groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [1/3] groovy git commit: Refine options for groovydoc
Date Tue, 13 Jun 2017 05:36:13 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X c52c1c0b0 -> 6c5258bf1


Refine options for groovydoc


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 1c5dbda362a04d1a59b3487750c43bfd6a6cf350
Parents: c52c1c0
Author: sunlan <sunlan@apache.org>
Authored: Sat Jun 10 08:27:46 2017 +0800
Committer: paulk <paulk@asert.com.au>
Committed: Tue Jun 13 15:35:08 2017 +1000

----------------------------------------------------------------------
 .../groovy/parser/antlr4/GroovydocManager.java  | 27 ++++++++++++++------
 1 file changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/1c5dbda3/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java
index 449b2e7..2fdef75 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java
@@ -42,22 +42,33 @@ import static org.codehaus.groovy.runtime.DefaultGroovyMethods.asBoolean;
 public class GroovydocManager {
     public static final String DOC_COMMENT = "_DOC_COMMENT"; // keys for meta data
     private static final String DOC_COMMENT_PREFIX = "/**";
-    private static final String EXTRACT_DOC_COMMENT = "groovy.extract.doc.comment";
     private static final String TRUE_STR = "true";
-    private static final boolean EXTRACTING_DOC_COMMENT_ENABLED;
+
+    @Deprecated
+    private static final String EXTRACT_DOC_COMMENT = "groovy.extract.doc.comment"; // it
will be removed in future releases and replaced with ATTACH_GROOVYDOC
+    private static final String ATTACH_GROOVYDOC = "groovy.attach.groovydoc";
+    private static final boolean ATTACHING_GROOVYDOC_ENABLED;
+    private static final String ATTACH_RUNTIME_GROOVYDOC = "groovy.attach.runtime.groovydoc";
+    private static final boolean ATTACHING_RUNTIME_GROOVYDOC_ENABLED;
     private static final String VALUE = "value";
     private static final String RUNTIME_GROOVYDOC_PATTERN = "(?s)/[*][*]\\s+(\\s+[*]\\s*)*@Groovydoc\\b.+?[*]/";
     private AstBuilder astBuilder;
 
     static {
-        boolean edce;
+        ATTACHING_GROOVYDOC_ENABLED = isFeatureEnabled(ATTACH_GROOVYDOC) || isFeatureEnabled(EXTRACT_DOC_COMMENT);
+        ATTACHING_RUNTIME_GROOVYDOC_ENABLED = isFeatureEnabled(ATTACH_RUNTIME_GROOVYDOC);
+    }
+
+    private static boolean isFeatureEnabled(String featureOpt) {
+        boolean result;
+
         try {
-            edce = TRUE_STR.equals(System.getProperty(EXTRACT_DOC_COMMENT));
+            result = TRUE_STR.equals(System.getProperty(featureOpt));
         } catch (Exception e) {
-            edce = false;
+            result = false;
         }
 
-        EXTRACTING_DOC_COMMENT_ENABLED = edce;
+        return result;
     }
 
     public GroovydocManager(AstBuilder astBuilder) {
@@ -86,7 +97,7 @@ public class GroovydocManager {
      * Attach doc comment to member node as meta data
      */
     private void attachDocCommentAsMetaData(ASTNode node, String docCommentNodeText) {
-        if (!EXTRACTING_DOC_COMMENT_ENABLED) {
+        if (!ATTACHING_GROOVYDOC_ENABLED) {
             return;
         }
 
@@ -101,7 +112,7 @@ public class GroovydocManager {
             return;
         }
 
-        if (!docCommentNodeText.matches(RUNTIME_GROOVYDOC_PATTERN)) {
+        if (!(ATTACHING_RUNTIME_GROOVYDOC_ENABLED || docCommentNodeText.matches(RUNTIME_GROOVYDOC_PATTERN)))
{
             return;
         }
 


Mime
View raw message