diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/WebfluxUtils.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/WebfluxUtils.java index af7a3c547d..218aa991cf 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/WebfluxUtils.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/WebfluxUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Pivotal, Inc. + * Copyright (c) 2018, 2024 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -67,8 +67,11 @@ public static SimpleName extractSimpleNameArgument(MethodInvocation node) { List arguments = node.arguments(); if (arguments != null && arguments.size() > 0) { Object object = arguments.get(0); - if (object instanceof SimpleName) { - return (SimpleName) object; + if (object instanceof SimpleName sn) { + return sn; + } + else if (object instanceof QualifiedName qn) { + return qn.getName(); } } return null; diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxMappingSymbolProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxMappingSymbolProviderTest.java index c094e2a308..170e9b15ce 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxMappingSymbolProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/WebFluxMappingSymbolProviderTest.java @@ -89,10 +89,10 @@ void testRoutesMappingSymbols() throws Exception { String docUri = directory.toPath().resolve("src/main/java/org/test/QuoteRouter.java").toUri().toString(); List symbols = indexer.getSymbols(docUri); assertEquals(6, symbols.size()); - assertTrue(containsSymbol(symbols, "@/hello -- GET - Accept: text/plain", docUri, 22, 5, 22, 70)); - assertTrue(containsSymbol(symbols, "@/echo -- POST - Accept: text/plain - Content-Type: text/plain", docUri, 23, 5, 23, 101)); - assertTrue(containsSymbol(symbols, "@/quotes -- GET - Accept: application/json", docUri, 24, 5, 24, 86)); - assertTrue(containsSymbol(symbols, "@/quotes -- GET - Accept: application/stream+json", docUri, 25, 5, 25, 94)); + assertTrue(containsSymbol(symbols, "@/hello -- GET - Accept: text/plain", docUri, 23, 5, 23, 70)); + assertTrue(containsSymbol(symbols, "@/echo -- POST - Accept: text/plain - Content-Type: text/plain", docUri, 24, 5, 24, 101)); + assertTrue(containsSymbol(symbols, "@/quotes -- GET - Accept: application/json", docUri, 25, 5, 25, 86)); + assertTrue(containsSymbol(symbols, "@/quotes -- GET - Accept: application/stream+json", docUri, 26, 5, 26, 122)); Bean[] routeBeans = springIndex.getBeansWithName(project.getElementName(), "route"); assertEquals(1, routeBeans.length); diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-webflux-project/src/main/java/org/test/QuoteRouter.java b/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-webflux-project/src/main/java/org/test/QuoteRouter.java index a322a8cd4d..b68625610b 100644 --- a/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-webflux-project/src/main/java/org/test/QuoteRouter.java +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-webflux-project/src/main/java/org/test/QuoteRouter.java @@ -5,9 +5,10 @@ import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerResponse; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RequestPredicates; import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; import static org.springframework.http.MediaType.TEXT_PLAIN; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RequestPredicates.POST; @@ -23,6 +24,6 @@ public RouterFunction route(QuoteHandler quoteHandler) { .route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello) .andRoute(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo) .andRoute(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes) - .andRoute(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes); + .andRoute(RequestPredicates.GET("/quotes").and(accept(MediaType.APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes); } } \ No newline at end of file