groovy git commit: Minor refactoring: Generify GroovydocHolder

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

groovy git commit: Minor refactoring: Generify GroovydocHolder

Daniel.Sun
Repository: groovy
Updated Branches:
  refs/heads/master 43067475c -> e0b787dcf


Minor refactoring: Generify GroovydocHolder


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e0b787dc
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e0b787dc
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e0b787dc

Branch: refs/heads/master
Commit: e0b787dcfc50c1084aac7112ba9d8a2cc6aa0cfa
Parents: 4306747
Author: sunlan <[hidden email]>
Authored: Mon Sep 11 07:53:49 2017 +0800
Committer: sunlan <[hidden email]>
Committed: Mon Sep 11 07:53:49 2017 +0800

----------------------------------------------------------------------
 src/main/groovy/lang/groovydoc/Groovydoc.java       | 16 ++++++++--------
 src/main/groovy/lang/groovydoc/GroovydocHolder.java |  8 ++++++--
 src/main/org/codehaus/groovy/ast/ClassNode.java     |  6 +++---
 src/main/org/codehaus/groovy/ast/FieldNode.java     |  6 +++---
 src/main/org/codehaus/groovy/ast/MethodNode.java    |  4 ++--
 5 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/e0b787dc/src/main/groovy/lang/groovydoc/Groovydoc.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/groovydoc/Groovydoc.java b/src/main/groovy/lang/groovydoc/Groovydoc.java
