groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] 01/02: GROOVY-8296: Groovydoc Recognition exception with Java 8 class (improve name resolving)
Date Sun, 12 Jan 2020 08:26:29 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 49e4f821e82d5fd2075bfc9189408ba7c257d037
Author: Paul King <paulk@asert.com.au>
AuthorDate: Sun Jan 12 18:24:56 2020 +1000

    GROOVY-8296: Groovydoc Recognition exception with Java 8 class (improve name resolving)
---
 .../tools/groovydoc/antlr4/GroovydocJavaVisitor.java | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/antlr4/GroovydocJavaVisitor.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/antlr4/GroovydocJavaVisitor.java
index 882a1f6..d2f77d0 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/antlr4/GroovydocJavaVisitor.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/antlr4/GroovydocJavaVisitor.java
@@ -35,6 +35,7 @@ import com.github.javaparser.ast.body.TypeDeclaration;
 import com.github.javaparser.ast.expr.AnnotationExpr;
 import com.github.javaparser.ast.expr.Name;
 import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations;
+import com.github.javaparser.ast.type.ClassOrInterfaceType;
 import com.github.javaparser.ast.type.Type;
 import com.github.javaparser.ast.type.TypeParameter;
 import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
@@ -162,20 +163,27 @@ public class GroovydocJavaVisitor extends VoidVisitorAdapter<Object>
{
         }
         n.getExtendedTypes().forEach(et -> {
             if (n.isInterface()) {
-                currentClassDoc.addInterfaceName(et.getNameAsString());
+                currentClassDoc.addInterfaceName(fullName(et));
             } else {
-                currentClassDoc.setSuperClassName(et.getNameAsString());
+                currentClassDoc.setSuperClassName(fullName(et));
             }
         });
         currentClassDoc.setNameWithTypeArgs(currentClassDoc.name() + genericTypesAsString(n.getTypeParameters()));
         n.getImplementedTypes().forEach(classOrInterfaceType ->
-                currentClassDoc.addInterfaceName(classOrInterfaceType.getNameAsString()));
+                currentClassDoc.addInterfaceName(fullName(classOrInterfaceType)));
         super.visit(n, arg);
         if (parent != null) {
             currentClassDoc = parent;
         }
     }
 
+    private String fullName(ClassOrInterfaceType et) {
+        StringBuilder name = new StringBuilder();
+        et.getScope().ifPresent(sc -> name.append(sc.toString()));
+        name.append(et.getNameAsString());
+        return name.toString();
+    }
+
     private String genericTypesAsString(NodeList<TypeParameter> typeParameters) {
         return DefaultGroovyMethods.join(typeParameters, ", ");
     }
@@ -203,15 +211,13 @@ public class GroovydocJavaVisitor extends VoidVisitorAdapter<Object>
{
 
     private void processAnnotations(SimpleGroovyProgramElementDoc element, NodeWithAnnotations<?>
n) {
         for (AnnotationExpr an : n.getAnnotations()) {
-            String name = an.getNameAsString();
-            element.addAnnotationRef(new SimpleGroovyAnnotationRef(name, name));
+            element.addAnnotationRef(new SimpleGroovyAnnotationRef(an.getClass().getName(),
an.getNameAsString()));
         }
     }
 
     private void processAnnotations(SimpleGroovyParameter param, NodeWithAnnotations<?>
n) {
         for (AnnotationExpr an : n.getAnnotations()) {
-            String name = an.getNameAsString();
-            param.addAnnotationRef(new SimpleGroovyAnnotationRef(name, name));
+            param.addAnnotationRef(new SimpleGroovyAnnotationRef(an.getClass().getName(),
an.getNameAsString()));
         }
     }
 


Mime
View raw message