Package groovy.transform
Annotation Type ASTTest
-
@Documented @Retention(RUNTIME) @Target({TYPE,METHOD,ANNOTATION_TYPE,CONSTRUCTOR,FIELD,LOCAL_VARIABLE,PACKAGE,PARAMETER}) public @interface ASTTestThis AST transformation aims at helping in debugging other AST transformations. It provides a basic infrastructure for performing tests on AST nodes. You can place this annotation on any node which accepts an annotation (types, methods, annotations, constructors, fields, local variables, packages or parameters), then use a script which is run against this AST node at a specific phase. For example, you could test theFieldAST transformation this way:import groovy.transform.*
The closure code is executed after the specified phase has completed. If no phase is selected, then the code is executed after the@ASTTest(value = { def owner = node.declaringClass assert owner.fields.any { it.name == 'x' } })@Field int xsemantic analysisphase. Thenodevariable refers to the AST node where the AST test annotation is put. In the previous example, it means that node refers to the declaration node (int x).- Since:
- 2.0.0
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.ClassvalueA closure which is executed against the annotated node after the specified phase has completed.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description CompilePhasephaseThe compile phase after which the test code should run.
-
-
-
-
phase
CompilePhase phase
The compile phase after which the test code should run.- Default:
- org.codehaus.groovy.control.CompilePhase.SEMANTIC_ANALYSIS
-
-