index 7b281ff..d7d4204 100644
--- a/src/main/groovy/lang/groovydoc/Groovydoc.java
+++ b/src/main/groovy/lang/groovydoc/Groovydoc.java
@@ -28,23 +28,23 @@ import java.util.Objects;
 public class Groovydoc {
     private final String content;
     private List<GroovydocTag> tagList;
-    private final GroovydocHolder groovydocHolder;
+    private final GroovydocHolder holder;
 
     public Groovydoc(String content, GroovydocHolder groovydocHolder) {
         this.content = content;
-        this.groovydocHolder = groovydocHolder;
+        this.holder = groovydocHolder;
     }
 
     public Groovydoc(final String content, final AnnotatedElement annotatedElement) {
         this.content = content;
-        this.groovydocHolder = new GroovydocHolder() {
+        this.holder = new GroovydocHolder<AnnotatedElement>() {
             @Override
             public Groovydoc getGroovydoc() {
                 return Groovydoc.this;
             }
 
             @Override
-            public Object getInstance() {
+            public AnnotatedElement getInstance() {
                 return annotatedElement;
             }
         };
@@ -71,8 +71,8 @@ public class Groovydoc {
      * Get the holder of the groovydoc
      * @return the groovydoc holder
      */
-    public GroovydocHolder getGroovydocHolder() {
-        return groovydocHolder;
+    public GroovydocHolder getHolder() {
+        return holder;
     }
 
     @Override
@@ -81,12 +81,12 @@ public class Groovydoc {
         if (o == null || getClass() != o.getClass()) return false;
         Groovydoc groovydoc = (Groovydoc) o;
         return Objects.equals(content, groovydoc.content) &&
-                Objects.equals(groovydocHolder, groovydoc.groovydocHolder);
+                Objects.equals(holder, groovydoc.holder);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(content, groovydocHolder);
+        return Objects.hash(content, holder);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/groovy/blob/e0b787dc/src/main/groovy/lang/groovydoc/GroovydocHolder.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/groovydoc/GroovydocHolder.java b/src/main/groovy/lang/groovydoc/GroovydocHolder.java
index 8db3135..eb41df4 100644
--- a/src/main/groovy/lang/groovydoc/GroovydocHolder.java
+++ b/src/main/groovy/lang/groovydoc/GroovydocHolder.java
@@ -21,7 +21,7 @@ package groovy.lang.groovydoc;
 /**
  * Represents Groovydoc Holder
  */
-public interface GroovydocHolder {
+public interface GroovydocHolder<T> {
     String DOC_COMMENT = "_DOC_COMMENT"; // keys for meta data
     /**
      * Get the groovydoc
@@ -29,5 +29,9 @@ public interface GroovydocHolder {
      */
     Groovydoc getGroovydoc();
 
-    Object getInstance();
+    /**
+     * Get GroovydocHolder instance
+     * @return GroovydocHolder instance
+     */
+    T getInstance();
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/e0b787dc/src/main/org/codehaus/groovy/ast/ClassNode.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/ClassNode.java b/src/main/org/codehaus/groovy/ast/ClassNode.java
index fcf7cd6..f7ad48d 100644
--- a/src/main/org/codehaus/groovy/ast/ClassNode.java
+++ b/src/main/org/codehaus/groovy/ast/ClassNode.java
@@ -18,13 +18,13 @@
  */
 package org.codehaus.groovy.ast;
 
+import groovy.lang.groovydoc.Groovydoc;
 import groovy.lang.groovydoc.GroovydocHolder;
 import org.codehaus.groovy.GroovyBugError;
 import org.codehaus.groovy.ast.expr.BinaryExpression;
 import org.codehaus.groovy.ast.expr.Expression;
 import org.codehaus.groovy.ast.expr.FieldExpression;
 import org.codehaus.groovy.ast.expr.TupleExpression;
-import groovy.lang.groovydoc.Groovydoc;
 import org.codehaus.groovy.ast.stmt.BlockStatement;
 import org.codehaus.groovy.ast.stmt.ExpressionStatement;
 import org.codehaus.groovy.ast.stmt.Statement;
@@ -105,7 +105,7 @@ import java.util.Set;
  *
  * @see org.codehaus.groovy.ast.ClassHelper
  */
-public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder {
+public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder<ClassNode> {
 
     private static class MapOfLists {
         private Map<Object, List<MethodNode>> map;
@@ -1503,7 +1503,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder
     }
 
     @Override
-    public Object getInstance() {
+    public ClassNode getInstance() {
         return this;
     }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/e0b787dc/src/main/org/codehaus/groovy/ast/FieldNode.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/FieldNode.java b/src/main/org/codehaus/groovy/ast/FieldNode.java
index 78e3ace..d38f4f4 100644
--- a/src/main/org/codehaus/groovy/ast/FieldNode.java
+++ b/src/main/org/codehaus/groovy/ast/FieldNode.java
@@ -18,9 +18,9 @@
  */
 package org.codehaus.groovy.ast;
 
+import groovy.lang.groovydoc.Groovydoc;
 import groovy.lang.groovydoc.GroovydocHolder;
 import org.codehaus.groovy.ast.expr.Expression;
-import groovy.lang.groovydoc.Groovydoc;
 import org.objectweb.asm.Opcodes;
 
 import java.lang.reflect.Field;
@@ -30,7 +30,7 @@ import java.lang.reflect.Field;
  *
  * @author <a href="mailto:[hidden email]">James Strachan</a>
  */
-public class FieldNode extends AnnotatedNode implements Opcodes, Variable, GroovydocHolder {
+public class FieldNode extends AnnotatedNode implements Opcodes, Variable, GroovydocHolder<FieldNode> {
 
     private String name;
     private int modifiers;
@@ -199,7 +199,7 @@ public class FieldNode extends AnnotatedNode implements Opcodes, Variable, Groov
     }
 
     @Override
-    public Object getInstance() {
+    public FieldNode getInstance() {
         return this;
     }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/e0b787dc/src/main/org/codehaus/groovy/ast/MethodNode.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/MethodNode.java b/src/main/org/codehaus/groovy/ast/MethodNode.java
index db7f723..e493071 100644
--- a/src/main/org/codehaus/groovy/ast/MethodNode.java
+++ b/src/main/org/codehaus/groovy/ast/MethodNode.java
@@ -33,7 +33,7 @@ import java.util.List;
  * @author <a href="mailto:[hidden email]">James Strachan</a>
  * @author Hamlet D'Arcy
  */
-public class MethodNode extends AnnotatedNode implements Opcodes, GroovydocHolder {
+public class MethodNode extends AnnotatedNode implements Opcodes, GroovydocHolder<MethodNode> {
 
     public static final String SCRIPT_BODY_METHOD_KEY = "org.codehaus.groovy.ast.MethodNode.isScriptBody";
     private final String name;
@@ -278,7 +278,7 @@ public class MethodNode extends AnnotatedNode implements Opcodes, GroovydocHolde
     }
 
     @Override
-    public Object getInstance() {
+    public MethodNode getInstance() {
         return this;
     }
 }