diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/symbol/MicronautSymbolFinder.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/symbol/MicronautSymbolFinder.java index 8ab6e60998aa..dc523e6056fb 100644 --- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/symbol/MicronautSymbolFinder.java +++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/symbol/MicronautSymbolFinder.java @@ -135,6 +135,7 @@ public Void visitClass(ClassTree node, String path) { if (metaAnnotated != null) { Element annEl = metaAnnotated.first().getAnnotationType().asElement(); if ("io.micronaut.http.annotation.Controller".contentEquals(((TypeElement) annEl).getQualifiedName())) { + path = ""; for (Map.Entry entry : metaAnnotated.first().getElementValues().entrySet()) { if ("value".contentEquals(entry.getKey().getSimpleName())) { path = (String) entry.getValue().getValue(); @@ -153,19 +154,34 @@ public Void visitClass(ClassTree node, String path) { @Override public Void visitMethod(MethodTree node, String path) { - TreePath treePath = this.getCurrentPath(); - MthIterator it = new MthIterator(cc.getTrees().getElement(treePath), cc.getElements(), cc.getTypes()); - while (it.hasNext()) { - for (AnnotationMirror ann : it.next().getAnnotationMirrors()) { - String method = getEndpointMethod((TypeElement) ann.getAnnotationType().asElement()); - if (method != null) { - for (Map.Entry entry : ann.getElementValues().entrySet()) { - if ("value".contentEquals(entry.getKey().getSimpleName()) || "uri".contentEquals(entry.getKey().getSimpleName())) { - String name = '@' + (path != null ? path : "") + entry.getValue().getValue() + " -- " + method; + if (path != null) { + TreePath treePath = this.getCurrentPath(); + MthIterator it = new MthIterator(cc.getTrees().getElement(treePath), cc.getElements(), cc.getTypes()); + while (it.hasNext()) { + for (AnnotationMirror ann : it.next().getAnnotationMirrors()) { + String method = getEndpointMethod((TypeElement) ann.getAnnotationType().asElement()); + if (method != null) { + List ids = new ArrayList<>(); + Map values = ann.getElementValues(); + if (values.isEmpty()) { + ids.add("/"); + } else { + for (Map.Entry entry : values.entrySet()) { + if ("value".contentEquals(entry.getKey().getSimpleName()) || "uri".contentEquals(entry.getKey().getSimpleName())) { + ids.add((String) entry.getValue().getValue()); + } else if ("uris".contentEquals(entry.getKey().getSimpleName())) { + for (AnnotationValue av : (List) entry.getValue().getValue()) { + ids.add((String) av.getValue()); + } + } + } + } + for (Object id : ids) { + String name = '@' + path + id + " -- " + method; int[] span = cc.getTreeUtilities().findNameSpan(node); ret.add(new SymbolLocation(name, (int) sp.getStartPosition(treePath.getCompilationUnit(), node), (int) sp.getEndPosition(treePath.getCompilationUnit(), node), span[0], span[1])); - return null; } + return null; } } } @@ -193,9 +209,9 @@ private void store(FileObject indexFolder, URL url, String resourceName, List