Groovy 2.2.1

org.codehaus.groovy.transform
[Java] Class ASTTransformationVisitor

java.lang.Object
  org.codehaus.groovy.ast.CodeVisitorSupport
      org.codehaus.groovy.ast.ClassCodeVisitorSupport
          org.codehaus.groovy.transform.ASTTransformationVisitor

public final class ASTTransformationVisitor
extends ClassCodeVisitorSupport

This class handles the invocation of the ASTAnnotationTransformation when it is encountered by a tree walk. One instance of each exists for each phase of the compilation it applies to. Before invocation the

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).

Authors:
Danno Ferrin (shemnon)


Method Summary
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.

 
Methods inherited from class ClassCodeVisitorSupport
visitMethod, visitField, visitReturnStatement, visitProperty, visitConstructor, visitClass, visitPackage, visitBlockStatement, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitSwitch, visitWhileLoop, visitDeclarationExpression, visitImports, visitBreakStatement, visitContinueStatement, visitTryCatchFinally, visitAnnotations, visitCatchStatement, visitIfElse, visitAssertStatement, visitCaseStatement, visitSynchronizedStatement, visitThrowStatement, visitClassExpression, visitPropertyExpression, visitListExpression, visitConstantExpression, visitMethodCallExpression, visitStaticMethodCallExpression, visitConstructorCallExpression, visitBinaryExpression, visitTernaryExpression, visitShortTernaryExpression, visitPostfixExpression, visitPrefixExpression, visitBooleanExpression, visitNotExpression, visitClosureExpression, visitTupleExpression, visitArrayExpression, visitMapExpression, visitMapEntryExpression, visitRangeExpression, visitSpreadExpression, visitSpreadMapExpression, visitMethodPointerExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitBitwiseNegationExpression, visitCastExpression, visitVariableExpression, visitAttributeExpression, visitFieldExpression, visitGStringExpression, visitArgumentlistExpression, visitClosureListExpression, visitBytecodeExpression, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class CodeVisitorSupport
visitReturnStatement, visitClassExpression, visitPropertyExpression, visitListExpression, visitConstantExpression, visitBlockStatement, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitSwitch, visitWhileLoop, visitDeclarationExpression, visitBreakStatement, visitContinueStatement, visitTryCatchFinally, visitMethodCallExpression, visitStaticMethodCallExpression, visitConstructorCallExpression, visitBinaryExpression, visitTernaryExpression, visitShortTernaryExpression, visitPostfixExpression, visitPrefixExpression, visitBooleanExpression, visitNotExpression, visitClosureExpression, visitTupleExpression, visitArrayExpression, visitMapExpression, visitMapEntryExpression, visitRangeExpression, visitSpreadExpression, visitSpreadMapExpression, visitMethodPointerExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitBitwiseNegationExpression, visitCastExpression, visitVariableExpression, visitAttributeExpression, visitFieldExpression, visitGStringExpression, visitArgumentlistExpression, visitClosureListExpression, visitBytecodeExpression, visitCatchStatement, visitIfElse, visitAssertStatement, visitCaseStatement, visitSynchronizedStatement, visitThrowStatement, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Method Detail

addGlobalTransforms

public static void addGlobalTransforms(ASTTransformationsContext context)


addGlobalTransformsAfterGrab

public static void addGlobalTransformsAfterGrab(ASTTransformationsContext context)


addPhaseOperations

public static void addPhaseOperations(CompilationUnit compilationUnit)


getSourceUnit

protected SourceUnit getSourceUnit()


visitAnnotations

public void visitAnnotations(AnnotatedNode node)
Adds the annotation to the internal target list if a match is found.
Parameters:
node - the node to be processed


visitClass

public void visitClass(ClassNode classNode)
Main loop entry.

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.

Parameters:
classNode - the class to visit


 

Copyright © 2003-2013 The Codehaus. All rights reserved.