use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.
the class InFileSymbolsProvider method fetchFor.
@Override
public Collection<SymbolInformation> fetchFor(String query) throws Exception {
DocumentSymbolParams params = new DocumentSymbolParams(new TextDocumentIdentifier(info.getFileUri().toString()));
CompletableFuture<List<? extends SymbolInformation>> symbolsFuture = info.getLanguageClient().getTextDocumentService().documentSymbol(params);
List<? extends SymbolInformation> symbols = symbolsFuture.get();
return symbols == null ? ImmutableList.of() : ImmutableList.copyOf(symbols);
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.
the class Editor method assertGotoDefinition.
public void assertGotoDefinition(Position pos, Range expectedTarget) throws Exception {
TextDocumentIdentifier textDocumentId = doc.getId();
TextDocumentPositionParams params = new TextDocumentPositionParams(textDocumentId, textDocumentId.getUri(), pos);
List<? extends Location> defs = harness.getDefinitions(params);
assertEquals(1, defs.size());
assertEquals(new Location(textDocumentId.getUri(), expectedTarget), defs.get(0));
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.
the class TextDocumentInfo method getId.
public TextDocumentIdentifier getId() {
TextDocumentIdentifier id = new TextDocumentIdentifier();
id.setUri(getUri());
return id;
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.
the class SpringIndexer method createDocument.
public CompletableFuture<Void> createDocument(String docURI) {
synchronized (this) {
if (docURI.endsWith(".java") && lastInitializeItem != null) {
try {
Optional<IJavaProject> maybeProject = projectFinder.find(new TextDocumentIdentifier(docURI));
if (maybeProject.isPresent()) {
String[] classpathEntries = getClasspathEntries(maybeProject.get());
String content = FileUtils.readFileToString(new File(new URI(docURI)));
UpdateItem updateItem = new UpdateItem(docURI, content, classpathEntries);
updateQueue.put(updateItem);
return updateItem.getFuture();
}
} catch (Exception e) {
log.error("", e);
return Futures.error(e);
}
}
}
return CompletableFuture.completedFuture(null);
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.
the class SpringIndexer method updateDocument.
public CompletableFuture<Void> updateDocument(String docURI, String content) {
synchronized (this) {
if (docURI.endsWith(".java") && lastInitializeItem != null) {
try {
Optional<IJavaProject> maybeProject = projectFinder.find(new TextDocumentIdentifier(docURI));
if (maybeProject.isPresent()) {
String[] classpathEntries = getClasspathEntries(maybeProject.get());
UpdateItem updateItem = new UpdateItem(docURI, content, classpathEntries);
updateQueue.put(updateItem);
return updateItem.getFuture();
}
} catch (Exception e) {
log.error("{}", e);
}
}
}
return null;
}
Aggregations