use of org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation in project sts4 by spring-projects.
the class RequestMappingSymbolProvider method getSymbols.
@Override
public Collection<EnhancedSymbolInformation> getSymbols(Annotation node, ITypeBinding annotationType, Collection<ITypeBinding> metaAnnotations, TextDocument doc) {
if (node.getParent() instanceof MethodDeclaration) {
try {
Location location = new Location(doc.getUri(), doc.toRange(node.getStartPosition(), node.getLength()));
String[] path = getPath(node);
String[] parentPath = getParentPath(node);
String[] methods = getMethod(node);
String[] contentTypes = getContentTypes(node);
String[] acceptTypes = getAcceptTypes(node);
return (parentPath == null ? Stream.of("") : Arrays.stream(parentPath)).filter(Objects::nonNull).flatMap(parent -> (path == null ? Stream.<String>empty() : Arrays.stream(path)).filter(Objects::nonNull).map(p -> {
String separator = !parent.endsWith("/") && !p.startsWith("/") ? "/" : "";
String resultPath = parent + separator + p;
if (resultPath.endsWith("/")) {
resultPath = resultPath.substring(0, resultPath.length() - 1);
}
return resultPath.startsWith("/") ? resultPath : "/" + resultPath;
})).map(p -> RouteUtils.createRouteSymbol(location, p, methods, contentTypes, acceptTypes, null)).collect(Collectors.toList());
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
use of org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation 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.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation in project sts4 by spring-projects.
the class WebfluxRouterSymbolProvider method getSymbolsForRouterFunction.
private Collection<EnhancedSymbolInformation> getSymbolsForRouterFunction(MethodDeclaration methodDeclaration, TextDocument doc) {
List<EnhancedSymbolInformation> result = new ArrayList<>();
Block body = methodDeclaration.getBody();
body.accept(new ASTVisitor() {
@Override
public boolean visit(MethodInvocation node) {
IMethodBinding methodBinding = node.resolveMethodBinding();
if (WebfluxUtils.isRouteMethodInvocation(methodBinding)) {
extractMappingSymbol(node, doc, result);
}
return super.visit(node);
}
});
return result;
}
Aggregations