Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X ce47ad1ea -> 4f2cba1bc


Refine antlr4 parser plugin

(cherry picked from commit 75c8b22)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 4f2cba1bc6935883a14cee789b9e20db5f5f489e
Parents: ce47ad1
Author: sunlan <sun...@apache.org>
Authored: Tue Aug 8 01:14:54 2017 +0800
Committer: sunlan <sun...@apache.org>
Committed: Tue Aug 8 01:16:11 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/4f2cba1b/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);
         }

Reply via email to