You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2019/09/28 21:52:07 UTC
[groovy] branch master updated: deprecate antlr2 parser factory
method and remove respective tests
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 399988b deprecate antlr2 parser factory method and remove respective tests
399988b is described below
commit 399988b210abd6bdace861d772c2d541b521dc30
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sun Sep 29 07:51:56 2019 +1000
deprecate antlr2 parser factory method and remove respective tests
---
.../groovy/control/CompilerConfiguration.java | 4 +-
.../groovy/control/ParserPluginFactory.java | 37 ++++-------------
src/test/groovy/MultiCatchTest.groovy | 13 ------
src/test/groovy/bugs/Groovy9141.groovy | 14 -------
src/test/groovy/bugs/Groovy9184.groovy | 47 ----------------------
src/test/groovy/bugs/Groovy9213.groovy | 13 ------
6 files changed, 8 insertions(+), 120 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
index 407085f..161b72b 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -394,7 +394,6 @@ public class CompilerConfiguration {
* <blockquote>
* <table summary="Groovy Compiler Configuration Properties">
* <tr><th>Property Key</th><th>Related Property Getter</th></tr>
- * <tr><td><code>groovy.antlr4</code></td><td>{@link #getPluginFactory}</td></tr>
* <tr><td><code>groovy.source.encoding</code> (defaulting to <code>file.encoding</code>)</td><td>{@link #getSourceEncoding}</td></tr>
* <tr><td><code>groovy.target.bytecode</code></td><td>{@link #getTargetBytecode}</td></tr>
* <tr><td><code>groovy.target.directory</code></td><td>{@link #getTargetDirectory}</td></tr>
@@ -892,8 +891,7 @@ public class CompilerConfiguration {
public ParserPluginFactory getPluginFactory() {
if (pluginFactory == null) {
- pluginFactory = !Boolean.parseBoolean(getSystemPropertySafe("groovy.antlr4", "true"))
- ? ParserPluginFactory.antlr2() : ParserPluginFactory.antlr4(this);
+ pluginFactory = ParserPluginFactory.antlr4(this);
}
return pluginFactory;
}
diff --git a/src/main/java/org/codehaus/groovy/control/ParserPluginFactory.java b/src/main/java/org/codehaus/groovy/control/ParserPluginFactory.java
index 0b6f143..cced8a9 100644
--- a/src/main/java/org/codehaus/groovy/control/ParserPluginFactory.java
+++ b/src/main/java/org/codehaus/groovy/control/ParserPluginFactory.java
@@ -19,15 +19,14 @@
package org.codehaus.groovy.control;
import org.apache.groovy.parser.antlr4.Antlr4PluginFactory;
-import org.codehaus.groovy.antlr.AntlrParserPluginFactory;
/**
- * A factory of parser plugin instances
- *
+ * A factory of parser plugin instances.
*/
public abstract class ParserPluginFactory {
/**
- * creates the ANTLR 4 parser
+ * Creates the ANTLR 4 parser.
+ *
* @return the factory for the parser
*/
public static ParserPluginFactory antlr4(CompilerConfiguration compilerConfiguration) {
@@ -35,35 +34,13 @@ public abstract class ParserPluginFactory {
}
/**
- * creates the ANTLR 2.7 parser
- * @return the factory for the parser
- */
- public static ParserPluginFactory antlr2() {
- return new AntlrParserPluginFactory();
- }
-
- /**
- * creates the ANTLR 2.7 parser. This method was used to switch between the pre JSR
- * parser and the new ANTLR 2.7 based parser, but even before Groovy 1.0 this
- * method was changed to always return the ANTLR 2.7 parser.
- * @param useNewParser - ignored
- * @return the ANTLR 2.7 based parser
- */
- @Deprecated
- public static ParserPluginFactory newInstance(boolean useNewParser) {
- return newInstance();
- }
-
- /**
- * creates the ANTLR 2.7 parser. This method was used to switch between the pre JSR
- * parser and the new ANTLR 2.7 based parser, but even before Groovy 1.0 this
- * method was changed to always return the ANTLR 2.7 parser.
+ * Previously, created the ANTLR 2.7 parser, now throws an exception.
*
- * @return the new parser factory.
+ * @throws UnsupportedOperationException always
*/
@Deprecated
- public static ParserPluginFactory newInstance() {
- return antlr2();
+ public static ParserPluginFactory antlr2() {
+ throw new UnsupportedOperationException("The Antlr2-based parser is no longer supported");
}
public abstract ParserPlugin createParserPlugin();
diff --git a/src/test/groovy/MultiCatchTest.groovy b/src/test/groovy/MultiCatchTest.groovy
index 7c17550..0f16b4e 100644
--- a/src/test/groovy/MultiCatchTest.groovy
+++ b/src/test/groovy/MultiCatchTest.groovy
@@ -120,17 +120,4 @@ class MultiCatchTest extends GroovyTestCase {
}
assert catched
}
-
- // GROOVY-8238
- void testMultipleCatchGroovyAndJavaExceptions() {
- def cc = new CompilerConfiguration(pluginFactory: ParserPluginFactory.antlr2())
- new GroovyShell(cc).evaluate '''
- import groovy.cli.CliBuilderException
- try {
- throw new RuntimeException('boom')
- } catch ( RuntimeException | CliBuilderException e ) {
- assert e.message == 'boom'
- }
- '''
- }
}
diff --git a/src/test/groovy/bugs/Groovy9141.groovy b/src/test/groovy/bugs/Groovy9141.groovy
index ab323bf..1978abf 100644
--- a/src/test/groovy/bugs/Groovy9141.groovy
+++ b/src/test/groovy/bugs/Groovy9141.groovy
@@ -20,11 +20,9 @@ package groovy.bugs
import groovy.transform.CompileStatic
import org.codehaus.groovy.control.CompilationFailedException
-import org.codehaus.groovy.control.CompilerConfiguration
import org.junit.Test
import static groovy.test.GroovyAssert.shouldFail
-import static org.codehaus.groovy.control.ParserPluginFactory.antlr2
@CompileStatic
final class Groovy9141 {
@@ -46,16 +44,4 @@ final class Groovy9141 {
'''
assert err =~ / You cannot define an abstract method\[meth\] in the script. Try removing the 'abstract' /
}
-
- @Test
- void testAbstractMethodWithBodyInScript_oldParser() {
- def shell = new GroovyShell(new CompilerConfiguration(pluginFactory: antlr2()))
-
- def err = shouldFail CompilationFailedException, {
- shell.evaluate '''
- abstract void meth() {}
- '''
- }
- assert err =~ / Abstract methods do not define a body. /
- }
}
diff --git a/src/test/groovy/bugs/Groovy9184.groovy b/src/test/groovy/bugs/Groovy9184.groovy
deleted file mode 100644
index 70cfc6f..0000000
--- a/src/test/groovy/bugs/Groovy9184.groovy
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package groovy.bugs
-
-import groovy.transform.CompileStatic
-import org.codehaus.groovy.control.CompilerConfiguration
-import org.junit.Test
-
-import static org.codehaus.groovy.control.ParserPluginFactory.antlr2
-
-@CompileStatic
-final class Groovy9184 {
-
- @Test(timeout=1500L)
- void testEnumWithinEnum() {
- def config = new CompilerConfiguration(pluginFactory: antlr2())
-
- new GroovyShell(config).evaluate('''
- enum Outer {
- A, B
- enum Inner {
- X, Y
- }
- }
- assert Outer.A.name() == 'A'
- assert Outer.A.ordinal() == 0
- assert Outer.Inner.Y.name() == 'Y'
- assert Outer.Inner.Y.ordinal() == 1
- ''')
- }
-}
diff --git a/src/test/groovy/bugs/Groovy9213.groovy b/src/test/groovy/bugs/Groovy9213.groovy
index 2e8980c..b13dea0 100644
--- a/src/test/groovy/bugs/Groovy9213.groovy
+++ b/src/test/groovy/bugs/Groovy9213.groovy
@@ -23,23 +23,10 @@ import org.codehaus.groovy.control.CompilerConfiguration
import org.junit.Ignore
import org.junit.Test
-import static org.codehaus.groovy.control.ParserPluginFactory.antlr2
import static org.codehaus.groovy.control.ParserPluginFactory.antlr4
@CompileStatic @Ignore
final class Groovy9213 {
-
- @Test(timeout=15000L)
- void testUnmatchedParenInLongScript2() {
- def config = new CompilerConfiguration()
- config.pluginFactory = antlr2()
-
- new GroovyShell(config).evaluate('''
- int a = 0
- (
- ''' + ('a = 0\n' * 50))
- }
-
@Test(timeout=15000L)
void testUnmatchedParenInLongScript4() {
def config = new CompilerConfiguration()