You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/08/20 16:58:16 UTC

groovy git commit: Use the recommended API

Repository: groovy
Updated Branches:
  refs/heads/master ab910f018 -> 6c2eb7799


Use the recommended API


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

Branch: refs/heads/master
Commit: 6c2eb7799bc9c54d114b20546f028741c3ae0c82
Parents: ab910f0
Author: sunlan <su...@apache.org>
Authored: Mon Aug 21 00:57:58 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Mon Aug 21 00:57:58 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/6c2eb779/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 05d123f..449bef1 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
@@ -20,8 +20,8 @@ package org.apache.groovy.parser.antlr4;
 
 import groovy.lang.IntRange;
 import org.antlr.v4.runtime.ANTLRErrorListener;
-import org.antlr.v4.runtime.ANTLRInputStream;
 import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.CharStreams;
 import org.antlr.v4.runtime.CommonTokenStream;
 import org.antlr.v4.runtime.RecognitionException;
 import org.antlr.v4.runtime.Recognizer;
@@ -155,9 +155,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
         this.moduleNode = new ModuleNode(sourceUnit);
         this.classLoader = classLoader; // unused for the time being
 
-        CharStream charStream =
-                    new ANTLRInputStream(
-                            this.readSourceCode(sourceUnit));
+        CharStream charStream = CharStreams.fromString(this.readSourceCode(sourceUnit));
 
         this.lexer = new GroovyLangLexer(charStream);
         this.parser =
@@ -201,7 +199,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
         if (PredictionMode.SLL.equals(predictionMode)) {
             this.removeErrorListeners();
         } else {
-            ((CommonTokenStream) parser.getInputStream()).reset();
+            parser.getInputStream().seek(0);
             this.addErrorListeners();
         }