use of org.eclipse.lsp4j.DocumentSymbolParams 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.DocumentSymbolParams in project eclipse.jdt.ls by eclipse.
the class DocumentSymbolHandlerTest method getSymbols.
private List<? extends SymbolInformation> getSymbols(String className) throws JavaModelException, UnsupportedEncodingException, InterruptedException, ExecutionException {
String uri = ClassFileUtil.getURI(project, className);
TextDocumentIdentifier identifier = new TextDocumentIdentifier(uri);
DocumentSymbolParams params = new DocumentSymbolParams();
params.setTextDocument(identifier);
List<? extends SymbolInformation> symbols = handler.documentSymbol(params, monitor);
assertTrue(symbols.size() > 0);
return symbols;
}
use of org.eclipse.lsp4j.DocumentSymbolParams in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testDocumentSymbol.
protected void testDocumentSymbol(final Procedure1<? super DocumentSymbolConfiguraiton> configurator) {
try {
@Extension final DocumentSymbolConfiguraiton configuration = new DocumentSymbolConfiguraiton();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String fileUri = this.initializeContext(configuration).getUri();
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
DocumentSymbolParams _documentSymbolParams = new DocumentSymbolParams(_textDocumentIdentifier);
final CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>> symbolsFuture = this.languageServer.documentSymbol(_documentSymbolParams);
final List<Either<SymbolInformation, DocumentSymbol>> symbols = symbolsFuture.get();
Procedure1<? super List<Either<SymbolInformation, DocumentSymbol>>> _assertSymbols = configuration.getAssertSymbols();
boolean _tripleNotEquals = (_assertSymbols != null);
if (_tripleNotEquals) {
configuration.getAssertSymbols().apply(symbols);
} else {
final Function1<Either<SymbolInformation, DocumentSymbol>, Object> _function = (Either<SymbolInformation, DocumentSymbol> it) -> {
Object _xifexpression = null;
if (this.hierarchicalDocumentSymbolSupport) {
_xifexpression = it.getRight();
} else {
_xifexpression = it.getLeft();
}
return _xifexpression;
};
final List<Object> unwrappedSymbols = ListExtensions.<Either<SymbolInformation, DocumentSymbol>, Object>map(symbols, _function);
final String actualSymbols = this.toExpectation(unwrappedSymbols);
this.assertEquals(configuration.getExpectedSymbols(), actualSymbols);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.DocumentSymbolParams in project ballerina by ballerina-lang.
the class BallerinaTextDocumentService method documentSymbol.
@Override
public CompletableFuture<List<? extends SymbolInformation>> documentSymbol(DocumentSymbolParams params) {
String uri = params.getTextDocument().getUri();
List<SymbolInformation> symbols = new ArrayList<>();
TextDocumentServiceContext symbolsContext = new TextDocumentServiceContext();
symbolsContext.put(DocumentServiceKeys.FILE_URI_KEY, uri);
symbolsContext.put(DocumentServiceKeys.SYMBOL_LIST_KEY, symbols);
BLangPackage bLangPackage = TextDocumentServiceUtil.getBLangPackage(symbolsContext, documentManager, false, LSCustomErrorStrategy.class, false).get(0);
symbolsContext.put(DocumentServiceKeys.CURRENT_PACKAGE_NAME_KEY, bLangPackage.symbol.getName().getValue());
Optional<BLangCompilationUnit> documentCUnit = bLangPackage.getCompilationUnits().stream().filter(cUnit -> (uri.endsWith(cUnit.getName()))).findFirst();
documentCUnit.ifPresent(cUnit -> {
SymbolFindingVisitor visitor = new SymbolFindingVisitor(symbolsContext);
cUnit.accept(visitor);
});
return CompletableFuture.supplyAsync(() -> symbols);
}
use of org.eclipse.lsp4j.DocumentSymbolParams in project sts4 by spring-projects.
the class LanguageServerHarness method getDocumentSymbols.
public List<? extends SymbolInformation> getDocumentSymbols(TextDocumentInfo document) throws Exception {
// TODO: if the server works properly this shouldn't be needed it should do that internally itself somehow.
waitForReconcile();
DocumentSymbolParams params = new DocumentSymbolParams(document.getId());
return getServer().getTextDocumentService().documentSymbol(params).get();
}
Aggregations