You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2019/11/06 01:20:53 UTC

[groovy] branch master updated: ClosureUtils#hasImplicitParameter(ClosureExpression) can test for "it"

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new d91f527  ClosureUtils#hasImplicitParameter(ClosureExpression) can test for "it"
d91f527 is described below

commit d91f5275a34b52b71594860d23cda2526f9418d9
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Tue Nov 5 19:20:36 2019 -0600

    ClosureUtils#hasImplicitParameter(ClosureExpression) can test for "it"
---
 .../org/codehaus/groovy/ast/expr/ClosureExpression.java | 17 +++++------------
 .../org/codehaus/groovy/ast/tools/ClosureUtils.java     |  3 +--
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java
index 7df3fd1..ccdceed 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java
@@ -31,17 +31,17 @@ import org.codehaus.groovy.runtime.InvokerHelper;
  * or { i {@code ->} statement } or { i, x, String y {@code ->}  statement }
  */
 public class ClosureExpression extends Expression {
-    
+
     private final Parameter[] parameters;
     private Statement code;
     private VariableScope variableScope;
-    
+
     public ClosureExpression(Parameter[] parameters, Statement code) {
         this.parameters = parameters;
         this.code = code;
         super.setType(ClassHelper.CLOSURE_TYPE.getPlainNodeReference());
     }
-    
+
     public void visit(GroovyCodeVisitor visitor) {
         visitor.visitClosureExpression(this);
     }
@@ -49,7 +49,7 @@ public class ClosureExpression extends Expression {
     public Expression transformExpression(ExpressionTransformer transformer) {
         return this;
     }
-    
+
     public String toString() {
         return super.toString() + InvokerHelper.toString(parameters) + "{ " + code + " }";
     }
@@ -82,19 +82,12 @@ public class ClosureExpression extends Expression {
     }
 
     /**
-     * @return {@code true} if implicit {@code it} is supplied
-     */
-    public boolean hasItParameter() {
-        return null != parameters && 0 == parameters.length;
-    }
-
-    /**
      * @return {@code true} if one or more explicit parameters are supplied
      */
     public boolean isParameterSpecified() {
         return parameters != null && parameters.length > 0;
     }
-    
+
     public VariableScope getVariableScope() {
         return variableScope;
     }
diff --git a/src/main/java/org/codehaus/groovy/ast/tools/ClosureUtils.java b/src/main/java/org/codehaus/groovy/ast/tools/ClosureUtils.java
index da07990..761e8eb 100644
--- a/src/main/java/org/codehaus/groovy/ast/tools/ClosureUtils.java
+++ b/src/main/java/org/codehaus/groovy/ast/tools/ClosureUtils.java
@@ -22,10 +22,10 @@ import groovy.lang.Closure;
 import org.codehaus.groovy.ast.Parameter;
 import org.codehaus.groovy.ast.expr.ClosureExpression;
 import org.codehaus.groovy.control.io.ReaderSource;
+
 /**
  * Handy methods when working with Closure AST data structures.
  */
-
 public class ClosureUtils {
 
     /**
@@ -80,5 +80,4 @@ public class ClosureUtils {
     public static Parameter[] getParametersSafe(ClosureExpression ce) {
         return ce.getParameters() != null ? ce.getParameters() : Parameter.EMPTY_ARRAY;
     }
-
 }