Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X ec6ddee5e -> e4babf9d2
Minor refactoring (cherry picked from commit 5f8d99b) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e4babf9d Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e4babf9d Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e4babf9d Branch: refs/heads/GROOVY_2_6_X Commit: e4babf9d2698fcd37417f065ffecadc0652abed9 Parents: ec6ddee Author: sunlan <[email protected]> Authored: Tue Aug 8 23:23:04 2017 +0800 Committer: sunlan <[email protected]> Committed: Tue Aug 8 23:25:32 2017 +0800 ---------------------------------------------------------------------- .../groovy/control/CompilerConfiguration.java | 26 +++++++------------- 1 file changed, 9 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/e4babf9d/src/main/org/codehaus/groovy/control/CompilerConfiguration.java ---------------------------------------------------------------------- diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java index d367625..de12206 100644 --- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java +++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java @@ -197,7 +197,7 @@ public class CompilerConfiguration { * defines if antlr2 parser should be used or the antlr4 one if * no factory is set yet */ - private boolean antlr2Parser = true; // TODO replace it with ParserVersion + private ParserVersion parserVersion = ParserVersion.V_2; /** * Sets the Flags to defaults. @@ -253,7 +253,9 @@ public class CompilerConfiguration { setOptimizationOptions(options); try { - antlr2Parser = !"true".equals(System.getProperty("groovy.antlr4")); + if ("true".equals(System.getProperty("groovy.antlr4"))) { + this.parserVersion = ParserVersion.V_4; + } } catch (Exception e) { // IGNORE } @@ -730,11 +732,9 @@ public class CompilerConfiguration { public ParserPluginFactory getPluginFactory() { if (pluginFactory == null) { - if (antlr2Parser) { - pluginFactory = ParserPluginFactory.antlr2(); - } else { - pluginFactory = ParserPluginFactory.antlr4(); - } + pluginFactory = ParserVersion.V_2 == parserVersion + ? ParserPluginFactory.antlr2() + : ParserPluginFactory.antlr4(); } return pluginFactory; } @@ -905,18 +905,10 @@ public class CompilerConfiguration { } public ParserVersion getParserVersion() { - if (this.antlr2Parser) { - return ParserVersion.V_2; - } - - return ParserVersion.V_4; + return this.parserVersion; } public void setParserVersion(ParserVersion parserVersion) { - if (ParserVersion.V_2 == parserVersion) { - this.antlr2Parser = true; - } else { - this.antlr2Parser = false; - } + this.parserVersion = parserVersion; } }
