org.codehaus.groovy.control.customizers
[Groovy] Class ASTTransformationCustomizer
java.lang.Object
CompilationUnit.PrimaryClassNodeOperation
org.codehaus.groovy.control.customizers.CompilationCustomizer
org.codehaus.groovy.control.customizers.ASTTransformationCustomizer
class ASTTransformationCustomizer
extends CompilationCustomizer
This customizer allows applying an AST transformation to a source unit with
several strategies.
Creating a customizer with the class constructor will trigger an AST transformation for
each class node of a source unit. However, you cannot pass parameters to the annotation so the default values
will be used. Writing :
def configuration = new CompilerConfiguration()
configuration.addCompilationCustomizers(new ASTTransformationCustomizer(Log))
def shell = new GroovyShell(configuration)
shell.evaluate("""
class MyClass {
}""")
is equivalent to :
def shell = new GroovyShell()
shell.evaluate("""
@Log
class MyClass {
}""")
The class passed as a constructor parameter must be an AST transformation annotation.
Alternatively, you can apply a global AST transformation by calling the
AST transformation. In that case, the transformation is applied once for the whole source unit.
Unlike a global AST transformation declared in the META-INF/services/org.codehaus.groovy.transform.ASTTransformation
file, which are applied if the file is in the classpath, using this customizer you'll have the choice to apply
your transformation selectively. It can also be useful to debug global AST transformations without having to
package your annotation in a jar file.
- Authors:
- Cedric Champeau
- Since:
- 1.8.0
ASTTransformationCustomizer
ASTTransformationCustomizer(Class transformationAnnotation)
-
ASTTransformationCustomizer
ASTTransformationCustomizer(ASTTransformation transformation)
-
call
@Override
void call(SourceUnit source, GeneratorContext context, ClassNode classNode)
-
Copyright © 2003-2010 The Codehaus. All rights reserved.