Repository: groovy Updated Branches: refs/heads/master 341b53d58 -> b1ff68490
Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/b1ff6849 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/b1ff6849 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/b1ff6849 Branch: refs/heads/master Commit: b1ff68490aa1eed9927ad7cc44b2c8e7229e5cf5 Parents: 341b53d Author: sunlan <[email protected]> Authored: Fri Aug 25 08:05:18 2017 +0800 Committer: sunlan <[email protected]> Committed: Fri Aug 25 08:05:18 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/b1ff6849/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 f42cdf5..aee8194 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 @@ -2355,8 +2355,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 @@ -2383,6 +2382,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) { @@ -3182,9 +3185,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;
