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/06/07 03:16:24 UTC
[groovy] branch GROOVY_2_5_X updated: GROOVY-9163: AutoExternalize
AST transform (and others) mark user supplied read/write method as
@Generated
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
new 7f8ffc4 GROOVY-9163: AutoExternalize AST transform (and others) mark user supplied read/write method as @Generated
7f8ffc4 is described below
commit 7f8ffc4d5a5d749eef65e100dafabdec4116db63
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri Jun 7 11:35:29 2019 +1000
GROOVY-9163: AutoExternalize AST transform (and others) mark user supplied read/write method as @Generated
---
.../java/org/apache/groovy/ast/tools/ClassNodeUtils.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java b/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
index daf60aa..0d61ea5 100644
--- a/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
@@ -78,7 +78,7 @@ public class ClassNodeUtils {
}
/**
- * Add a method that is marked as @Generated.
+ * Return an existing method if one exists or else create a new method and mark it as {@code @Generated}.
*
* @see ClassNode#addMethod(String, int, ClassNode, Parameter[], ClassNode[], Statement)
*/
@@ -88,13 +88,15 @@ public class ClassNodeUtils {
Parameter[] parameters,
ClassNode[] exceptions,
Statement code) {
- MethodNode result = cNode.addMethod(name, modifiers, returnType, parameters, exceptions, code);
- markAsGenerated(cNode, result);
+ MethodNode existing = cNode.getDeclaredMethod(name, parameters);
+ if (existing != null) return existing;
+ MethodNode result = new MethodNode(name, modifiers, returnType, parameters, exceptions, code);
+ addGeneratedMethod(cNode, result);
return result;
}
/**
- * Add a method that is marked as @Generated.
+ * Add a method and mark it as {@code @Generated}.
*
* @see ClassNode#addMethod(MethodNode)
*/
@@ -104,7 +106,7 @@ public class ClassNodeUtils {
}
/**
- * Add an inner class that is marked as @Generated.
+ * Add an inner class that is marked as {@code @Generated}.
*
* @see org.codehaus.groovy.ast.ModuleNode#addClass(ClassNode)
*/
@@ -114,7 +116,7 @@ public class ClassNodeUtils {
}
/**
- * Add a method that is marked as @Generated.
+ * Add a method that is marked as {@code @Generated}.
*
* @see ClassNode#addConstructor(int, Parameter[], ClassNode[], Statement)
*/
@@ -125,7 +127,7 @@ public class ClassNodeUtils {
}
/**
- * Add a method that is marked as @Generated.
+ * Add a method that is marked as {@code @Generated}.
*
* @see ClassNode#addConstructor(ConstructorNode)
*/