Repository: groovy Updated Branches: refs/heads/master 7b573c0d2 -> 75c8b2214
Refine antlr4 parser plugin Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/75c8b221 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/75c8b221 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/75c8b221 Branch: refs/heads/master Commit: 75c8b2214c9139472e9d2d0399cbe014ee9d81c9 Parents: 7b573c0 Author: sunlan <sun...@apache.org> Authored: Tue Aug 8 01:14:54 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Tue Aug 8 01:14:54 2017 +0800 ---------------------------------------------------------------------- .../org/apache/groovy/parser/antlr4/Antlr4ParserPlugin.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/75c8b221/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Antlr4ParserPlugin.java ---------------------------------------------------------------------- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Antlr4ParserPlugin.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Antlr4ParserPlugin.java index 0b4728f..2a445d0 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Antlr4ParserPlugin.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Antlr4ParserPlugin.java @@ -43,7 +43,12 @@ public class Antlr4ParserPlugin implements ParserPlugin { @Override public Reduction parseCST(SourceUnit sourceUnit, java.io.Reader reader) throws CompilationFailedException { try { - this.readerSource = new StringReaderSource(IOGroovyMethods.getText(reader), sourceUnit.getConfiguration()); + ReaderSource readerSource = sourceUnit.getSource(); + if (null != readerSource && null != readerSource.getReader()) { + this.readerSource = readerSource; + } else { + this.readerSource = new StringReaderSource(IOGroovyMethods.getText(reader), sourceUnit.getConfiguration()); + } } catch (IOException e) { throw new GroovyBugError("Failed to create StringReaderSource instance", e); }