use of org.eclipse.lsp4j.SymbolInformation 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.SymbolInformation in project sts4 by spring-projects.
the class Editor method assertDocumentSymbols.
public void assertDocumentSymbols(String... symbolsAndContainers) throws Exception {
Arrays.sort(symbolsAndContainers);
StringBuilder expected = new StringBuilder();
for (String string : symbolsAndContainers) {
expected.append(string + "\n");
}
List<? extends SymbolInformation> actualSymbols = getDocumentSymbols();
List<String> actuals = new ArrayList<>();
for (SymbolInformation actualSymbol : actualSymbols) {
assertEquals(doc.getUri(), actualSymbol.getLocation().getUri());
String coveredText = getText(actualSymbol.getLocation().getRange());
assertEquals(actualSymbol.getName(), coveredText);
actuals.add(coveredText + "|" + actualSymbol.getContainerName());
}
Collections.sort(actuals);
StringBuilder actual = new StringBuilder();
for (String string : actuals) {
actual.append(string + "\n");
}
assertEquals(expected.toString(), actual.toString());
}
use of org.eclipse.lsp4j.SymbolInformation in project sts4 by spring-projects.
the class TypeBasedYamlSymbolHandler method handle.
@Override
public List<? extends SymbolInformation> handle(DocumentSymbolParams params) {
Builder<SymbolInformation> builder = ImmutableList.builder();
TextDocument doc = documents.getDocument(params.getTextDocument().getUri());
for (Entry<Node, YType> entry : astTypeCache.getNodeTypes(params.getTextDocument().getUri()).getTypes().entrySet()) {
if (definitionTypes.contains(entry.getValue())) {
try {
builder.add(createSymbol(doc, entry.getKey(), entry.getValue()));
} catch (Exception e) {
Log.log(e);
}
}
}
return builder.build();
}
use of org.eclipse.lsp4j.SymbolInformation in project sts4 by spring-projects.
the class SpringIndexer method extractSymbolInformation.
private void extractSymbolInformation(Annotation node, String docURI, AtomicReference<TextDocument> docRef, String content) throws Exception {
ITypeBinding typeBinding = node.resolveTypeBinding();
if (typeBinding != null) {
Collection<SymbolProvider> providers = symbolProviders.get(typeBinding);
Collection<ITypeBinding> metaAnnotations = AnnotationHierarchies.getMetaAnnotations(typeBinding, symbolProviders::containsKey);
if (!providers.isEmpty()) {
TextDocument doc = getTempTextDocument(docURI, docRef, content);
for (SymbolProvider provider : providers) {
Collection<EnhancedSymbolInformation> sbls = provider.getSymbols(node, typeBinding, metaAnnotations, doc);
if (sbls != null) {
sbls.forEach(enhancedSymbol -> {
symbols.add(enhancedSymbol.getSymbol());
symbolsByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolInformation>()).add(enhancedSymbol.getSymbol());
if (enhancedSymbol.getAdditionalInformation() != null) {
addonInformation.addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
addonInformationByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolAddOnInformation>()).addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
}
});
}
}
} else {
SymbolInformation symbol = provideDefaultSymbol(node, docURI, docRef, content);
if (symbol != null) {
symbols.add(symbol);
symbolsByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolInformation>()).add(symbol);
}
}
}
}
use of org.eclipse.lsp4j.SymbolInformation in project sts4 by spring-projects.
the class SpringIndexer method extractSymbolInformation.
private void extractSymbolInformation(TypeDeclaration typeDeclaration, String docURI, AtomicReference<TextDocument> docRef, String content) throws Exception {
Collection<SymbolProvider> providers = symbolProviders.getAll();
if (!providers.isEmpty()) {
TextDocument doc = getTempTextDocument(docURI, docRef, content);
for (SymbolProvider provider : providers) {
Collection<EnhancedSymbolInformation> sbls = provider.getSymbols(typeDeclaration, doc);
if (sbls != null) {
sbls.forEach(enhancedSymbol -> {
symbols.add(enhancedSymbol.getSymbol());
symbolsByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolInformation>()).add(enhancedSymbol.getSymbol());
if (enhancedSymbol.getAdditionalInformation() != null) {
addonInformation.addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
addonInformationByDoc.computeIfAbsent(docURI, s -> new ArrayList<SymbolAddOnInformation>()).addAll(Arrays.asList(enhancedSymbol.getAdditionalInformation()));
}
});
}
}
}
}
Aggregations