Skip to content

Commit 3400541

Browse files
fbricondatho7561
authored andcommitted
fix Renarde url computation
Signed-off-by: Fred Bricon <fbricon@gmail.com>
1 parent 958d1c6 commit 3400541

4 files changed

Lines changed: 49 additions & 8 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,5 @@ buildNumber.properties
115115
# Ignore config for Eclipse PDE in VS Code until we get remote repositories working
116116
javaConfig.json
117117
**/*.target
118+
119+
.DS_Store
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package rest;
2+
3+
import javax.ws.rs.Path;
4+
import io.quarkiverse.renarde.Controller;
5+
6+
@Path("/play")
7+
public class Game extends Controller {
8+
9+
@Path("/id")
10+
public String endpoint() {
11+
return "id";
12+
}
13+
14+
public String start() {
15+
return "start";
16+
}
17+
}

quarkus.jdt.ext/com.redhat.microprofile.jdt.quarkus.test/src/main/java/com/redhat/microprofile/jdt/quarkus/renarde/RenardeJaxRsTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ public void codeLens() throws Exception {
5252
cl("http://localhost:8080/Application/endpoint", "", r(34, 18, 26)));
5353
}
5454

55+
@Test
56+
public void absolutePathCodeLens() throws Exception {
57+
IJavaProject javaProject = loadMavenProject(quarkus_renarde_todo);
58+
59+
assertNotNull(javaProject);
60+
61+
MicroProfileJavaCodeLensParams params = new MicroProfileJavaCodeLensParams();
62+
params.setCheckServerAvailable(false);
63+
IFile javaFile = javaProject.getProject().getFile(new Path("src/main/java/rest/Game.java"));
64+
params.setUri(javaFile.getLocation().toFile().toURI().toString());
65+
params.setUrlCodeLensEnabled(true);
66+
67+
assertCodeLens(params, JDT_UTILS, //
68+
cl("http://localhost:8080/play/id", "", r(9, 16, 16)),
69+
cl("http://localhost:8080/play/start", "", r(13, 18, 23)));
70+
}
71+
5572
@Test
5673
public void workspaceSymbols() throws Exception {
5774
IJavaProject javaProject = loadMavenProject(quarkus_renarde_todo);
@@ -73,7 +90,9 @@ public void workspaceSymbols() throws Exception {
7390
si("@/Todos/delete: POST", r(35, 16, 22)), //
7491
si("@/Todos/done: POST", r(46, 16, 20)), //
7592
si("@/Todos/index: GET", r(29, 28, 33)), //
76-
si("@/about: GET", r(25, 28, 33)));
93+
si("@/about: GET", r(25, 28, 33)),
94+
si("@/play/id: GET", r(9, 18, 26)),
95+
si("@/play/start: GET", r(13, 18, 23)));
7796
}
7897

7998
}

quarkus.jdt.ext/com.redhat.microprofile.jdt.quarkus/src/main/java/com/redhat/microprofile/jdt/internal/quarkus/renarde/java/RenardeJaxRsInfoProvider.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ public List<JaxRsMethodInfo> getJaxRsMethodInfo(ITypeRoot typeRoot, JaxRsContext
6161
IProgressMonitor monitor) {
6262
try {
6363
IType type = typeRoot.findPrimaryType();
64-
String typeSegment = JaxRsUtils.getJaxRsPathValue(type);
65-
if (typeSegment == null) {
66-
typeSegment = type.getElementName();
67-
}
64+
String pathSegment = JaxRsUtils.getJaxRsPathValue(type);
65+
String typeSegment = type.getElementName();
6866

6967
List<JaxRsMethodInfo> methodInfos = new ArrayList<>();
7068
for (IMethod method : type.getMethods()) {
@@ -85,9 +83,14 @@ public List<JaxRsMethodInfo> getJaxRsMethodInfo(ITypeRoot typeRoot, JaxRsContext
8583
if (methodSegment == null) {
8684
methodSegment = method.getElementName();
8785
}
88-
String url = methodSegment.startsWith("/") ? methodSegment
89-
: JaxRsUtils.buildURL(typeSegment, methodSegment);
90-
url = JaxRsUtils.buildURL(jaxrsContext.getLocalBaseURL(), url);
86+
String path;
87+
if (pathSegment == null) {
88+
path = methodSegment.startsWith("/") ? methodSegment : JaxRsUtils.buildURL(typeSegment, methodSegment);
89+
} else {
90+
path = JaxRsUtils.buildURL(pathSegment, methodSegment);
91+
}
92+
93+
String url = JaxRsUtils.buildURL(jaxrsContext.getLocalBaseURL(), path);
9194

9295
JaxRsMethodInfo methodInfo = createMethodInfo(method, url);
9396
if (methodInfo != null) {

0 commit comments

Comments
 (0)