use of org.springframework.ide.vscode.commons.util.text.TextDocument in project sts4 by spring-projects.
the class BootJavaHoverProvider method handle.
@Override
public Hover handle(TextDocumentPositionParams params) {
SimpleTextDocumentService documents = server.getTextDocumentService();
if (documents.get(params) != null) {
TextDocument doc = documents.get(params).copy();
try {
int offset = doc.toOffset(params.getPosition());
Hover hoverResult = provideHover(doc, offset);
if (hoverResult != null) {
return hoverResult;
}
} catch (Exception e) {
}
}
return SimpleTextDocumentService.NO_HOVER;
}
use of org.springframework.ide.vscode.commons.util.text.TextDocument in project sts4 by spring-projects.
the class BootJavaReferencesHandler method handle.
@Override
public List<? extends Location> handle(ReferenceParams params) {
SimpleTextDocumentService documents = server.getTextDocumentService();
TextDocument doc = documents.get(params).copy();
if (doc != null) {
try {
int offset = doc.toOffset(params.getPosition());
List<? extends Location> referencesResult = provideReferences(doc, offset);
if (referencesResult != null) {
return referencesResult;
}
} catch (Exception e) {
}
}
return SimpleTextDocumentService.NO_REFERENCES;
}
use of org.springframework.ide.vscode.commons.util.text.TextDocument in project sts4 by spring-projects.
the class SpringIndexer method getTempTextDocument.
private TextDocument getTempTextDocument(String docURI, AtomicReference<TextDocument> docRef, String content) throws Exception {
TextDocument doc = docRef.get();
if (doc == null) {
doc = createTempTextDocument(docURI, content);
docRef.set(doc);
}
return doc;
}
use of org.springframework.ide.vscode.commons.util.text.TextDocument in project sts4 by spring-projects.
the class SpringIndexer method scanFiles.
private void scanFiles(ASTParser parser, String[] javaFiles, String[] classpathEntries) throws Exception {
Map<String, String> options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_10, options);
parser.setCompilerOptions(options);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setStatementsRecovery(true);
parser.setBindingsRecovery(true);
parser.setResolveBindings(true);
parser.setIgnoreMethodBodies(false);
String[] sourceEntries = new String[] {};
parser.setEnvironment(classpathEntries, sourceEntries, null, true);
FileASTRequestor requestor = new FileASTRequestor() {
@Override
public void acceptAST(String sourceFilePath, CompilationUnit cu) {
String docURI = UriUtil.toUri(new File(sourceFilePath)).toString();
AtomicReference<TextDocument> docRef = new AtomicReference<>();
scanAST(cu, docURI, docRef, null);
}
};
parser.createASTs(javaFiles, null, new String[0], requestor, null);
}
use of org.springframework.ide.vscode.commons.util.text.TextDocument in project sts4 by spring-projects.
the class SpringIndexer method createTempTextDocument.
private TextDocument createTempTextDocument(String docURI, String content) throws Exception {
if (content == null) {
Path path = Paths.get(new URI(docURI));
content = new String(Files.readAllBytes(path));
}
TextDocument doc = new TextDocument(docURI, LanguageId.PLAINTEXT, 0, content);
return doc;
}
Aggregations