Repository: groovy
Updated Branches:
  refs/heads/master 75a16a0ab -> 5096e0cb8


Minor refactoring: remove duplicated code of `visitListOfExpressions`


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

Branch: refs/heads/master
Commit: 5096e0cb8a6a9402bd9139991cddc4d00d681943
Parents: 75a16a0
Author: danielsun1106 <realblue...@hotmail.com>
Authored: Mon Feb 19 23:49:07 2018 +0800
Committer: danielsun1106 <realblue...@hotmail.com>
Committed: Mon Feb 19 23:49:07 2018 +0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/ast/CodeVisitorSupport.java  | 15 ---------------
 .../org/codehaus/groovy/ast/GroovyCodeVisitor.java   | 15 +++++++++++++++
 .../control/customizers/SecureASTCustomizer.java     | 12 ------------
 .../inspect/swingui/ScriptToTreeNodeAdapter.groovy   |  2 +-
 .../codehaus/groovy/macro/matcher/ASTMatcher.groovy  |  2 +-
 5 files changed, 17 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/5096e0cb/src/main/java/org/codehaus/groovy/ast/CodeVisitorSupport.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/ast/CodeVisitorSupport.java 
b/src/main/java/org/codehaus/groovy/ast/CodeVisitorSupport.java
index 523475e..51ef06e 100644
--- a/src/main/java/org/codehaus/groovy/ast/CodeVisitorSupport.java
+++ b/src/main/java/org/codehaus/groovy/ast/CodeVisitorSupport.java
@@ -32,7 +32,6 @@ import org.codehaus.groovy.ast.expr.ConstantExpression;
 import org.codehaus.groovy.ast.expr.ConstructorCallExpression;
 import org.codehaus.groovy.ast.expr.DeclarationExpression;
 import org.codehaus.groovy.ast.expr.ElvisOperatorExpression;
-import org.codehaus.groovy.ast.expr.Expression;
 import org.codehaus.groovy.ast.expr.FieldExpression;
 import org.codehaus.groovy.ast.expr.GStringExpression;
 import org.codehaus.groovy.ast.expr.ListExpression;
@@ -73,8 +72,6 @@ import org.codehaus.groovy.ast.stmt.TryCatchStatement;
 import org.codehaus.groovy.ast.stmt.WhileStatement;
 import org.codehaus.groovy.classgen.BytecodeExpression;
 
