GH-1431: let webflux index elements create document symbols on-demand
This commit is contained in:
@@ -10,13 +10,16 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.requestmapping;
|
||||
|
||||
import org.eclipse.lsp4j.Range;
|
||||
|
||||
public class WebfluxHandlerMethodIndexElement extends RequestMappingIndexElement {
|
||||
|
||||
private final String handlerClass;
|
||||
private final String handlerMethod;
|
||||
|
||||
public WebfluxHandlerMethodIndexElement(String handlerClass, String handlerMethod, String path, String[] httpMethods, String[] contentTypes, String[] acceptTypes) {
|
||||
super(path, httpMethods, contentTypes, acceptTypes);
|
||||
public WebfluxHandlerMethodIndexElement(String handlerClass, String handlerMethod, String path, String[] httpMethods, String[] contentTypes, String[] acceptTypes,
|
||||
Range range, String symbolLabel) {
|
||||
super(path, httpMethods, contentTypes, acceptTypes, range, symbolLabel);
|
||||
|
||||
this.handlerClass = handlerClass;
|
||||
this.handlerMethod = handlerMethod;
|
||||
|
||||
@@ -125,17 +125,18 @@ public class WebfluxRouterSymbolProvider {
|
||||
try {
|
||||
|
||||
Location location = new Location(doc.getUri(), doc.toRange(methodNameStart, node.getLength() - (methodNameStart - invocationStart)));
|
||||
WebfluxHandlerMethodIndexElement handler = extractHandlerInformation(node, path, httpMethods, contentTypes, acceptTypes);
|
||||
WebfluxRouteElementRangesIndexElement elements = extractElementsInformation(pathElements, httpMethods, contentTypes, acceptTypes);
|
||||
|
||||
if (handler != null) indexElementsCollector.add(handler);
|
||||
if (elements != null) indexElementsCollector.add(elements);
|
||||
|
||||
WorkspaceSymbol symbol = RouteUtils.createRouteSymbol(location, path, getElementStrings(httpMethods),
|
||||
getElementStrings(contentTypes), getElementStrings(acceptTypes));
|
||||
|
||||
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(), symbol));
|
||||
|
||||
WebfluxHandlerMethodIndexElement handler = extractHandlerInformation(node, path, httpMethods, contentTypes, acceptTypes, location.getRange(), symbol.getName());
|
||||
WebfluxRouteElementRangesIndexElement elements = extractElementsInformation(pathElements, httpMethods, contentTypes, acceptTypes);
|
||||
|
||||
if (handler != null) indexElementsCollector.add(handler);
|
||||
if (elements != null) indexElementsCollector.add(elements);
|
||||
|
||||
} catch (BadLocationException e) {
|
||||
log.error("bad location while extracting mapping symbol for " + doc.getUri(), e);
|
||||
}
|
||||
@@ -319,7 +320,7 @@ public class WebfluxRouterSymbolProvider {
|
||||
}
|
||||
|
||||
private static WebfluxHandlerMethodIndexElement extractHandlerInformation(MethodInvocation node, String path, WebfluxRouteElement[] httpMethods,
|
||||
WebfluxRouteElement[] contentTypes, WebfluxRouteElement[] acceptTypes) {
|
||||
WebfluxRouteElement[] contentTypes, WebfluxRouteElement[] acceptTypes, Range range, String symbolLabel) {
|
||||
|
||||
List<?> arguments = node.arguments();
|
||||
|
||||
@@ -336,7 +337,8 @@ public class WebfluxRouterSymbolProvider {
|
||||
String handlerMethod = methodBinding.getMethodDeclaration().toString();
|
||||
if (handlerMethod != null) handlerMethod = handlerMethod.trim();
|
||||
|
||||
return new WebfluxHandlerMethodIndexElement(handlerClass, handlerMethod, path, getElementStrings(httpMethods), getElementStrings(contentTypes), getElementStrings(acceptTypes));
|
||||
return new WebfluxHandlerMethodIndexElement(handlerClass, handlerMethod, path, getElementStrings(httpMethods), getElementStrings(contentTypes),
|
||||
getElementStrings(acceptTypes), range, symbolLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user