public final class ASTTransformationVisitor extends ClassCodeVisitorSupport
ASTTransformationCollectorCodeVisitor
will add a list
of annotations that this visitor should be concerned about. All other
annotations are ignored, whether or not they are GroovyASTTransformation
annotated or not.
A Two-pass method is used. First all candidate annotations are added to a list then the transformations are called on those collected annotations. This is done to avoid concurrent modification exceptions during the AST tree walk and allows the transformations to alter any portion of the AST tree. Hence annotations that are added in this phase will not be processed as transformations. They will only be handled in later phases (and then only if the type was in the AST prior to any AST transformations being run against it).
Modifier and Type | Method and Description |
---|---|
static void |
addGlobalTransforms(ASTTransformationsContext context) |
static void |
addGlobalTransformsAfterGrab(ASTTransformationsContext context) |
static void |
addPhaseOperations(CompilationUnit compilationUnit) |
protected SourceUnit |
getSourceUnit() |
void |
visitAnnotations(AnnotatedNode node)
Adds the annotation to the internal target list if a match is found.
|
void |
visitClass(ClassNode classNode)
Main loop entry.
|
addError, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClassCodeContainer, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop
visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitListExpression, visitListOfExpressions, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression
protected SourceUnit getSourceUnit()
getSourceUnit
in class ClassCodeVisitorSupport
public void visitClass(ClassNode classNode)
First, it delegates to the super visitClass so we can collect the relevant annotations in an AST tree walk.
Second, it calls the visit method on the transformation for each relevant annotation found.
visitClass
in interface GroovyClassVisitor
visitClass
in class ClassCodeVisitorSupport
classNode
- the class to visitpublic void visitAnnotations(AnnotatedNode node)
visitAnnotations
in class ClassCodeVisitorSupport
node
- the node to be processedpublic static void addPhaseOperations(CompilationUnit compilationUnit)
public static void addGlobalTransformsAfterGrab(ASTTransformationsContext context)
public static void addGlobalTransforms(ASTTransformationsContext context)