Repository: groovy
Updated Branches:
  refs/heads/master 0d7b0bcc5 -> 4b09236fd


Minor refactoring


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

Branch: refs/heads/master
Commit: 4b09236fdd15c3d73fbf58b0fac8565e7b843a88
Parents: 0d7b0bc
Author: sunlan <[email protected]>
Authored: Thu Sep 7 21:16:18 2017 +0800
Committer: sunlan <[email protected]>
Committed: Thu Sep 7 21:16:18 2017 +0800

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/ast/Parameter.java         |  3 +--
 .../org/apache/groovy/parser/antlr4/AstBuilder.java     | 12 ++++++------
 2 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/4b09236f/src/main/org/codehaus/groovy/ast/Parameter.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/Parameter.java 
b/src/main/org/codehaus/groovy/ast/Parameter.java
index a49b34a..c3df7c3 100644
--- a/src/main/org/codehaus/groovy/ast/Parameter.java
+++ b/src/main/org/codehaus/groovy/ast/Parameter.java
@@ -29,8 +29,7 @@ import org.codehaus.groovy.ast.expr.*;
  */
 public class Parameter extends AnnotatedNode implements Variable {
 
-    public static final Parameter[] EMPTY_ARRAY = {
-    };
+    public static final Parameter[] EMPTY_ARRAY = {};
 
     private ClassNode type;
     private final String name;

http://git-wip-us.apache.org/repos/asf/groovy/blob/4b09236f/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 a833973..7b63bee 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
@@ -264,7 +264,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
             this.addPackageInfoClassNode();
         } else {
             // if groovy source file only contains blank(including EOF), add 
"return null" to the AST
-            if (this.isBlankScript(ctx)) {
+            if (this.isBlankScript()) {
                 this.addEmptyReturnStatement();
             }
         }
@@ -3347,7 +3347,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
     @Override
     public Parameter[] visitFormalParameters(FormalParametersContext ctx) {
         if (!asBoolean(ctx)) {
-            return new Parameter[0];
+            return Parameter.EMPTY_ARRAY;
         }
 
         return this.visitFormalParameterList(ctx.formalParameterList());
@@ -3356,7 +3356,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
     @Override
     public Parameter[] visitFormalParameterList(FormalParameterListContext 
ctx) {
         if (!asBoolean(ctx)) {
-            return new Parameter[0];
+            return Parameter.EMPTY_ARRAY;
         }
 
         List<Parameter> parameterList = new LinkedList<>();
@@ -3377,7 +3377,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
 
         validateParameterList(parameterList);
 
-        return parameterList.toArray(new Parameter[0]);
+        return parameterList.toArray(Parameter.EMPTY_ARRAY);
     }
 
     private void validateVarArgParameter(List<? extends 
FormalParameterContext> formalParameterList) {
@@ -3828,7 +3828,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
     @Override
     public ClassNode[] 
visitQualifiedClassNameList(QualifiedClassNameListContext ctx) {
         if (!asBoolean(ctx)) {
-            return new ClassNode[0];
+            return ClassNode.EMPTY_ARRAY;
         }
 
         return ctx.annotatedQualifiedClassName().stream()
@@ -4122,7 +4122,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
 
     }
 
-    private boolean isBlankScript(CompilationUnitContext ctx) {
+    private boolean isBlankScript() {
         return moduleNode.getStatementBlock().isEmpty() && 
moduleNode.getMethods().isEmpty() && moduleNode.getClasses().isEmpty();
     }
 

Reply via email to