groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] branch GROOVY_3_0_X updated: prepare for removal of antlr2 parser: move used utility method into separate helper class
Date Sun, 29 Sep 2019 00:58:33 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
     new e190e69  prepare for removal of antlr2 parser: move used utility method into separate
helper class
e190e69 is described below

commit e190e69ab03713d37a0547dc5e46d93958549731
Author: Paul King <paulk@asert.com.au>
AuthorDate: Sun Sep 29 10:57:28 2019 +1000

    prepare for removal of antlr2 parser: move used utility method into separate helper class
---
 .../codehaus/groovy/antlr/AntlrParserPlugin.java   | 27 ++-------------
 .../org/codehaus/groovy/antlr/PrimitiveHelper.java | 39 ++++++++++++++++++++++
 .../transform/AutoImplementASTTransformation.java  |  2 +-
 3 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/antlr/AntlrParserPlugin.java b/src/main/java/org/codehaus/groovy/antlr/AntlrParserPlugin.java
index f6330c0..afb0921 100644
--- a/src/main/java/org/codehaus/groovy/antlr/AntlrParserPlugin.java
+++ b/src/main/java/org/codehaus/groovy/antlr/AntlrParserPlugin.java
@@ -1097,32 +1097,9 @@ public class AntlrParserPlugin extends ASTHelper implements ParserPlugin,
Groovy
         }
     }
 
+    @Deprecated
     public static Expression getDefaultValueForPrimitive(ClassNode type) {
-        if (type == ClassHelper.int_TYPE) {
-            return new ConstantExpression(0);
-        }
-        if (type == ClassHelper.long_TYPE) {
-            return new ConstantExpression(0L);
-        }
-        if (type == ClassHelper.double_TYPE) {
-            return new ConstantExpression(0.0);
-        }
-        if (type == ClassHelper.float_TYPE) {
-            return new ConstantExpression(0.0F);
-        }
-        if (type == ClassHelper.boolean_TYPE) {
-            return ConstantExpression.FALSE;
-        }
-        if (type == ClassHelper.short_TYPE) {
-            return new ConstantExpression((short) 0);
-        }
-        if (type == ClassHelper.byte_TYPE) {
-            return new ConstantExpression((byte) 0);
-        }
-        if (type == ClassHelper.char_TYPE) {
-            return new ConstantExpression((char) 0);
-        }
-        return null;
+        return PrimitiveHelper.getDefaultValueForPrimitive(type);
     }
 
     protected ClassNode[] interfaces(AST node) {
diff --git a/src/main/java/org/codehaus/groovy/antlr/PrimitiveHelper.java b/src/main/java/org/codehaus/groovy/antlr/PrimitiveHelper.java
new file mode 100644
index 0000000..ae053b0
--- /dev/null
+++ b/src/main/java/org/codehaus/groovy/antlr/PrimitiveHelper.java
@@ -0,0 +1,39 @@
+package org.codehaus.groovy.antlr;
+
+import org.codehaus.groovy.ast.ClassHelper;
+import org.codehaus.groovy.ast.ClassNode;
+import org.codehaus.groovy.ast.expr.ConstantExpression;
+import org.codehaus.groovy.ast.expr.Expression;
+
+public class PrimitiveHelper {
+    private PrimitiveHelper() {
+    }
+
+    public static Expression getDefaultValueForPrimitive(ClassNode type) {
+        if (type == ClassHelper.int_TYPE) {
+            return new ConstantExpression(0);
+        }
+        if (type == ClassHelper.long_TYPE) {
+            return new ConstantExpression(0L);
+        }
+        if (type == ClassHelper.double_TYPE) {
+            return new ConstantExpression(0.0);
+        }
+        if (type == ClassHelper.float_TYPE) {
+            return new ConstantExpression(0.0F);
+        }
+        if (type == ClassHelper.boolean_TYPE) {
+            return ConstantExpression.FALSE;
+        }
+        if (type == ClassHelper.short_TYPE) {
+            return new ConstantExpression((short) 0);
+        }
+        if (type == ClassHelper.byte_TYPE) {
+            return new ConstantExpression((byte) 0);
+        }
+        if (type == ClassHelper.char_TYPE) {
+            return new ConstantExpression((char) 0);
+        }
+        return null;
+    }
+}
diff --git a/src/main/java/org/codehaus/groovy/transform/AutoImplementASTTransformation.java
b/src/main/java/org/codehaus/groovy/transform/AutoImplementASTTransformation.java
index 67745f8..985e8a7 100644
--- a/src/main/java/org/codehaus/groovy/transform/AutoImplementASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/AutoImplementASTTransformation.java
@@ -44,7 +44,7 @@ import java.util.Map;
 
 import static org.apache.groovy.ast.tools.ClassNodeUtils.addGeneratedMethod;
 import static org.apache.groovy.ast.tools.MethodNodeUtils.methodDescriptorWithoutReturnType;
-import static org.codehaus.groovy.antlr.AntlrParserPlugin.getDefaultValueForPrimitive;
+import static org.codehaus.groovy.antlr.PrimitiveHelper.getDefaultValueForPrimitive;
 import static org.codehaus.groovy.ast.ClassHelper.make;
 import static org.codehaus.groovy.ast.expr.ArgumentListExpression.EMPTY_ARGUMENTS;
 import static org.codehaus.groovy.ast.tools.GeneralUtils.constX;


Mime
View raw message