Repository: groovy
Updated Branches:
  refs/heads/master 138f8a63e -> cf583ac5d


Minor refactoring


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

Branch: refs/heads/master
Commit: cf583ac5d94e80c7cdcbaff33dcc9645634d28f5
Parents: 138f8a6
Author: sunlan <[email protected]>
Authored: Fri Aug 25 07:51:27 2017 +0800
Committer: sunlan <[email protected]>
Committed: Fri Aug 25 07:51:27 2017 +0800

----------------------------------------------------------------------
 .../apache/groovy/parser/antlr4/AstBuilder.java | 31 +++++++++-----------
 1 file changed, 14 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/cf583ac5/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 09727b5..0b13c5b 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
@@ -169,7 +169,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
     }
 
     private CharStream createCharStream(SourceUnit sourceUnit) {
-        CharStream charStream = null;
+        CharStream charStream;
 
         try {
             charStream = CharStreams.fromReader(
@@ -182,7 +182,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
         return charStream;
     }
 
-    public GroovyParserRuleContext buildCST() throws 
CompilationFailedException {
+    private GroovyParserRuleContext buildCST() throws 
CompilationFailedException {
         GroovyParserRuleContext result;
 
         try {
@@ -220,7 +220,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
         return parser.compilationUnit();
     }
 
-    public CompilationFailedException convertException(Throwable t) {
+    private CompilationFailedException convertException(Throwable t) {
         CompilationFailedException cfe;
 
         if (t instanceof CompilationFailedException) {
@@ -612,7 +612,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
      * Multi-catch(1..*) clause will be unpacked to several normal catch 
clauses, so the return type is List
      *
      * @param ctx the parse tree
-     * @return
+     * @return a list of CatchStatement instances
      */
     @Override
     public List<CatchStatement> visitCatchClause(CatchClauseContext ctx) {
@@ -2575,8 +2575,8 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
             return this.configureAST(new RangeExpression(left, right, 
!ctx.rangeOp.getText().endsWith("<")), ctx);
         }
 
-        org.codehaus.groovy.syntax.Token op = null;
-        Token antlrToken = null;
+        org.codehaus.groovy.syntax.Token op;
+        Token antlrToken;
 
         if (asBoolean(ctx.dlOp)) {
             op = this.createGroovyToken(ctx.dlOp, 2);
@@ -3944,18 +3944,15 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
 
     // e.g. m(1, 2) or m 1, 2
     private MethodCallExpression createMethodCallExpression(Expression 
baseExpr, Expression arguments) {
-        MethodCallExpression methodCallExpression =
-                new MethodCallExpression(
-                        VariableExpression.THIS_EXPRESSION,
+        return new MethodCallExpression(
+                VariableExpression.THIS_EXPRESSION,
 
-                        (baseExpr instanceof VariableExpression)
-                                ? this.createConstantExpression(baseExpr)
-                                : baseExpr,
+                (baseExpr instanceof VariableExpression)
+                        ? this.createConstantExpression(baseExpr)
+                        : baseExpr,
 
-                        arguments
-                );
-
-        return methodCallExpression;
+                arguments
+        );
     }
 
     private Parameter processFormalParameter(GroovyParserRuleContext ctx,
@@ -4446,7 +4443,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
     }
 
     private class DeclarationListStatement extends Statement {
-        private List<ExpressionStatement> declarationStatements;
+        private final List<ExpressionStatement> declarationStatements;
 
         public DeclarationListStatement(DeclarationExpression... declarations) 
{
             this(Arrays.asList(declarations));

Reply via email to