groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Minor refactoring
Date Sat, 09 Sep 2017 04:44:53 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 7dd30235d -> 21971d236


Minor refactoring

(cherry picked from commit a23c809)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 21971d236e086be7093a26d301d24757807dfdb8
Parents: 7dd3023
Author: sunlan <sunlan@apache.org>
Authored: Sat Sep 9 12:43:27 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Sat Sep 9 12:44:35 2017 +0800

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


http://git-wip-us.apache.org/repos/asf/groovy/blob/21971d23/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 1ba83fc..76671f6 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
@@ -4290,9 +4290,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
         astNode.setLineNumber(start.getLine());
         astNode.setColumnNumber(start.getCharPositionInLine() + 1);
 
-        Pair<Integer, Integer> stopTokenEndPosition = endPosition(stop);
-        astNode.setLastLineNumber(stopTokenEndPosition.getKey());
-        astNode.setLastColumnNumber(stopTokenEndPosition.getValue());
+        configureEndPosition(astNode, stop);
 
         return astNode;
     }
@@ -4345,14 +4343,18 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
             astNode.setLastLineNumber(stop.getLastLineNumber());
             astNode.setLastColumnNumber(stop.getLastColumnNumber());
         } else {
-            Pair<Integer, Integer> endPosition = endPosition(start);
-            astNode.setLastLineNumber(endPosition.getKey());
-            astNode.setLastColumnNumber(endPosition.getValue());
+            configureEndPosition(astNode, start);
         }
 
         return astNode;
     }
 
+    private <T extends ASTNode> void configureEndPosition(T astNode, Token token) {
+        Pair<Integer, Integer> endPosition = endPosition(token);
+        astNode.setLastLineNumber(endPosition.getKey());
+        astNode.setLastColumnNumber(endPosition.getValue());
+    }
+
     private <T extends ASTNode> T configureAST(T astNode, ASTNode start, ASTNode stop)
{
         astNode.setLineNumber(start.getLineNumber());
         astNode.setColumnNumber(start.getColumnNumber());


Mime
View raw message