Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X ccfa2896e -> 844a147a5


Minor refactoring

(cherry picked from commit b1ff684)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 844a147a5e6b572b46c9380788192daa687dac53
Parents: ccfa289
Author: sunlan <[email protected]>
Authored: Fri Aug 25 08:05:18 2017 +0800
Committer: sunlan <[email protected]>
Committed: Fri Aug 25 08:05:53 2017 +0800

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


http://git-wip-us.apache.org/repos/asf/groovy/blob/844a147a/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 655f44a..7b7bddd 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
@@ -2383,8 +2383,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
     public ConstantExpression visitStringLiteral(StringLiteralContext ctx) {
         String text = ctx.StringLiteral().getText();
 
-        int slashyType = text.startsWith("/") ? StringUtils.SLASHY :
-                text.startsWith("$/") ? StringUtils.DOLLAR_SLASHY : 
StringUtils.NONE_SLASHY;
+        int slashyType = getSlashyType(text);
 
         if (text.startsWith("'''") || text.startsWith("\"\"\"")) {
             text = StringUtils.removeCR(text); // remove CR in the multiline 
string
@@ -2411,6 +2410,10 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
         return this.configureAST(constantExpression, ctx);
     }
 
+    private int getSlashyType(String text) {
+        return text.startsWith("/") ? StringUtils.SLASHY :
+                    text.startsWith("$/") ? StringUtils.DOLLAR_SLASHY : 
StringUtils.NONE_SLASHY;
+    }
 
     @Override
     public Pair<Token, Expression> 
visitIndexPropertyArgs(IndexPropertyArgsContext ctx) {
@@ -3224,9 +3227,7 @@ public class AstBuilder extends 
GroovyParserBaseVisitor<Object> implements Groov
         List<ConstantExpression> strings = new LinkedList<>();
 
         String begin = ctx.GStringBegin().getText();
-        final int slashyType = begin.startsWith("/")
-                ? StringUtils.SLASHY
-                : begin.startsWith("$/") ? StringUtils.DOLLAR_SLASHY : 
StringUtils.NONE_SLASHY;
+        final int slashyType = getSlashyType(begin);
 
         {
             String it = begin;

Reply via email to