Package: org.codehaus.groovy.macro.matcher

## [Java] Class ContextualClassCodeVisitor

- org.codehaus.groovy.macro.matcher.ContextualClassCodeVisitor

- 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 and description
    `ContextualClassCodeVisitor ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `TreeContext` | `getLastContext()`
    `` | `protected SourceUnit` | `getSourceUnit()`
    `` | `TreeContext` | `getTreeContext()`
    `` | `List<TreeContext>` | `getTreePath()`
    `` | `static List<ASTNodePredicate>` | `matchByClass(Class<ASTNode> classes)`
    `` | `List<TreeContext>` | `pathMatches(List<ASTNodePredicate> predicates)`
    `` | `List<TreeContext>` | `pathUpTo(ASTNodePredicate predicate)`
    `` | `List<TreeContext>` | `pathUpTo(Class<ASTNode> node)`
    `` | `List<TreeContext>` | `pathUpTo(Class<ASTNode> node, ASTNodePredicate predicate)`
    `` | `protected TreeContext` | `popContext()`
    `` | `protected void` | `pushContext(TreeContext ctx)`
    `` | `protected void` | `pushContext(ASTNode node)`
    `` | `Expression` | `transform(Expression exp)`
    `` | `void` | `visitArrayExpression(ArrayExpression expression)`
    `` | `void` | `visitAssertStatement(AssertStatement statement)`
    `` | `void` | `visitAttributeExpression(AttributeExpression expression)`
    `` | `void` | `visitBinaryExpression(BinaryExpression expression)`
    `` | `void` | `visitBitwiseNegationExpression(BitwiseNegationExpression expression)`
    `` | `void` | `visitBlockStatement(BlockStatement block)`
    `` | `void` | `visitBooleanExpression(BooleanExpression expression)`
    `` | `void` | `visitBreakStatement(BreakStatement statement)`
    `` | `void` | `visitBytecodeExpression(BytecodeExpression cle)`
    `` | `void` | `visitCaseStatement(CaseStatement statement)`
    `` | `void` | `visitCastExpression(CastExpression expression)`
    `` | `void` | `visitCatchStatement(CatchStatement statement)`
    `` | `void` | `visitClass(ClassNode node)`
    `` | `void` | `visitClassExpression(ClassExpression expression)`
    `` | `void` | `visitClosureExpression(ClosureExpression expression)`
    `` | `void` | `visitClosureListExpression(ClosureListExpression cle)`
    `` | `void` | `visitConstantExpression(ConstantExpression expression)`
    `` | `void` | `visitConstructorCallExpression(ConstructorCallExpression call)`
    `` | `protected void` | `visitConstructorOrMethod(MethodNode node, boolean isConstructor)`
    `` | `void` | `visitContinueStatement(ContinueStatement statement)`
    `` | `void` | `visitDoWhileLoop(DoWhileStatement loop)`
    `` | `void` | `visitEmptyStatement(EmptyStatement statement)`
    `` | `void` | `visitExpressionStatement(ExpressionStatement statement)`
    `` | `void` | `visitField(FieldNode node)`
    `` | `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` | `visitMethodCallExpression(MethodCallExpression call)`
    `` | `void` | `visitMethodPointerExpression(MethodPointerExpression expression)`
    `` | `void` | `visitNotExpression(NotExpression expression)`
    `` | `void` | `visitPackage(PackageNode node)`
    `` | `void` | `visitPostfixExpression(PostfixExpression expression)`
    `` | `void` | `visitPrefixExpression(PrefixExpression expression)`
    `` | `void` | `visitProperty(PropertyNode node)`
    `` | `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` | `visitStaticMethodCallExpression(StaticMethodCallExpression call)`
    `` | `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)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassCodeVisitorSupport` | `addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`
    `class CodeVisitorSupport` | `afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`

- - ### Constructor Detail

    - #### public ContextualClassCodeVisitor()

  - ### Method Detail

    - #### public TreeContext getLastContext()

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride protected SourceUnit getSourceUnit()

    - #### public TreeContext getTreeContext()

    - #### public List<TreeContext> getTreePath()

    - #### public static List<ASTNodePredicate> matchByClass(Class<ASTNode> classes)

    - #### public List<TreeContext> pathMatches(List<ASTNodePredicate> predicates)

    - #### public List<TreeContext> pathUpTo(ASTNodePredicate predicate)

    - #### public List<TreeContext> pathUpTo(Class<ASTNode> node)

    - #### public List<TreeContext> pathUpTo(Class<ASTNode> node, ASTNodePredicate predicate)

    - #### protected TreeContext popContext()

    - #### protected void pushContext(TreeContext ctx)

    - #### protected void pushContext(ASTNode node)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public Expression transform(Expression exp)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitArrayExpression(ArrayExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitAssertStatement(AssertStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitAttributeExpression(AttributeExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitBinaryExpression(BinaryExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitBlockStatement(BlockStatement block)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitBooleanExpression(BooleanExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitBreakStatement(BreakStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitBytecodeExpression(BytecodeExpression cle)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitCaseStatement(CaseStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitCastExpression(CastExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitCatchStatement(CatchStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitClass(ClassNode node)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitClassExpression(ClassExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitClosureExpression(ClosureExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitClosureListExpression(ClosureListExpression cle)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitConstantExpression(ConstantExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitConstructorCallExpression(ConstructorCallExpression call)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitContinueStatement(ContinueStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitDoWhileLoop(DoWhileStatement loop)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitEmptyStatement(EmptyStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitExpressionStatement(ExpressionStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitField(FieldNode node)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitFieldExpression(FieldExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitForLoop(ForStatement forLoop)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitGStringExpression(GStringExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitIfElse(IfStatement ifElse)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitImports(ModuleNode node)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitListExpression(ListExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitMapEntryExpression(MapEntryExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitMapExpression(MapExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitMethodCallExpression(MethodCallExpression call)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitMethodPointerExpression(MethodPointerExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitNotExpression(NotExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitPackage(PackageNode node)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitPostfixExpression(PostfixExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitPrefixExpression(PrefixExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitProperty(PropertyNode node)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitPropertyExpression(PropertyExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitRangeExpression(RangeExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitReturnStatement(ReturnStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitShortTernaryExpression(ElvisOperatorExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitSpreadExpression(SpreadExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitSpreadMapExpression(SpreadMapExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitStaticMethodCallExpression(StaticMethodCallExpression call)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitSwitch(SwitchStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitSynchronizedStatement(SynchronizedStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitTernaryExpression(TernaryExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitThrowStatement(ThrowStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitTryCatchFinally(TryCatchStatement statement)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitTupleExpression(TupleExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitUnaryMinusExpression(UnaryMinusExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitUnaryPlusExpression(UnaryPlusExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitVariableExpression(VariableExpression expression)

    - #### @com.github.javaparser.ast.expr.MarkerAnnotationExprOverride public void visitWhileLoop(WhileStatement loop)