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
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<ASTNodePredicate>
matchByClass
(Class<ASTNode>... classes) pathMatches
(List<ASTNodePredicate> predicates) pathUpTo
(Class<ASTNode> node, ASTNodePredicate predicate) pathUpTo
(ASTNodePredicate predicate) protected TreeContext
protected void
pushContext
(ASTNode node) protected void
pushContext
(TreeContext ctx) void
visitArrayExpression
(ArrayExpression expression) void
visitAssertStatement
(AssertStatement statement) void
visitAttributeExpression
(AttributeExpression expression) void
visitBinaryExpression
(BinaryExpression expression) void
void
void
visitBooleanExpression
(BooleanExpression expression) void
visitBreakStatement
(BreakStatement statement) void
void
visitCaseStatement
(CaseStatement statement) void
visitCastExpression
(CastExpression expression) void
visitCatchStatement
(CatchStatement statement) void
visitClass
(ClassNode node) Visit a ClassNode.void
visitClassExpression
(ClassExpression expression) void
visitClosureExpression
(ClosureExpression expression) void
void
visitConstantExpression
(ConstantExpression expression) void
protected void
visitConstructorOrMethod
(MethodNode node, boolean isConstructor) void
visitContinueStatement
(ContinueStatement statement) void
void
visitEmptyStatement
(EmptyStatement statement) void
visitExpressionStatement
(ExpressionStatement statement) void
visitField
(FieldNode node) Visit a FieldNode.void
visitFieldExpression
(FieldExpression expression) void
visitForLoop
(ForStatement forLoop) void
visitGStringExpression
(GStringExpression expression) void
visitIfElse
(IfStatement ifElse) void
visitImports
(ModuleNode node) void
visitListExpression
(ListExpression expression) void
visitMapEntryExpression
(MapEntryExpression expression) void
visitMapExpression
(MapExpression expression) void
void
visitMethodPointerExpression
(MethodPointerExpression expression) void
visitNotExpression
(NotExpression expression) void
visitPackage
(PackageNode node) void
visitPostfixExpression
(PostfixExpression expression) void
visitPrefixExpression
(PrefixExpression expression) void
visitProperty
(PropertyNode node) Visit a PropertyNode.void
visitPropertyExpression
(PropertyExpression expression) void
visitRangeExpression
(RangeExpression expression) void
visitReturnStatement
(ReturnStatement statement) void
visitShortTernaryExpression
(ElvisOperatorExpression expression) void
visitSpreadExpression
(SpreadExpression expression) void
visitSpreadMapExpression
(SpreadMapExpression expression) void
void
visitSwitch
(SwitchStatement statement) void
visitSynchronizedStatement
(SynchronizedStatement statement) void
visitTernaryExpression
(TernaryExpression expression) void
visitThrowStatement
(ThrowStatement statement) void
visitTryCatchFinally
(TryCatchStatement statement) void
visitTupleExpression
(TupleExpression expression) void
visitUnaryMinusExpression
(UnaryMinusExpression expression) void
visitUnaryPlusExpression
(UnaryPlusExpression expression) void
visitVariableExpression
(VariableExpression expression) void
visitWhileLoop
(WhileStatement loop) Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAnnotations, visitClassCodeContainer, visitConstructor, visitDeclarationExpression, visitMethod, visitObjectInitializerStatements, visitStatement
Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
afterSwitchCaseStatementsVisited, 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
visit, visit, visitEmptyExpression, visitListOfExpressions
-
Constructor Details
-
ContextualClassCodeVisitor
public ContextualClassCodeVisitor()
-
-
Method Details
-
getTreeContext
-
getLastContext
-
pushContext
-
popContext
-
pushContext
-
visitClass
Description copied from interface:GroovyClassVisitor
Visit a ClassNode.- Specified by:
visitClass
in interfaceGroovyClassVisitor
- Overrides:
visitClass
in classClassCodeVisitorSupport
-
visitPackage
- Overrides:
visitPackage
in classClassCodeVisitorSupport
-
visitImports
- Overrides:
visitImports
in classClassCodeVisitorSupport
-
visitConstructorOrMethod
- Overrides:
visitConstructorOrMethod
in classClassCodeVisitorSupport
-
visitField
Description copied from interface:GroovyClassVisitor
Visit a FieldNode.- Specified by:
visitField
in interfaceGroovyClassVisitor
- Overrides:
visitField
in classClassCodeVisitorSupport
-
visitProperty
Description copied from interface:GroovyClassVisitor
Visit a PropertyNode.- Specified by:
visitProperty
in interfaceGroovyClassVisitor
- Overrides:
visitProperty
in classClassCodeVisitorSupport
-
visitMethodCallExpression
- Specified by:
visitMethodCallExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMethodCallExpression
in classCodeVisitorSupport
-
visitStaticMethodCallExpression
- Specified by:
visitStaticMethodCallExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitStaticMethodCallExpression
in classCodeVisitorSupport
-
visitConstructorCallExpression
- Specified by:
visitConstructorCallExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitConstructorCallExpression
in classCodeVisitorSupport
-
visitBinaryExpression
- Specified by:
visitBinaryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBinaryExpression
in classCodeVisitorSupport
-
visitTernaryExpression
- Specified by:
visitTernaryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitTernaryExpression
in classCodeVisitorSupport
-
visitShortTernaryExpression
- Specified by:
visitShortTernaryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitShortTernaryExpression
in classCodeVisitorSupport
-
visitPostfixExpression
- Specified by:
visitPostfixExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitPostfixExpression
in classCodeVisitorSupport
-
visitPrefixExpression
- Specified by:
visitPrefixExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitPrefixExpression
in classCodeVisitorSupport
-
visitBooleanExpression
- Specified by:
visitBooleanExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBooleanExpression
in classCodeVisitorSupport
-
visitNotExpression
- Specified by:
visitNotExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitNotExpression
in classCodeVisitorSupport
-
visitClosureExpression
- Specified by:
visitClosureExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClosureExpression
in classClassCodeVisitorSupport
-
visitTupleExpression
- Specified by:
visitTupleExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitTupleExpression
in classCodeVisitorSupport
-
visitListExpression
- Specified by:
visitListExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitListExpression
in classCodeVisitorSupport
-
visitArrayExpression
- Specified by:
visitArrayExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitArrayExpression
in classCodeVisitorSupport
-
visitMapExpression
- Specified by:
visitMapExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMapExpression
in classCodeVisitorSupport
-
visitMapEntryExpression
- Specified by:
visitMapEntryExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMapEntryExpression
in classCodeVisitorSupport
-
visitRangeExpression
- Specified by:
visitRangeExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitRangeExpression
in classCodeVisitorSupport
-
visitSpreadExpression
- Specified by:
visitSpreadExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitSpreadExpression
in classCodeVisitorSupport
-
visitSpreadMapExpression
- Specified by:
visitSpreadMapExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitSpreadMapExpression
in classCodeVisitorSupport
-
visitMethodPointerExpression
- Specified by:
visitMethodPointerExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitMethodPointerExpression
in classCodeVisitorSupport
-
visitUnaryMinusExpression
- Specified by:
visitUnaryMinusExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitUnaryMinusExpression
in classCodeVisitorSupport
-
visitUnaryPlusExpression
- Specified by:
visitUnaryPlusExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitUnaryPlusExpression
in classCodeVisitorSupport
-
visitBitwiseNegationExpression
- Specified by:
visitBitwiseNegationExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBitwiseNegationExpression
in classCodeVisitorSupport
-
visitCastExpression
- Specified by:
visitCastExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitCastExpression
in classCodeVisitorSupport
-
visitConstantExpression
- Specified by:
visitConstantExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitConstantExpression
in classCodeVisitorSupport
-
visitClassExpression
- Specified by:
visitClassExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClassExpression
in classCodeVisitorSupport
-
visitVariableExpression
- Specified by:
visitVariableExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitVariableExpression
in classCodeVisitorSupport
-
visitPropertyExpression
- Specified by:
visitPropertyExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitPropertyExpression
in classCodeVisitorSupport
-
visitAttributeExpression
- Specified by:
visitAttributeExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitAttributeExpression
in classCodeVisitorSupport
-
visitFieldExpression
- Specified by:
visitFieldExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitFieldExpression
in classCodeVisitorSupport
-
visitGStringExpression
- Specified by:
visitGStringExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitGStringExpression
in classCodeVisitorSupport
-
visitClosureListExpression
- Specified by:
visitClosureListExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClosureListExpression
in classCodeVisitorSupport
-
visitBytecodeExpression
- Specified by:
visitBytecodeExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitBytecodeExpression
in classCodeVisitorSupport
-
visitAssertStatement
- Specified by:
visitAssertStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitAssertStatement
in classClassCodeVisitorSupport
-
visitBlockStatement
- Specified by:
visitBlockStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitBlockStatement
in classClassCodeVisitorSupport
-
visitBreakStatement
- Specified by:
visitBreakStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitBreakStatement
in classClassCodeVisitorSupport
-
visitCaseStatement
- Specified by:
visitCaseStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitCaseStatement
in classClassCodeVisitorSupport
-
visitCatchStatement
- Specified by:
visitCatchStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitCatchStatement
in classClassCodeVisitorSupport
-
visitContinueStatement
- Specified by:
visitContinueStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitContinueStatement
in classClassCodeVisitorSupport
-
visitDoWhileLoop
- Specified by:
visitDoWhileLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitDoWhileLoop
in classClassCodeVisitorSupport
-
visitExpressionStatement
- Specified by:
visitExpressionStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitExpressionStatement
in classClassCodeVisitorSupport
-
visitForLoop
- Specified by:
visitForLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitForLoop
in classClassCodeVisitorSupport
-
visitIfElse
- Specified by:
visitIfElse
in interfaceGroovyCodeVisitor
- Overrides:
visitIfElse
in classClassCodeVisitorSupport
-
visitReturnStatement
- Specified by:
visitReturnStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitReturnStatement
in classClassCodeVisitorSupport
-
visitSwitch
- Specified by:
visitSwitch
in interfaceGroovyCodeVisitor
- Overrides:
visitSwitch
in classClassCodeVisitorSupport
-
visitSynchronizedStatement
- Specified by:
visitSynchronizedStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitSynchronizedStatement
in classClassCodeVisitorSupport
-
visitThrowStatement
- Specified by:
visitThrowStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitThrowStatement
in classClassCodeVisitorSupport
-
visitTryCatchFinally
- Specified by:
visitTryCatchFinally
in interfaceGroovyCodeVisitor
- Overrides:
visitTryCatchFinally
in classClassCodeVisitorSupport
-
visitWhileLoop
- Specified by:
visitWhileLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitWhileLoop
in classClassCodeVisitorSupport
-
visitEmptyStatement
- Specified by:
visitEmptyStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitEmptyStatement
in classCodeVisitorSupport
-
getTreePath
-
pathMatches
-
pathUpTo
-
pathUpTo
-
pathUpTo
-
matchByClass
-