groovy git commit: Add `getGroovydoc` DGMs

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

groovy git commit: Add `getGroovydoc` DGMs

Daniel.Sun
Repository: groovy
Updated Branches:
  refs/heads/master b364be085 -> ec49133c5


Add `getGroovydoc` DGMs


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

Branch: refs/heads/master
Commit: ec49133c5ebdcd3236fccd59718c919f5d840f7f
Parents: b364be0
Author: sunlan <[hidden email]>
Authored: Sun Sep 10 14:02:06 2017 +0800
Committer: sunlan <[hidden email]>
Committed: Sun Sep 10 14:02:06 2017 +0800

----------------------------------------------------------------------
 .../groovy/runtime/DefaultGroovyMethods.java    | 138 ++++++++++++++++++-
 .../test/resources/core/Groovydoc_01x.groovy    |  12 +-
 2 files changed, 139 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/ec49133c/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index dd0ae2c..9f99021 100644
--- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -20,7 +20,31 @@ package org.codehaus.groovy.runtime;
 
 import groovy.io.FileType;
 import groovy.io.GroovyPrintWriter;
-import groovy.lang.*;
+import groovy.lang.Closure;
+import groovy.lang.DelegatesTo;
+import groovy.lang.DelegatingMetaClass;
+import groovy.lang.EmptyRange;
+import groovy.lang.ExpandoMetaClass;
+import groovy.lang.GString;
+import groovy.lang.GroovyObject;
+import groovy.lang.GroovyRuntimeException;
+import groovy.lang.GroovySystem;
+import groovy.lang.Groovydoc;
+import groovy.lang.IntRange;
+import groovy.lang.ListWithDefault;
+import groovy.lang.MapWithDefault;
+import groovy.lang.MetaClass;
+import groovy.lang.MetaClassImpl;
+import groovy.lang.MetaClassRegistry;
+import groovy.lang.MetaMethod;
+import groovy.lang.MetaProperty;
+import groovy.lang.MissingPropertyException;
+import groovy.lang.ObjectRange;
+import groovy.lang.PropertyValue;
+import groovy.lang.Range;
+import groovy.lang.SpreadMap;
+import groovy.lang.Tuple2;
+import groovy.lang.Writable;
 import groovy.transform.stc.ClosureParams;
 import groovy.transform.stc.FirstParam;
 import groovy.transform.stc.FromString;
@@ -44,7 +68,24 @@ import org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv;
 import org.codehaus.groovy.runtime.dgmimpl.NumberNumberMinus;
 import org.codehaus.groovy.runtime.dgmimpl.NumberNumberMultiply;
 import org.codehaus.groovy.runtime.dgmimpl.NumberNumberPlus;
-import org.codehaus.groovy.runtime.dgmimpl.arrays.*;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayGetAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayPutAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayGetAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayPutAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayGetAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayPutAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayGetAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayPutAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayGetAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayPutAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayGetAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayPutAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayGetAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayPutAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayPutAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayGetAtMetaMethod;
+import org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayPutAtMetaMethod;
 import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl;
 import org.codehaus.groovy.runtime.metaclass.MissingPropertyExceptionNoStack;
 import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
@@ -53,11 +94,31 @@ import org.codehaus.groovy.runtime.typehandling.NumberMath;
 import org.codehaus.groovy.tools.RootLoader;
 import org.codehaus.groovy.transform.trait.Traits;
 import org.codehaus.groovy.util.ArrayIterator;
-import org.codehaus.groovy.util.ListBufferedIterator;
 import org.codehaus.groovy.util.IteratorBufferedIterator;
+import org.codehaus.groovy.util.ListBufferedIterator;
 
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
 import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -74,7 +135,33 @@ import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.text.MessageFormat;
-import java.util.*;
+import java.util.AbstractCollection;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Queue;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.Stack;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.TreeMap;
+import java.util.TreeSet;
 import java.util.concurrent.BlockingQueue;
 import java.util.logging.Logger;
 import java.util.regex.Matcher;
@@ -18796,4 +18883,45 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
     public static <E> boolean removeElement(Collection<E> self, Object o) {
         return self.remove(o);
     }
+
+
+    /**
+     * Get runtime groovydoc
+     * @param holder the groovydoc hold
+     * @return runtime groovydoc
+     * @since 2.6.0
+     */
+    public static String getGroovydoc(Class<?> holder) {
+        return holder.<Groovydoc>getAnnotation(Groovydoc.class).value();
+    }
+
+    /**
+     * Get runtime groovydoc
+     * @param holder the groovydoc hold
+     * @return runtime groovydoc
+     * @since 2.6.0
+     */
+    public static String getGroovydoc(Method holder) {
+        return holder.<Groovydoc>getAnnotation(Groovydoc.class).value();
+    }
+
+    /**
+     * Get runtime groovydoc
+     * @param holder the groovydoc hold
+     * @return runtime groovydoc
+     * @since 2.6.0
+     */
+    public static String getGroovydoc(Constructor holder) {
+        return ((Groovydoc) holder.<Groovydoc>getAnnotation(Groovydoc.class)).value();
+    }
+
+    /**
+     * Get runtime groovydoc
+     * @param holder the groovydoc hold
+     * @return runtime groovydoc
+     * @since 2.6.0
+     */
+    public static String getGroovydoc(Field holder) {
+        return holder.<Groovydoc>getAnnotation(Groovydoc.class).value();
+    }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/ec49133c/subprojects/parser-antlr4/src/test/resources/core/Groovydoc_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Groovydoc_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Groovydoc_01x.groovy
index 9bbf9f5..5ab86a8 100644
--- a/subprojects/parser-antlr4/src/test/resources/core/Groovydoc_01x.groovy
+++ b/subprojects/parser-antlr4/src/test/resources/core/Groovydoc_01x.groovy
@@ -62,9 +62,9 @@ class AA {
 
 }
 
-assert AA.class.getAnnotation(groovy.lang.Groovydoc).value().contains('class AA')
-assert AA.class.getMethod('m', new Class[0]).getAnnotation(groovy.lang.Groovydoc).value().contains('method m')
-assert AA.class.getConstructor().getAnnotation(groovy.lang.Groovydoc).value().contains('constructor AA')
-assert AA.class.getField('SOME_FIELD').getAnnotation(groovy.lang.Groovydoc).value().contains('field SOME_FIELD')
-assert AA.class.getDeclaredClasses().find {it.simpleName.contains('InnerClass')}.getAnnotation(groovy.lang.Groovydoc).value().contains('class InnerClass')
-assert BB.class.getAnnotation(groovy.lang.Groovydoc).value().contains('annotation BB')
\ No newline at end of file
+assert AA.class.groovydoc.contains('class AA')
+assert AA.class.getMethod('m', new Class[0]).groovydoc.contains('method m')
+assert AA.class.getConstructor().groovydoc.contains('constructor AA')
+assert AA.class.getField('SOME_FIELD').groovydoc.contains('field SOME_FIELD')
+assert AA.class.getDeclaredClasses().find {it.simpleName.contains('InnerClass')}.groovydoc.contains('class InnerClass')
+assert BB.class.groovydoc.contains('annotation BB')