Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

## groovy.transform
[Java] Annotation Type ASTTest

    java.lang.Object
      groovy.transform.ASTTest

    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD,
    ElementType.LOCAL_VARIABLE, ElementType.PACKAGE, ElementType.PARAMETER})
    @GroovyASTTransformationClass("org.codehaus.groovy.transform.ASTTestTransformation")
    public @interface ASTTest

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 selected, then the code is executed after the semantic analysis 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 node (int x).

Authors:
  Cedric Champeau

Since:
  2.0.0

Required Element Summary
`java.lang.Class` | `value` A closure which is executed against the annotated node after the specified phase has completed.

Optional Element Summary
`CompilePhase` | `phase` The compile phase after which the test code should run.

Method Summary

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Element Detail

### phase

    public CompilePhase phase

  The compile phase after which the test code should run. @default CompilePhase.SEMANTIC_ANALYSIS

### value

    public java.lang.Class value

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

Groovy Documentation