Top Description Methods
groovy.transform

public @Interface ASTTest

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:PACKAGE, TYPE, ANNOTATION_TYPE, CONSTRUCTOR, METHOD, FIELD, PARAMETER, LOCAL_VARIABLE
@GroovyASTTransformationClass:org.codehaus.groovy.transform.ASTTestTransformation
Imports
org.codehaus.groovy.control.CompilePhase, org.codehaus.groovy.transform.GroovyASTTransformationClass, java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target

This 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 the Field AST transformation this way:
import groovy.transform.*

@ASTTest(value = {
   def owner = node.declaringClass
   assert owner.fields.any { it.name == 'x' }
 })
@Field int x
The closure code is executed after the specified phase has completed. If no phase is provided, then the code is executed after the semantic analysis phase and each subsequent phase.

The node variable refers to the AST node where the AST test annotation is put. In the previous example, it means that node refers to the declaration "int x".

Since
2.0.0

Method Summary

Modifier and TypeMethod and Description
public CompilePhase
phase()

The compile phase after which the test code should run.

public Class<T>
value()

A closure which is executed against the annotated node after the specified phase has completed.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

phaseback to summary
public CompilePhase phase()

The compile phase after which the test code should run.

valueback to summary
public Class<T> value()

A closure which is executed against the annotated node after the specified phase has completed.