You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/06/13 05:36:13 UTC

[1/3] groovy git commit: Refine options for groovydoc

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 <su...@apache.org>
Authored: Sat Jun 10 08:27:46 2017 +0800
Committer: paulk <pa...@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;
         }
 


[3/3] groovy git commit: Use the recommended option for groovydoc

Posted by pa...@apache.org.
Use the recommended option for groovydoc


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 6c5258bf1f94bd30738310cc69f356534dfe51be
Parents: b2bb722
Author: sunlan <su...@apache.org>
Authored: Sat Jun 10 13:08:58 2017 +0800
Committer: paulk <pa...@asert.com.au>
Committed: Tue Jun 13 15:35:52 2017 +1000

----------------------------------------------------------------------
 subprojects/groovy-console/build.gradle | 2 +-
 subprojects/parser-antlr4/README.adoc   | 3 ++-
 subprojects/parser-antlr4/build.gradle  | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/6c5258bf/subprojects/groovy-console/build.gradle
----------------------------------------------------------------------
diff --git a/subprojects/groovy-console/build.gradle b/subprojects/groovy-console/build.gradle
index e40766e..bc38c53 100644
--- a/subprojects/groovy-console/build.gradle
+++ b/subprojects/groovy-console/build.gradle
@@ -28,7 +28,7 @@ dependencies {
 
 task console(type: JavaExec, dependsOn:classes) {
     if (rootProject.hasProperty('useAntlr4')) {
-        jvmArgs += ["-Dgroovy.antlr4=true", "-Dgroovy.extract.doc.comment=true"]
+        jvmArgs += ["-Dgroovy.antlr4=true", "-Dgroovy.attach.groovydoc=true"]
     }
 
     main = 'groovy.ui.Console'

http://git-wip-us.apache.org/repos/asf/groovy/blob/6c5258bf/subprojects/parser-antlr4/README.adoc
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/README.adoc b/subprojects/parser-antlr4/README.adoc
index 4170426..50a3639 100644
--- a/subprojects/parser-antlr4/README.adoc
+++ b/subprojects/parser-antlr4/README.adoc
@@ -53,7 +53,8 @@ groovyOptions.forkOptions.jvmArgs += ["-Dgroovy.antlr4=true"]
 === JVM system properties to control parsing
 
 * `groovy.antlr4.cache.threshold`: how frequently to clear DFA cache(default: 50). **Notice:** The more frequently the DFA cache is cleared, the poorer parsing performance will be(you can not set the value that is less than the default value). But the DFA cache has to be cleared to avoid OutOfMemoryError's occurring. 
-* `groovy.extract.doc.comment`: whether to collect groovydoc while parsing groovy source code(default: false)
+* `groovy.attach.groovydoc`: whether to attach groovydoc to node as metadata while parsing groovy source code(default: false)
+* `groovy.attach.runtime.groovydoc`: whether to attach `@Groovydoc` annotation to all members which have groovydoc(i.e. `/** ... */`).
 
 *P.S. Parrot is based on the highly optimized version of antlr4(com.tunnelvisionlabs:antlr4), which is licensed under BSD.*
  
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/6c5258bf/subprojects/parser-antlr4/build.gradle
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/build.gradle b/subprojects/parser-antlr4/build.gradle
index c955408..1d52b2c 100644
--- a/subprojects/parser-antlr4/build.gradle
+++ b/subprojects/parser-antlr4/build.gradle
@@ -73,5 +73,5 @@ allprojects {
 }
 
 test {
-    jvmArgs "-Dgroovy.extract.doc.comment=true", "-Dgroovy.antlr4.cache.threshold=100"
+    jvmArgs "-Dgroovy.attach.groovydoc=true", "-Dgroovy.antlr4.cache.threshold=100"
 }
\ No newline at end of file


[2/3] groovy git commit: Minor refactoring

Posted by pa...@apache.org.
Minor refactoring


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

Branch: refs/heads/GROOVY_2_6_X
Commit: b2bb7229490a9f2031c1d221dea3585193a0162c
Parents: 1c5dbda
Author: sunlan <su...@apache.org>
Authored: Sat Jun 10 11:56:36 2017 +0800
Committer: paulk <pa...@asert.com.au>
Committed: Tue Jun 13 15:35:34 2017 +1000

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/ast/ASTNode.java   |  91 ++----------
 .../groovy/ast/NodeMetaDataHandler.java         | 137 +++++++++++++++++++
 .../apache/groovy/parser/antlr4/GroovyParser.g4 |  53 ++-----
 .../apache/groovy/parser/antlr4/AstBuilder.java |  48 +++----
 4 files changed, 175 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/b2bb7229/src/main/org/codehaus/groovy/ast/ASTNode.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/ASTNode.java b/src/main/org/codehaus/groovy/ast/ASTNode.java
index 058af78..a192e68 100644
--- a/src/main/org/codehaus/groovy/ast/ASTNode.java
+++ b/src/main/org/codehaus/groovy/ast/ASTNode.java
@@ -18,10 +18,8 @@
  */
 package org.codehaus.groovy.ast;
 
-import org.codehaus.groovy.GroovyBugError;
 import org.codehaus.groovy.util.ListHashMap;
 
-import java.util.Collections;
 import java.util.Map;
 
 /**
@@ -46,13 +44,13 @@ import java.util.Map;
  * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
  * @author <a href="mailto:blackdrag@gmx.org">Jochen "blackdrag" Theodorou</a>
  */
-public class ASTNode {
+public class ASTNode implements NodeMetaDataHandler {
 
     private int lineNumber = -1;
     private int columnNumber = -1;
     private int lastLineNumber = -1;
     private int lastColumnNumber = -1;
-    private ListHashMap metaDataMap = null;
+    private Map metaDataMap = null;
 
     public void visit(GroovyCodeVisitor visitor) {
         throw new RuntimeException("No visit() method implemented for class: " + getClass().getName());
@@ -108,93 +106,22 @@ public class ASTNode {
         this.lastColumnNumber = node.getLastColumnNumber();
         this.lineNumber = node.getLineNumber();
     }
-    
-    /**
-     * Gets the node meta data. 
-     * 
-     * @param key - the meta data key
-     * @return the node meta data value for this key
-     */
-    public <T> T getNodeMetaData(Object key) {
-        if (metaDataMap == null) {
-            return (T) null;
-        }
-        return (T) metaDataMap.get(key);
-    }
 
     /**
      * Copies all node meta data from the other node to this one
      * @param other - the other node
      */
     public void copyNodeMetaData(ASTNode other) {
-        if (other.metaDataMap == null) {
-            return;
-        }
-        if (metaDataMap == null) {
-            metaDataMap = new ListHashMap();
-        }
-        metaDataMap.putAll(other.metaDataMap);
-    }
-    
-    /**
-     * Sets the node meta data. 
-     * 
-     * @param key - the meta data key
-     * @param value - the meta data value
-     * @throws GroovyBugError if key is null or there is already meta 
-     *                        data under that key
-     */
-    public void setNodeMetaData(Object key, Object value) {
-        if (key==null) throw new GroovyBugError("Tried to set meta data with null key on "+this+".");
-        if (metaDataMap == null) {
-            metaDataMap = new ListHashMap();
-        }
-        Object old = metaDataMap.put(key,value);
-        if (old!=null) throw new GroovyBugError("Tried to overwrite existing meta data "+this+".");
+        copyNodeMetaData((NodeMetaDataHandler) other);
     }
 
-    /**
-     * Sets the node meta data but allows overwriting values.
-     *
-     * @param key   - the meta data key
-     * @param value - the meta data value
-     * @return the old node meta data value for this key
-     * @throws GroovyBugError if key is null
-     */
-    public Object putNodeMetaData(Object key, Object value) {
-        if (key == null) throw new GroovyBugError("Tried to set meta data with null key on " + this + ".");
-        if (metaDataMap == null) {
-            metaDataMap = new ListHashMap();
-        }
-        return metaDataMap.put(key, value);
-    }
-
-    /**
-     * Removes a node meta data entry.
-     * 
-     * @param key - the meta data key
-     * @throws GroovyBugError if the key is null
-     */
-    public void removeNodeMetaData(Object key) {
-        if (key==null) throw new GroovyBugError("Tried to remove meta data with null key "+this+".");
-        if (metaDataMap == null) {
-            return;
-        }
-        metaDataMap.remove(key);
-    }
-
-    /**
-     * Returns an unmodifiable view of the current node metadata.
-     * @return the node metadata. Always not null.
-     */
-    public Map<?,?> getNodeMetaData() {
-        if (metaDataMap==null) {
-            return Collections.emptyMap();
-        }
-        return Collections.unmodifiableMap(metaDataMap);
+    @Override
+    public ListHashMap getMetaDataMap() {
+        return (ListHashMap) metaDataMap;
     }
 
-    public ListHashMap getMetaDataMap() {
-        return metaDataMap;
+    @Override
+    public void setMetaDataMap(Map<?, ?> metaDataMap) {
+        this.metaDataMap = metaDataMap;
     }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/b2bb7229/src/main/org/codehaus/groovy/ast/NodeMetaDataHandler.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/NodeMetaDataHandler.java b/src/main/org/codehaus/groovy/ast/NodeMetaDataHandler.java
new file mode 100644
index 0000000..280cd6b
--- /dev/null
+++ b/src/main/org/codehaus/groovy/ast/NodeMetaDataHandler.java
@@ -0,0 +1,137 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.ast;
+
+import org.codehaus.groovy.GroovyBugError;
+import org.codehaus.groovy.util.ListHashMap;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * An interface to mark a node being able to handle metadata
+ */
+public interface NodeMetaDataHandler {
+    /**
+     * Gets the node meta data.
+     *
+     * @param key - the meta data key
+     * @return the node meta data value for this key
+     */
+    default <T> T getNodeMetaData(Object key) {
+        Map<?, ?> metaDataMap = this.getMetaDataMap();
+
+        if (metaDataMap == null) {
+            return (T) null;
+        }
+        return (T) metaDataMap.get(key);
+    }
+
+    /**
+     * Copies all node meta data from the other node to this one
+     *
+     * @param other - the other node
+     */
+    default void copyNodeMetaData(NodeMetaDataHandler other) {
+        Map otherMetaDataMap = other.getMetaDataMap();
+        if (otherMetaDataMap == null) {
+            return;
+        }
+        Map metaDataMap = this.getMetaDataMap();
+        if (metaDataMap == null) {
+            metaDataMap = new ListHashMap();
+            this.setMetaDataMap(metaDataMap);
+        }
+
+        metaDataMap.putAll(otherMetaDataMap);
+    }
+
+    /**
+     * Sets the node meta data.
+     *
+     * @param key   - the meta data key
+     * @param value - the meta data value
+     * @throws GroovyBugError if key is null or there is already meta
+     *                        data under that key
+     */
+    default void setNodeMetaData(Object key, Object value) {
+        if (key == null) throw new GroovyBugError("Tried to set meta data with null key on " + this + ".");
+
+        Map metaDataMap = this.getMetaDataMap();
+        if (metaDataMap == null) {
+            metaDataMap = new ListHashMap();
+            this.setMetaDataMap(metaDataMap);
+        }
+        Object old = metaDataMap.put(key, value);
+        if (old != null) throw new GroovyBugError("Tried to overwrite existing meta data " + this + ".");
+    }
+
+    /**
+     * Sets the node meta data but allows overwriting values.
+     *
+     * @param key   - the meta data key
+     * @param value - the meta data value
+     * @return the old node meta data value for this key
+     * @throws GroovyBugError if key is null
+     */
+    default Object putNodeMetaData(Object key, Object value) {
+        if (key == null) throw new GroovyBugError("Tried to set meta data with null key on " + this + ".");
+
+        Map metaDataMap = this.getMetaDataMap();
+        if (metaDataMap == null) {
+            metaDataMap = new ListHashMap();
+            this.setMetaDataMap(metaDataMap);
+        }
+        return metaDataMap.put(key, value);
+    }
+
+    /**
+     * Removes a node meta data entry.
+     *
+     * @param key - the meta data key
+     * @throws GroovyBugError if the key is null
+     */
+    default void removeNodeMetaData(Object key) {
+        if (key == null) throw new GroovyBugError("Tried to remove meta data with null key " + this + ".");
+
+        Map metaDataMap = this.getMetaDataMap();
+        if (metaDataMap == null) {
+            return;
+        }
+        metaDataMap.remove(key);
+    }
+
+    /**
+     * Returns an unmodifiable view of the current node metadata.
+     *
+     * @return the node metadata. Always not null.
+     */
+    default Map<?, ?> getNodeMetaData() {
+        Map metaDataMap = this.getMetaDataMap();
+
+        if (metaDataMap == null) {
+            return Collections.emptyMap();
+        }
+        return Collections.unmodifiableMap(metaDataMap);
+    }
+
+    Map<?, ?> getMetaDataMap();
+
+    void setMetaDataMap(Map<?, ?> metaDataMap);
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/b2bb7229/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4 b/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
index 3e6bc07..1fb2c97 100644
--- a/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
+++ b/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
@@ -41,14 +41,13 @@ options {
 
 @header {
     import java.util.Map;
-    import org.codehaus.groovy.util.ListHashMap;
+    import org.codehaus.groovy.ast.NodeMetaDataHandler;
     import org.apache.groovy.parser.antlr4.SemanticPredicates;
-    import org.codehaus.groovy.GroovyBugError;
 }
 
 @members {
 
-    public static class GroovyParserRuleContext extends ParserRuleContext {
+    public static class GroovyParserRuleContext extends ParserRuleContext implements NodeMetaDataHandler {
         private Map metaDataMap = null;
 
         public GroovyParserRuleContext() {}
@@ -57,50 +56,14 @@ options {
             super(parent, invokingStateNumber);
         }
 
-        /**
-         * Gets the node meta data.
-         *
-         * @param key - the meta data key
-         * @return the node meta data value for this key
-         */
-        public <T> T getNodeMetaData(Object key) {
-            if (metaDataMap == null) {
-                return (T) null;
-            }
-            return (T) metaDataMap.get(key);
+        @Override
+        public Map<?, ?> getMetaDataMap() {
+            return this.metaDataMap;
         }
 
-        /**
-         * Sets the node meta data.
-         *
-         * @param key - the meta data key
-         * @param value - the meta data value
-         * @throws GroovyBugError if key is null or there is already meta
-         *                        data under that key
-         */
-        public void setNodeMetaData(Object key, Object value) {
-            if (key==null) throw new GroovyBugError("Tried to set meta data with null key on "+this+".");
-            if (metaDataMap == null) {
-                metaDataMap = new ListHashMap();
-            }
-            Object old = metaDataMap.put(key,value);
-            if (old!=null) throw new GroovyBugError("Tried to overwrite existing meta data "+this+".");
-        }
-
-        /**
-         * Sets the node meta data but allows overwriting values.
-         *
-         * @param key   - the meta data key
-         * @param value - the meta data value
-         * @return the old node meta data value for this key
-         * @throws GroovyBugError if key is null
-         */
-        public Object putNodeMetaData(Object key, Object value) {
-            if (key == null) throw new GroovyBugError("Tried to set meta data with null key on " + this + ".");
-            if (metaDataMap == null) {
-                metaDataMap = new ListHashMap();
-            }
-            return metaDataMap.put(key, value);
+        @Override
+        public void setMetaDataMap(Map<?, ?> metaDataMap) {
+            this.metaDataMap = metaDataMap;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/b2bb7229/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index add3e6d..c8d8eae 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -48,6 +48,7 @@ import org.codehaus.groovy.ast.ImportNode;
 import org.codehaus.groovy.ast.InnerClassNode;
 import org.codehaus.groovy.ast.MethodNode;
 import org.codehaus.groovy.ast.ModuleNode;
+import org.codehaus.groovy.ast.NodeMetaDataHandler;
 import org.codehaus.groovy.ast.PackageNode;
 import org.codehaus.groovy.ast.Parameter;
 import org.codehaus.groovy.ast.PropertyNode;
@@ -1749,7 +1750,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
                                     (PropertyExpression) baseExpr, arguments),
                             arguments);
 
-        } else if (baseExpr instanceof MethodCallExpression && !isTrue(baseExpr, IS_INSIDE_PARENTHESES)) { // e.g. m {} a, b  OR  m(...) a, b
+        } else if (baseExpr instanceof MethodCallExpression && !isInsideParentheses(baseExpr)) { // e.g. m {} a, b  OR  m(...) a, b
             if (asBoolean(arguments)) {
                 // The error should never be thrown.
                 throw new GroovyBugError("When baseExpr is a instance of MethodCallExpression, which should follow NO argumentList");
@@ -1757,7 +1758,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
 
             methodCallExpression = (MethodCallExpression) baseExpr;
         } else if (
-                !isTrue(baseExpr, IS_INSIDE_PARENTHESES)
+                !isInsideParentheses(baseExpr)
                         && (baseExpr instanceof VariableExpression /* e.g. m 1, 2 */
                         || baseExpr instanceof GStringExpression /* e.g. "$m" 1, 2 */
                         || (baseExpr instanceof ConstantExpression && isTrue(baseExpr, IS_STRING)) /* e.g. "m" 1, 2 */)
@@ -1852,8 +1853,6 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
     public Expression visitParExpression(ParExpressionContext ctx) {
         Expression expression = this.visitExpressionInPar(ctx.expressionInPar());
 
-        expression.putNodeMetaData(IS_INSIDE_PARENTHESES, true);
-
         Integer insideParenLevel = expression.getNodeMetaData(INSIDE_PARENTHESES_LEVEL);
         if (asBoolean((Object) insideParenLevel)) {
             insideParenLevel++;
@@ -1984,7 +1983,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
             Expression argumentsExpr = this.visitArguments(ctx.arguments());
             this.configureAST(argumentsExpr, ctx);
 
-            if (isTrue(baseExpr, IS_INSIDE_PARENTHESES)) { // e.g. (obj.x)(), (obj.@x)()
+            if (isInsideParentheses(baseExpr)) { // e.g. (obj.x)(), (obj.@x)()
                 MethodCallExpression methodCallExpression =
                         new MethodCallExpression(
                                 baseExpr,
@@ -2437,7 +2436,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
         ExpressionContext expressionCtx = ctx.expression();
         Expression expression = (Expression) this.visit(expressionCtx);
 
-        Boolean insidePar = isTrue(expression, IS_INSIDE_PARENTHESES);
+        Boolean insidePar = isInsideParentheses(expression);
 
         switch (ctx.op.getType()) {
             case ADD: {
@@ -2629,7 +2628,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
         Expression leftExpr = (Expression) this.visit(ctx.left);
 
         if (leftExpr instanceof VariableExpression
-                && isTrue(leftExpr, IS_INSIDE_PARENTHESES)) { // it is a special multiple assignment whose variable count is only one, e.g. (a) = [1]
+                && isInsideParentheses(leftExpr)) { // it is a special multiple assignment whose variable count is only one, e.g. (a) = [1]
 
             if ((Integer) leftExpr.getNodeMetaData(INSIDE_PARENTHESES_LEVEL) > 1) {
                 throw createParsingFailedException("Nested parenthesis is not allowed in multiple assignment, e.g. ((a)) = b", ctx);
@@ -2648,7 +2647,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
                 !(
                         (leftExpr instanceof VariableExpression
 //                                && !(THIS_STR.equals(leftExpr.getText()) || SUPER_STR.equals(leftExpr.getText()))     // commented, e.g. this = value // this will be transformed to $this
-                                && !isTrue(leftExpr, IS_INSIDE_PARENTHESES)) // e.g. p = 123
+                                && !isInsideParentheses(leftExpr)) // e.g. p = 123
 
                                 || leftExpr instanceof PropertyExpression // e.g. obj.p = 123
 
@@ -2929,7 +2928,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
             Expression expression = (Expression) this.visit(ctx.primary());
 
             // if the key is variable and not inside parentheses, convert it to a constant, e.g. [a:1, b:2]
-            if (expression instanceof VariableExpression && !isTrue(expression, IS_INSIDE_PARENTHESES)) {
+            if (expression instanceof VariableExpression && !isInsideParentheses(expression)) {
                 expression =
                         this.configureAST(
                                 new ConstantExpression(((VariableExpression) expression).getName()),
@@ -4019,6 +4018,16 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
         return moduleNode.getStatementBlock().isEmpty() && moduleNode.getMethods().isEmpty() && moduleNode.getClasses().isEmpty();
     }
 
+    private boolean isInsideParentheses(NodeMetaDataHandler nodeMetaDataHandler) {
+        Integer insideParenLevel = nodeMetaDataHandler.getNodeMetaData(INSIDE_PARENTHESES_LEVEL);
+
+        if (asBoolean((Object) insideParenLevel)) {
+            return insideParenLevel > 0;
+        }
+
+        return false;
+    }
+
     private void addEmptyReturnStatement() {
         moduleNode.addStatement(ReturnStatement.RETURN_NULL_OR_VOID);
     }
@@ -4182,29 +4191,15 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
         return astNode;
     }
 
-    private boolean isTrue(GroovyParserRuleContext ctx, String key) {
-        Object nmd = ctx.getNodeMetaData(key);
-
-        if (null == nmd) {
-            return false;
-        }
-
-        if (!(nmd instanceof Boolean)) {
-            throw new GroovyBugError(ctx + " ctx meta data[" + key + "] is not an instance of Boolean");
-        }
-
-        return (Boolean) nmd;
-    }
-
-    private boolean isTrue(ASTNode node, String key) {
-        Object nmd = node.getNodeMetaData(key);
+    private boolean isTrue(NodeMetaDataHandler nodeMetaDataHandler, String key) {
+        Object nmd = nodeMetaDataHandler.getNodeMetaData(key);
 
         if (null == nmd) {
             return false;
         }
 
         if (!(nmd instanceof Boolean)) {
-            throw new GroovyBugError(node + " node meta data[" + key + "] is not an instance of Boolean");
+            throw new GroovyBugError(nodeMetaDataHandler + " node meta data[" + key + "] is not an instance of Boolean");
         }
 
         return (Boolean) nmd;
@@ -4434,7 +4429,6 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
     private static final Set<String> PRIMITIVE_TYPE_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("boolean", "char", "byte", "short", "int", "long", "float", "double")));
     private static final Logger LOGGER = Logger.getLogger(AstBuilder.class.getName());
 
-    private static final String IS_INSIDE_PARENTHESES = "_IS_INSIDE_PARENTHESES";
     private static final String INSIDE_PARENTHESES_LEVEL = "_INSIDE_PARENTHESES_LEVEL";
 
     private static final String IS_INSIDE_INSTANCEOF_EXPR = "_IS_INSIDE_INSTANCEOF_EXPR";