Class ContextualClassCodeVisitor
- java.lang.Object
-
- org.codehaus.groovy.ast.CodeVisitorSupport
-
- org.codehaus.groovy.ast.ClassCodeVisitorSupport
-
- org.codehaus.groovy.macro.matcher.ContextualClassCodeVisitor
-
- All Implemented Interfaces:
GroovyClassVisitor
,GroovyCodeVisitor
,ErrorCollecting
public abstract class ContextualClassCodeVisitor extends ClassCodeVisitorSupport
A class code visitor which is capable of remembering the context of the current visit. This makes it easier for subclasses to perform context-dependent transformations, where for example it is necessary to check the parent nodes of an AST node before performing some operations.- Since:
- 2.5.0
-
-
Constructor Summary
Constructors Constructor Description ContextualClassCodeVisitor()
-
Method Summary
-
Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, getSourceUnit, visitAnnotation, visitAnnotations, visitClassCodeContainer, visitConstructor, visitDeclarationExpression, visitMethod, visitObjectInitializerStatements, visitStatement
-
Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitLambdaExpression, visitMethodReferenceExpression
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor
visitEmptyExpression, visitListOfExpressions
-
-
-
-
Method Detail
-
getTreeContext
public TreeContext getTreeContext()
-
getLastContext
public TreeContext getLastContext()
-
pushContext
protected void pushContext(TreeContext ctx)
-
popContext
protected TreeContext popContext()
-
pushContext
protected void pushContext(ASTNode node)
-
visitClass
public void visitClass(ClassNode node)
Description copied from interface:GroovyClassVisitor
Visit a ClassNode.- Specified by:
visitClass
in interfaceGroovyClassVisitor
- Overrides:
visitClass
in classClassCodeVisitorSupport
-
visitPackage
public void visitPackage(PackageNode node)
- Overrides:
visitPackage
in classClassCodeVisitorSupport
-
visitImports
public void visitImports(ModuleNode node)
- Overrides:
visitImports
in classClassCodeVisitorSupport
-
visitConstructorOrMethod
protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
- Overrides:
visitConstructorOrMethod
in classClassCodeVisitorSupport
-
visitField
public void visitField(FieldNode node)
Description copied from interface:GroovyClassVisitor
Visit a FieldNode.- Specified by:
visitField
in interfaceGroovyClassVisitor
- Overrides:
visitField
in classClassCodeVisitorSupport
-
visitProperty
public void visitProperty(PropertyNode node)
Description copied from interface:GroovyClassVisitor
Visit a PropertyNode.- Specified by:
visitProperty
in interfaceGroovyClassVisitor
- Overrides:
visitProperty
in classClassCodeVisitorSupport
-
visitMethodCallExpression
public void visitMethodCallExpression(MethodCallExpression call)
- Specified by:
visitMethodCallExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMethodCallExpression
in classCodeVisitorSupport
-
visitStaticMethodCallExpression
public void visitStaticMethodCallExpression(StaticMethodCallExpression call)
- Specified by:
visitStaticMethodCallExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitStaticMethodCallExpression
in classCodeVisitorSupport
-
visitConstructorCallExpression
public void visitConstructorCallExpression(ConstructorCallExpression call)
- Specified by:
visitConstructorCallExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitConstructorCallExpression
in classCodeVisitorSupport
-
visitBinaryExpression
public void visitBinaryExpression(BinaryExpression expression)
- Specified by:
visitBinaryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBinaryExpression
in classCodeVisitorSupport
-
visitTernaryExpression
public void visitTernaryExpression(TernaryExpression expression)
- Specified by:
visitTernaryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitTernaryExpression
in classCodeVisitorSupport
-
visitShortTernaryExpression
public void visitShortTernaryExpression(ElvisOperatorExpression expression)
- Specified by:
visitShortTernaryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitShortTernaryExpression
in classCodeVisitorSupport
-
visitPostfixExpression
public void visitPostfixExpression(PostfixExpression expression)
- Specified by:
visitPostfixExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitPostfixExpression
in classCodeVisitorSupport
-
visitPrefixExpression
public void visitPrefixExpression(PrefixExpression expression)
- Specified by:
visitPrefixExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitPrefixExpression
in classCodeVisitorSupport
-
visitBooleanExpression
public void visitBooleanExpression(BooleanExpression expression)
- Specified by:
visitBooleanExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBooleanExpression
in classCodeVisitorSupport
-
visitNotExpression
public void visitNotExpression(NotExpression expression)
- Specified by:
visitNotExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitNotExpression
in classCodeVisitorSupport
-
visitClosureExpression
public void visitClosureExpression(ClosureExpression expression)
- Specified by:
visitClosureExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClosureExpression
in classCodeVisitorSupport
-
visitTupleExpression
public void visitTupleExpression(TupleExpression expression)
- Specified by:
visitTupleExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitTupleExpression
in classCodeVisitorSupport
-
visitListExpression
public void visitListExpression(ListExpression expression)
- Specified by:
visitListExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitListExpression
in classCodeVisitorSupport
-
visitArrayExpression
public void visitArrayExpression(ArrayExpression expression)
- Specified by:
visitArrayExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitArrayExpression
in classCodeVisitorSupport
-
visitMapExpression
public void visitMapExpression(MapExpression expression)
- Specified by:
visitMapExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMapExpression
in classCodeVisitorSupport
-
visitMapEntryExpression
public void visitMapEntryExpression(MapEntryExpression expression)
- Specified by:
visitMapEntryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMapEntryExpression
in classCodeVisitorSupport
-
visitRangeExpression
public void visitRangeExpression(RangeExpression expression)
- Specified by:
visitRangeExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitRangeExpression
in classCodeVisitorSupport
-
visitSpreadExpression
public void visitSpreadExpression(SpreadExpression expression)
- Specified by:
visitSpreadExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitSpreadExpression
in classCodeVisitorSupport
-
visitSpreadMapExpression
public void visitSpreadMapExpression(SpreadMapExpression expression)
- Specified by:
visitSpreadMapExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitSpreadMapExpression
in classCodeVisitorSupport
-
visitMethodPointerExpression
public void visitMethodPointerExpression(MethodPointerExpression expression)
- Specified by:
visitMethodPointerExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMethodPointerExpression
in classCodeVisitorSupport
-
visitUnaryMinusExpression
public void visitUnaryMinusExpression(UnaryMinusExpression expression)
- Specified by:
visitUnaryMinusExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitUnaryMinusExpression
in classCodeVisitorSupport
-
visitUnaryPlusExpression
public void visitUnaryPlusExpression(UnaryPlusExpression expression)
- Specified by:
visitUnaryPlusExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitUnaryPlusExpression
in classCodeVisitorSupport
-
visitBitwiseNegationExpression
public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)
- Specified by:
visitBitwiseNegationExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBitwiseNegationExpression
in classCodeVisitorSupport
-
visitCastExpression
public void visitCastExpression(CastExpression expression)
- Specified by:
visitCastExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitCastExpression
in classCodeVisitorSupport
-
visitConstantExpression
public void visitConstantExpression(ConstantExpression expression)
- Specified by:
visitConstantExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitConstantExpression
in classCodeVisitorSupport
-
visitClassExpression
public void visitClassExpression(ClassExpression expression)
- Specified by:
visitClassExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClassExpression
in classCodeVisitorSupport
-
visitVariableExpression
public void visitVariableExpression(VariableExpression expression)
- Specified by:
visitVariableExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitVariableExpression
in classCodeVisitorSupport
-
visitPropertyExpression
public void visitPropertyExpression(PropertyExpression expression)
- Specified by:
visitPropertyExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitPropertyExpression
in classCodeVisitorSupport
-
visitAttributeExpression
public void visitAttributeExpression(AttributeExpression expression)
- Specified by:
visitAttributeExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitAttributeExpression
in classCodeVisitorSupport
-
visitFieldExpression
public void visitFieldExpression(FieldExpression expression)
- Specified by:
visitFieldExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitFieldExpression
in classCodeVisitorSupport
-
visitGStringExpression
public void visitGStringExpression(GStringExpression expression)
- Specified by:
visitGStringExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitGStringExpression
in classCodeVisitorSupport
-
visitClosureListExpression
public void visitClosureListExpression(ClosureListExpression cle)
- Specified by:
visitClosureListExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClosureListExpression
in classCodeVisitorSupport
-
visitBytecodeExpression
public void visitBytecodeExpression(BytecodeExpression cle)
- Specified by:
visitBytecodeExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBytecodeExpression
in classCodeVisitorSupport
-
visitAssertStatement
public void visitAssertStatement(AssertStatement statement)
- Specified by:
visitAssertStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitAssertStatement
in classClassCodeVisitorSupport
-
visitBlockStatement
public void visitBlockStatement(BlockStatement block)
- Specified by:
visitBlockStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitBlockStatement
in classClassCodeVisitorSupport
-
visitBreakStatement
public void visitBreakStatement(BreakStatement statement)
- Specified by:
visitBreakStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitBreakStatement
in classClassCodeVisitorSupport
-
visitCaseStatement
public void visitCaseStatement(CaseStatement statement)
- Specified by:
visitCaseStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitCaseStatement
in classClassCodeVisitorSupport
-
visitCatchStatement
public void visitCatchStatement(CatchStatement statement)
- Specified by:
visitCatchStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitCatchStatement
in classClassCodeVisitorSupport
-
visitContinueStatement
public void visitContinueStatement(ContinueStatement statement)
- Specified by:
visitContinueStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitContinueStatement
in classClassCodeVisitorSupport
-
visitDoWhileLoop
public void visitDoWhileLoop(DoWhileStatement loop)
- Specified by:
visitDoWhileLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitDoWhileLoop
in classClassCodeVisitorSupport
-
visitExpressionStatement
public void visitExpressionStatement(ExpressionStatement statement)
- Specified by:
visitExpressionStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitExpressionStatement
in classClassCodeVisitorSupport
-
visitForLoop
public void visitForLoop(ForStatement forLoop)
- Specified by:
visitForLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitForLoop
in classClassCodeVisitorSupport
-
visitIfElse
public void visitIfElse(IfStatement ifElse)
- Specified by:
visitIfElse
in interfaceGroovyCodeVisitor
- Overrides:
visitIfElse
in classClassCodeVisitorSupport
-
visitReturnStatement
public void visitReturnStatement(ReturnStatement statement)
- Specified by:
visitReturnStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitReturnStatement
in classClassCodeVisitorSupport
-
visitSwitch
public void visitSwitch(SwitchStatement statement)
- Specified by:
visitSwitch
in interfaceGroovyCodeVisitor
- Overrides:
visitSwitch
in classClassCodeVisitorSupport
-
visitSynchronizedStatement
public void visitSynchronizedStatement(SynchronizedStatement statement)
- Specified by:
visitSynchronizedStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitSynchronizedStatement
in classClassCodeVisitorSupport
-
visitThrowStatement
public void visitThrowStatement(ThrowStatement statement)
- Specified by:
visitThrowStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitThrowStatement
in classClassCodeVisitorSupport
-
visitTryCatchFinally
public void visitTryCatchFinally(TryCatchStatement statement)
- Specified by:
visitTryCatchFinally
in interfaceGroovyCodeVisitor
- Overrides:
visitTryCatchFinally
in classClassCodeVisitorSupport
-
visitWhileLoop
public void visitWhileLoop(WhileStatement loop)
- Specified by:
visitWhileLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitWhileLoop
in classClassCodeVisitorSupport
-
visitEmptyStatement
public void visitEmptyStatement(EmptyStatement statement)
- Specified by:
visitEmptyStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitEmptyStatement
in classCodeVisitorSupport
-
getTreePath
public List<TreeContext> getTreePath()
-
pathMatches
public List<TreeContext> pathMatches(List<ASTNodePredicate> predicates)
-
pathUpTo
public List<TreeContext> pathUpTo(ASTNodePredicate predicate)
-
pathUpTo
public List<TreeContext> pathUpTo(Class<ASTNode> node)
-
pathUpTo
public List<TreeContext> pathUpTo(Class<ASTNode> node, ASTNodePredicate predicate)
-
matchByClass
public static List<ASTNodePredicate> matchByClass(Class<ASTNode>... classes)
-
-