You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jw...@apache.org on 2016/09/11 02:14:13 UTC

[1/2] groovy git commit: minor refactor: deprecate method

Repository: groovy
Updated Branches:
  refs/heads/master 84f6288b9 -> 006b0ba12


minor refactor:  deprecate method


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

Branch: refs/heads/master
Commit: 006b0ba1255fdc449e0f8b38a9997f513be090fc
Parents: 4241dce
Author: John Wagenleitner <jw...@apache.org>
Authored: Sat Sep 10 19:08:44 2016 -0700
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sat Sep 10 19:10:03 2016 -0700

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/control/ParserPluginFactory.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/006b0ba1/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/ParserPluginFactory.java b/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
index d043a7f..30a0d1c 100644
--- a/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
+++ b/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
@@ -34,7 +34,9 @@ public abstract class ParserPluginFactory {
      *
      * @param useNewParser unused.
      * @return the new parser factory.
+     * @deprecated use {@link #newInstance()}
      */
+    @Deprecated
     public static ParserPluginFactory newInstance(boolean useNewParser) {
         return newInstance();
     }


[2/2] groovy git commit: Remove outdated parser loading logic. (closes #415)

Posted by jw...@apache.org.
Remove outdated parser loading logic. (closes #415)

It looks like a long time ago there were two Groovy parsers, a \u201cClassic\u201d
and Antlr.  The Antlr one was loaded using reflection, while the classic
one was simply instantiated.  The reflection logic was kept after
definitely switching to Antlr (cf. ebeff74), although it is still
normally instantiated if reflection fails.

This commit simply removes all the reflection stuff.


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

Branch: refs/heads/master
Commit: 4241dce7a8f13713165bb19107935c1e463d8a6f
Parents: 84f6288
Author: S�bastien Le Callonnec <se...@weblogism.com>
Authored: Tue Sep 6 20:14:56 2016 +0100
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sat Sep 10 19:10:03 2016 -0700

----------------------------------------------------------------------
 .../groovy/control/CompilerConfiguration.java   |  2 +-
 .../groovy/control/ParserPluginFactory.java     | 50 +++++++-------------
 .../control/CompilerConfigurationTest.java      |  2 +-
 3 files changed, 20 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/4241dce7/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 e26b3ea..e85a62f 100644
--- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -698,7 +698,7 @@ public class CompilerConfiguration {
 
     public ParserPluginFactory getPluginFactory() {
         if (pluginFactory == null) {
-            pluginFactory = ParserPluginFactory.newInstance(true);
+            pluginFactory = ParserPluginFactory.newInstance();
         }
         return pluginFactory;
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/4241dce7/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/ParserPluginFactory.java b/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
index 20cb9e4..d043a7f 100644
--- a/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
+++ b/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
@@ -25,40 +25,26 @@ import org.codehaus.groovy.antlr.AntlrParserPluginFactory;
  *
  */
 public abstract class ParserPluginFactory {
+
+    /**
+     * Creates a new instance of {@link ParserPluginFactory}.
+     *
+     * <p>The <code>useNewParser</code> parameter is not used, and this method
+     * is kept for backward compatibility.
+     *
+     * @param useNewParser unused.
+     * @return the new parser factory.
+     */
     public static ParserPluginFactory newInstance(boolean useNewParser) {
-        if (useNewParser) {
-            Class type = null;
-            String name = "org.codehaus.groovy.antlr.AntlrParserPluginFactory";
-            try {
-                type = Class.forName(name);
-            }
-            catch (ClassNotFoundException e) {
-                try {
-                    type = ParserPluginFactory.class.getClassLoader().loadClass(name);
-                }
-                catch (ClassNotFoundException e1) {
-                    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-                    if (contextClassLoader != null) {
-                        try {
-                            type = contextClassLoader.loadClass(name);
-                        }
-                        catch (ClassNotFoundException e2) {
-                            // ignore
-                        }
-                    }
-                }
-            }
+        return newInstance();
+    }
 
-            if (type != null) {
-                try {
-                    return (ParserPluginFactory) type.newInstance();
-                }
-                catch (Exception e) {
-                    throw new RuntimeException("Could not create AntlrParserPluginFactory: " + e, e);
-                }
-            }
-            // can't find Antlr parser, so lets use the Classic one
-        }
+    /**
+     * Creates a new instance of {@link ParserPluginFactory}.
+     *
+     * @return the new parser factory.
+     */
+    public static ParserPluginFactory newInstance() {
         return new AntlrParserPluginFactory();
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/4241dce7/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java b/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
index 3be37cc..7d67307 100644
--- a/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
+++ b/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
@@ -130,7 +130,7 @@ public class CompilerConfigurationTest extends GroovyTestCase {
         initJoint.put("somekey", "somevalue");
         init.setJointCompilationOptions(initJoint);
 
-        final ParserPluginFactory initPPF = ParserPluginFactory.newInstance(true);
+        final ParserPluginFactory initPPF = ParserPluginFactory.newInstance();
         init.setPluginFactory(initPPF);
 
         assertEquals(WarningMessage.POSSIBLE_ERRORS, init.getWarningLevel());