Skip to content

Commit 812102a

Browse files
committed
GH-1431: let webflux index elements create document symbols on-demand
1 parent 6f66310 commit 812102a

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/WebfluxHandlerMethodIndexElement.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
*******************************************************************************/
1111
package org.springframework.ide.vscode.boot.java.requestmapping;
1212

13+
import org.eclipse.lsp4j.Range;
14+
1315
public class WebfluxHandlerMethodIndexElement extends RequestMappingIndexElement {
1416

1517
private final String handlerClass;
1618
private final String handlerMethod;
1719

18-
public WebfluxHandlerMethodIndexElement(String handlerClass, String handlerMethod, String path, String[] httpMethods, String[] contentTypes, String[] acceptTypes) {
19-
super(path, httpMethods, contentTypes, acceptTypes);
20+
public WebfluxHandlerMethodIndexElement(String handlerClass, String handlerMethod, String path, String[] httpMethods, String[] contentTypes, String[] acceptTypes,
21+
Range range, String symbolLabel) {
22+
super(path, httpMethods, contentTypes, acceptTypes, range, symbolLabel);
2023

2124
this.handlerClass = handlerClass;
2225
this.handlerMethod = handlerMethod;

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/WebfluxRouterSymbolProvider.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,18 @@ protected static void extractMappingSymbol(MethodInvocation node, TextDocument d
125125
try {
126126

127127
Location location = new Location(doc.getUri(), doc.toRange(methodNameStart, node.getLength() - (methodNameStart - invocationStart)));
128-
WebfluxHandlerMethodIndexElement handler = extractHandlerInformation(node, path, httpMethods, contentTypes, acceptTypes);
129-
WebfluxRouteElementRangesIndexElement elements = extractElementsInformation(pathElements, httpMethods, contentTypes, acceptTypes);
130-
131-
if (handler != null) indexElementsCollector.add(handler);
132-
if (elements != null) indexElementsCollector.add(elements);
133128

134129
WorkspaceSymbol symbol = RouteUtils.createRouteSymbol(location, path, getElementStrings(httpMethods),
135130
getElementStrings(contentTypes), getElementStrings(acceptTypes));
136131

137132
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(), symbol));
138133

134+
WebfluxHandlerMethodIndexElement handler = extractHandlerInformation(node, path, httpMethods, contentTypes, acceptTypes, location.getRange(), symbol.getName());
135+
WebfluxRouteElementRangesIndexElement elements = extractElementsInformation(pathElements, httpMethods, contentTypes, acceptTypes);
136+
137+
if (handler != null) indexElementsCollector.add(handler);
138+
if (elements != null) indexElementsCollector.add(elements);
139+
139140
} catch (BadLocationException e) {
140141
log.error("bad location while extracting mapping symbol for " + doc.getUri(), e);
141142
}
@@ -319,7 +320,7 @@ private static void extractNestedValue(ASTNode node, Collection<WebfluxRouteElem
319320
}
320321

321322
private static WebfluxHandlerMethodIndexElement extractHandlerInformation(MethodInvocation node, String path, WebfluxRouteElement[] httpMethods,
322-
WebfluxRouteElement[] contentTypes, WebfluxRouteElement[] acceptTypes) {
323+
WebfluxRouteElement[] contentTypes, WebfluxRouteElement[] acceptTypes, Range range, String symbolLabel) {
323324

324325
List<?> arguments = node.arguments();
325326

@@ -336,7 +337,8 @@ private static WebfluxHandlerMethodIndexElement extractHandlerInformation(Method
336337
String handlerMethod = methodBinding.getMethodDeclaration().toString();
337338
if (handlerMethod != null) handlerMethod = handlerMethod.trim();
338339

339-
return new WebfluxHandlerMethodIndexElement(handlerClass, handlerMethod, path, getElementStrings(httpMethods), getElementStrings(contentTypes), getElementStrings(acceptTypes));
340+
return new WebfluxHandlerMethodIndexElement(handlerClass, handlerMethod, path, getElementStrings(httpMethods), getElementStrings(contentTypes),
341+
getElementStrings(acceptTypes), range, symbolLabel);
340342
}
341343
}
342344
}

0 commit comments

Comments
 (0)