Merge branch 'master' of github.com:spring-projects/sts4
This commit is contained in:
@@ -56,6 +56,9 @@ public class RequestMappingSymbolProvider implements SymbolProvider {
|
||||
.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 -> "@" + p + " -- " + methodStr)
|
||||
@@ -121,7 +124,7 @@ public class RequestMappingSymbolProvider implements SymbolProvider {
|
||||
return ASTUtils.getExpressionValueAsArray(expression);
|
||||
}
|
||||
|
||||
return null;
|
||||
return new String[] { "" };
|
||||
}
|
||||
|
||||
private String[] getParentPath(Annotation node) {
|
||||
|
||||
@@ -59,6 +59,18 @@ public class RequestMappingSymbolProviderTest {
|
||||
assertTrue(containsSymbol(symbols, "@/parent/greeting -- GET", uriPrefix + "/src/main/java/org/test/ParentMappingClass.java", 8, 1, 8, 47));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyPathWithParentRequestMappingSymbol() throws Exception {
|
||||
harness.intialize(new File(ProjectsHarness.class.getResource("/test-projects/test-request-mapping-symbols/").toURI()));
|
||||
|
||||
File directory = new File(ProjectsHarness.class.getResource("/test-projects/test-request-mapping-symbols/").toURI());
|
||||
|
||||
String uriPrefix = "file://" + directory.getAbsolutePath();
|
||||
List<? extends SymbolInformation> symbols = harness.getServer().getSpringIndexer().getSymbols(uriPrefix + "/src/main/java/org/test/ParentMappingClass2.java");
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/parent2 -- GET,POST,DELETE", uriPrefix + "/src/main/java/org/test/ParentMappingClass2.java", 8, 1, 8, 16));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiRequestMappingSymbol() throws Exception {
|
||||
harness.intialize(new File(ProjectsHarness.class.getResource("/test-projects/test-request-mapping-symbols/").toURI()));
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.test;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod.*;
|
||||
|
||||
@RequestMapping(value="parent2", method= {GET,POST,DELETE})
|
||||
public class ParentMappingClass2 {
|
||||
|
||||
@RequestMapping
|
||||
public void nothing() {}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user