use of org.eclipse.lsp4j.SymbolInformation 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.SymbolInformation in project sts4 by spring-projects.
the class SpringIndexerHarness method getSymbolsInFile.
public List<TestSymbolInfo> getSymbolsInFile(String docURI) throws Exception {
List<? extends SymbolInformation> symbols = indexer.getSymbols(docURI);
if (symbols != null) {
symbols = new ArrayList<>(symbols);
Collections.sort(symbols, SYMBOL_COMPARATOR);
TextDocument doc = new TextDocument(docURI, LanguageId.JAVA, 1, IOUtils.toString(new URI(docURI)));
ImmutableList.Builder<TestSymbolInfo> symbolInfos = ImmutableList.builder();
for (SymbolInformation s : symbols) {
int start = doc.toOffset(s.getLocation().getRange().getStart());
int end = doc.toOffset(s.getLocation().getRange().getEnd());
symbolInfos.add(new TestSymbolInfo(doc.textBetween(start, end), s.getName()));
}
return symbolInfos.build();
}
return ImmutableList.of();
}
use of org.eclipse.lsp4j.SymbolInformation in project sts4 by spring-projects.
the class LiveAppURLSymbolProvider method getSymbols.
public List<? extends SymbolInformation> getSymbols(String query) {
System.out.println(query);
List<SymbolInformation> result = new ArrayList<>();
try {
SpringBootApp[] runningApps = runningAppProvider.getAllRunningSpringApps().toArray(new SpringBootApp[0]);
for (SpringBootApp app : runningApps) {
try {
String host = app.getHost();
String port = app.getPort();
Stream<String> urls = app.getRequestMappings().stream().flatMap(rm -> Arrays.stream(rm.getSplitPath())).map(path -> UrlUtil.createUrl(host, port, path));
urls.forEach(url -> result.add(new SymbolInformation(url, SymbolKind.Method, new Location(url, new Range(new Position(0, 0), new Position(0, 1))))));
} catch (Exception e) {
Log.log(e);
}
}
} catch (Exception e) {
Log.log(e);
}
return result;
}
use of org.eclipse.lsp4j.SymbolInformation in project sts4 by spring-projects.
the class BeansSymbolProvider method getSymbols.
@Override
public Collection<EnhancedSymbolInformation> getSymbols(Annotation node, ITypeBinding annotationType, Collection<ITypeBinding> metaAnnotations, TextDocument doc) {
if (isMethodAbstract(node))
return null;
ImmutableList.Builder<EnhancedSymbolInformation> symbols = ImmutableList.builder();
boolean isFunction = isFunctionBean(node);
String beanType = getBeanType(node);
for (Tuple2<String, DocumentRegion> nameAndRegion : getBeanNames(node, doc)) {
try {
symbols.add(new EnhancedSymbolInformation(new SymbolInformation(beanLabel(isFunction, nameAndRegion.getT1(), beanType, "@Bean"), SymbolKind.Interface, new Location(doc.getUri(), doc.toRange(nameAndRegion.getT2()))), null));
} catch (BadLocationException e) {
Log.log(e);
}
}
return symbols.build();
}
use of org.eclipse.lsp4j.SymbolInformation in project sts4 by spring-projects.
the class TypeBasedYamlSymbolHandler method createSymbol.
protected SymbolInformation createSymbol(TextDocument doc, Node node, YType type) throws BadLocationException {
DocumentRegion region = NodeUtil.region(doc, node);
Location location = new Location(doc.getUri(), doc.toRange(region.getStart(), region.getLength()));
SymbolInformation symbol = new SymbolInformation();
symbol.setName(region.toString());
symbol.setKind(symbolKind(type));
symbol.setLocation(location);
symbol.setContainerName(containerName(type));
return symbol;
}
Aggregations