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

[groovy] branch GROOVY_3_0_X updated: Revert "GROOVY-9702: source retention for @ASTTest and improved AST modification (closes #1352)"

This is an automated email from the ASF dual-hosted git repository.

sunlan 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 9296010  Revert "GROOVY-9702: source retention for @ASTTest and improved AST modification (closes #1352)"
9296010 is described below

commit 9296010393cbcf4bd7fea892b93129b45ba63f02
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Sep 13 19:21:28 2020 +0800

    Revert "GROOVY-9702: source retention for @ASTTest and improved AST modification (closes #1352)"
    
    This reverts commit d26be15e, which is a breaking change
---
 .../org/codehaus/groovy/transform/ASTTestTransformation.groovy      | 6 +-----
 src/main/java/groovy/transform/ASTTest.java                         | 5 ++---
 src/test/groovy/transform/AnnotationCollectorLegacyTest.groovy      | 6 +++---
 src/test/groovy/transform/AnnotationCollectorTest.groovy            | 2 +-
 4 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/main/groovy/org/codehaus/groovy/transform/ASTTestTransformation.groovy b/src/main/groovy/org/codehaus/groovy/transform/ASTTestTransformation.groovy
index e14a8fe..15ca578 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/ASTTestTransformation.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/ASTTestTransformation.groovy
@@ -25,11 +25,9 @@ import org.codehaus.groovy.ast.ClassCodeVisitorSupport
 import org.codehaus.groovy.ast.ClassHelper
 import org.codehaus.groovy.ast.ClassNode
 import org.codehaus.groovy.ast.MethodNode
-import org.codehaus.groovy.ast.Parameter
 import org.codehaus.groovy.ast.expr.ClosureExpression
 import org.codehaus.groovy.ast.expr.PropertyExpression
 import org.codehaus.groovy.ast.expr.VariableExpression
-import org.codehaus.groovy.ast.stmt.EmptyStatement
 import org.codehaus.groovy.ast.stmt.Statement
 import org.codehaus.groovy.control.CompilationUnit
 import org.codehaus.groovy.control.CompilePhase
@@ -74,9 +72,7 @@ class ASTTestTransformation implements ASTTransformation, CompilationUnitAware {
         }
         // convert value into node metadata so that the expression doesn't mix up with other AST xforms like STC
         annotationNode.setNodeMetaData(ASTTestTransformation, member)
-        annotationNode.setMember('value', new ClosureExpression(
-            Parameter.EMPTY_ARRAY, EmptyStatement.INSTANCE))
-        member.variableScope.@parent = null
+        annotationNode.members.remove('value')
 
         def pcallback = compilationUnit.progressCallback
         def callback = new CompilationUnit.ProgressCallback() {
diff --git a/src/main/java/groovy/transform/ASTTest.java b/src/main/java/groovy/transform/ASTTest.java
index 1c144a8..1779161 100644
--- a/src/main/java/groovy/transform/ASTTest.java
+++ b/src/main/java/groovy/transform/ASTTest.java
@@ -18,7 +18,6 @@
  */
 package groovy.transform;
 
-import groovy.lang.Closure;
 import org.codehaus.groovy.control.CompilePhase;
 import org.codehaus.groovy.transform.GroovyASTTransformationClass;
 
@@ -53,7 +52,7 @@ import java.lang.annotation.Target;
  * @since 2.0.0
  */
 @Documented
-@Retention(RetentionPolicy.SOURCE)
+@Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
 @GroovyASTTransformationClass("org.codehaus.groovy.transform.ASTTestTransformation")
 public @interface ASTTest {
@@ -65,5 +64,5 @@ public @interface ASTTest {
     /**
      * A closure which is executed against the annotated node after the specified phase has completed.
      */
-    Class<? extends /*@ClosureParams(value=FromString.class,options="")*/ Closure<?>> value();
+    Class value();
 }
diff --git a/src/test/groovy/transform/AnnotationCollectorLegacyTest.groovy b/src/test/groovy/transform/AnnotationCollectorLegacyTest.groovy
index 304c03c..0268602 100644
--- a/src/test/groovy/transform/AnnotationCollectorLegacyTest.groovy
+++ b/src/test/groovy/transform/AnnotationCollectorLegacyTest.groovy
@@ -162,7 +162,7 @@ class AnnotationCollectorLegacyTest extends GroovyTestCase {
     }
 
     void testAST() {
-        assertScript '''
+        assertScript """
             import groovy.transform.*
             @AnnotationCollector(value = [ToString, EqualsAndHashCode, Sortable], serializeClass = Alias)
             @interface Alias {}
@@ -178,11 +178,11 @@ class AnnotationCollectorLegacyTest extends GroovyTestCase {
             class Foo {
                 Integer a, b
             }
-            assert Foo.class.annotations.size() == 3
+            assert Foo.class.annotations.size() == 4
             assert new Foo(a: 1, b: 2).toString() == "Foo(2)"
             assert Alias.value().length == 0
             assert Alias.value() instanceof Object[][]
-        '''
+        """
     }
 
     void testConflictingAnnotations() {
diff --git a/src/test/groovy/transform/AnnotationCollectorTest.groovy b/src/test/groovy/transform/AnnotationCollectorTest.groovy
index f78235b..6f519a5 100644
--- a/src/test/groovy/transform/AnnotationCollectorTest.groovy
+++ b/src/test/groovy/transform/AnnotationCollectorTest.groovy
@@ -185,7 +185,7 @@ class AnnotationCollectorTest extends GroovyTestCase {
             class Foo {
                 Integer a, b
             }
-            assert Foo.class.annotations.size() == 3
+            assert Foo.class.annotations.size() == 4
             assert new Foo(a: 1, b: 2).toString() == "Foo(2)"
             def data = Alias.getAnnotation(AnnotationCollector).serializeClass().value()
             assert data.length == 0