Repository: groovy Updated Branches: refs/heads/master 96279141f -> 004be8226
Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/004be822 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/004be822 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/004be822 Branch: refs/heads/master Commit: 004be8226c66ac6c2dbc213da56acd500f6f9b4b Parents: 9627914 Author: sunlan <sun...@apache.org> Authored: Sat Sep 2 06:49:48 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 2 06:49:48 2017 +0800 ---------------------------------------------------------------------- .../java/org/apache/groovy/parser/antlr4/AstBuilder.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/004be822/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 fc6d92d..7f0e391 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 @@ -175,8 +175,6 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov charStream = CharStreams.fromReader( new BufferedReader(sourceUnit.getSource().getReader()), sourceUnit.getName()); - - // charStream = new ANTLRInputStream(new BufferedReader(sourceUnit.getSource().getReader())); } catch (IOException e) { throw new RuntimeException("Error occurred when reading source code.", e); } @@ -2320,19 +2318,19 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov throw createParsingFailedException("Unsupported enhanced argument list element: " + ctx.getText(), ctx); } - @Override public ConstantExpression visitStringLiteral(StringLiteralContext ctx) { String text = ctx.StringLiteral().getText(); int slashyType = getSlashyType(text); + boolean startsWithSlash = false; if (text.startsWith("'''") || text.startsWith("\"\"\"")) { text = StringUtils.removeCR(text); // remove CR in the multiline string text = StringUtils.trimQuotations(text, 3); - } else if (text.startsWith("'") || text.startsWith("/") || text.startsWith("\"")) { - if (text.startsWith("/")) { // the slashy string can span rows, so we have to remove CR for it + } else if (text.startsWith("'") || text.startsWith("\"") || (startsWithSlash = text.startsWith("/"))) { + if (startsWithSlash) { // the slashy string can span rows, so we have to remove CR for it text = StringUtils.removeCR(text); // remove CR in the multiline string }