-import java.util.List;
-
 /**
  * Abstract base class for any GroovyCodeVisitor which by default
  * just walks the code and expression tree
@@ -316,18 +313,6 @@ public abstract class CodeVisitorSupport implements 
GroovyCodeVisitor {
         visitListOfExpressions(expression.getValues());
     }
 
-    protected void visitListOfExpressions(List<? extends Expression> list) {
-        if (list == null) return;
-        for (Expression expression : list) {
-            if (expression instanceof SpreadExpression) {
-                Expression spread = ((SpreadExpression) 
expression).getExpression();
-                spread.visit(this);
-            } else {
-                expression.visit(this);
-            }
-        }
-    }
-
     public void visitCatchStatement(CatchStatement statement) {
         statement.getCode().visit(this);
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/5096e0cb/src/main/java/org/codehaus/groovy/ast/GroovyCodeVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/ast/GroovyCodeVisitor.java 
b/src/main/java/org/codehaus/groovy/ast/GroovyCodeVisitor.java
index db793cc..70f0e78 100644
--- a/src/main/java/org/codehaus/groovy/ast/GroovyCodeVisitor.java
+++ b/src/main/java/org/codehaus/groovy/ast/GroovyCodeVisitor.java
@@ -32,6 +32,7 @@ import org.codehaus.groovy.ast.expr.ConstantExpression;
 import org.codehaus.groovy.ast.expr.ConstructorCallExpression;
 import org.codehaus.groovy.ast.expr.DeclarationExpression;
 import org.codehaus.groovy.ast.expr.ElvisOperatorExpression;
+import org.codehaus.groovy.ast.expr.Expression;
 import org.codehaus.groovy.ast.expr.FieldExpression;
 import org.codehaus.groovy.ast.expr.GStringExpression;
 import org.codehaus.groovy.ast.expr.LambdaExpression;
@@ -71,6 +72,8 @@ import org.codehaus.groovy.ast.stmt.TryCatchStatement;
 import org.codehaus.groovy.ast.stmt.WhileStatement;
 import org.codehaus.groovy.classgen.BytecodeExpression;
 
+import java.util.List;
+
 /**
  * An implementation of the visitor pattern for working with ASTNodes
  *
@@ -192,5 +195,17 @@ public interface GroovyCodeVisitor {
     void visitClosureListExpression(ClosureListExpression 
closureListExpression);
 
     void visitBytecodeExpression(BytecodeExpression expression);
+
+    default void visitListOfExpressions(List<? extends Expression> list) {
+        if (list == null) return;
+        for (Expression expression : list) {
+            if (expression instanceof SpreadExpression) {
+                Expression spread = ((SpreadExpression) 
expression).getExpression();
+                spread.visit(this);
+            } else {
+                expression.visit(this);
+            }
+        }
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/5096e0cb/src/main/java/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
 
b/src/main/java/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
index 1bb302b..9245ae5 100644
--- 
a/src/main/java/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
+++ 
b/src/main/java/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
@@ -1095,18 +1095,6 @@ public class SecureASTCustomizer extends 
CompilationCustomizer {
             visitBinaryExpression(expression);
         }
 
-        protected void visitListOfExpressions(List<? extends Expression> list) 
{
-            if (list == null) return;
-            for (Expression expression : list) {
-                if (expression instanceof SpreadExpression) {
-                    Expression spread = ((SpreadExpression) 
expression).getExpression();
-                    spread.visit(this);
-                } else {
-                    expression.visit(this);
-                }
-            }
-        }
-
         public void visitGStringExpression(final GStringExpression expression) 
{
             assertExpressionAuthorized(expression);
             visitListOfExpressions(expression.getStrings());

http://git-wip-us.apache.org/repos/asf/groovy/blob/5096e0cb/subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/ScriptToTreeNodeAdapter.groovy
----------------------------------------------------------------------
diff --git 
a/subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/ScriptToTreeNodeAdapter.groovy
 
b/subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/ScriptToTreeNodeAdapter.groovy
index 6a0d84d..9e40f19 100644
--- 
a/subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/ScriptToTreeNodeAdapter.groovy
+++ 
b/subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/ScriptToTreeNodeAdapter.groovy
@@ -788,7 +788,7 @@ class TreeNodeBuildingVisitor extends CodeVisitorSupport {
     }
 
     @Override
-    protected void visitListOfExpressions(List<? extends Expression> list) {
+    void visitListOfExpressions(List<? extends Expression> list) {
         list.each { Expression node ->
             if (node instanceof NamedArgumentListExpression ) {
                 addNode(node, NamedArgumentListExpression, { it.visit(this) })

http://git-wip-us.apache.org/repos/asf/groovy/blob/5096e0cb/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/ASTMatcher.groovy
----------------------------------------------------------------------
diff --git 
a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/ASTMatcher.groovy
 
b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/ASTMatcher.groovy
index d2164e8..ac312ab 100644
--- 
a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/ASTMatcher.groovy
+++ 
b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/ASTMatcher.groovy
@@ -940,7 +940,7 @@ class ASTMatcher extends ContextualClassCodeVisitor {
     }
 
     @Override
-    protected void visitListOfExpressions(final List<? extends Expression> 
list) {
+    void visitListOfExpressions(final List<? extends Expression> list) {
         if (list == null) return;
         def currentExprs = (List<Expression>) current
         if (currentExprs.size() != list.size()) {

Reply via email to