[groovy] branch master updated (f6d77bf -> 3564976)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch master updated (f6d77bf -> 3564976)

paulk
This is an automated email from the ASF dual-hosted git repository.

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


    from f6d77bf  bump rat plugin version
     new 49e4f82  GROOVY-8296: Groovydoc Recognition exception with Java 8 class (improve name resolving)
     new 3564976  GROOVY-8296: Groovydoc Recognition exception with Java 8 class (improve name resolving)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../groovy/tools/groovydoc/SimpleGroovyClassDoc.java | 11 +++++++++++
 .../tools/groovydoc/antlr4/GroovydocJavaVisitor.java | 20 +++++++++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)

Reply | Threaded
Open this post in threaded view
|

[groovy] 01/02: GROOVY-8296: Groovydoc Recognition exception with Java 8 class (improve name resolving)

paulk
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 <[hidden email]>
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()));
         }
     }
 

Reply | Threaded
Open this post in threaded view
|

[groovy] 02/02: GROOVY-8296: Groovydoc Recognition exception with Java 8 class (improve name resolving)

paulk
In reply to this post by paulk
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 35649760d0130c78e537aa766a2bbaa4274493da
Author: Paul King <[hidden email]>
AuthorDate: Sun Jan 12 18:25:06 2020 +1000

    GROOVY-8296: Groovydoc Recognition exception with Java 8 class (improve name resolving)
---
 .../codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
index ff1221c..140e4d2 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
@@ -588,6 +588,8 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc imp
             if (slashIndex < 1) {
                 doc = resolveInternalClassDocFromImport(rootDoc, name);
                 if (doc != null) return doc;
+                doc = resolveInternalClassDocFromSamePackage(rootDoc, name);
+                if (doc != null) return doc;
                 for (GroovyClassDoc nestedDoc : nested) {
                     if (nestedDoc.name().endsWith("." + name))
                         return nestedDoc;
@@ -680,6 +682,15 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc imp
         return null;
     }
 
+    private GroovyClassDoc resolveInternalClassDocFromSamePackage(GroovyRootDoc rootDoc, String baseName) {
+        if (isPrimitiveType(baseName)) return null;
+        if (baseName.contains(".")) return null;
+        int lastSlash = fullPathName.lastIndexOf("/");
+        if (lastSlash < 0) return null;
+        String pkg = fullPathName.substring(0, lastSlash + 1);
+        return ((SimpleGroovyRootDoc)rootDoc).classNamedExact(pkg + baseName);
+    }
+
     private Class resolveExternalClassFromImport(String name) {
         if (isPrimitiveType(name)) return null;
         Class<?> clazz = resolvedExternalClassesCache.get(name);