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.

  Authors:
    Cedric Champeau
  Since:
    2.5.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ContextualClassCodeVisitor ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `TreeContext` | `getLastContext()`
    `` | `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)`
    `` | `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)`
    `` | `protected 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, 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` | `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, visitListExpression, visitListOfExpressions, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Constructor Detail

    - #### public ContextualClassCodeVisitor()

  - ### Method Detail

    - #### public TreeContext getLastContext()

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

    - #### @Override public void visitArrayExpression(ArrayExpression expression)

    - #### @Override public void visitAssertStatement(AssertStatement statement)

    - #### @Override public void visitAttributeExpression(AttributeExpression expression)

    - #### @Override public void visitBinaryExpression(BinaryExpression expression)

    - #### @Override public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)

    - #### @Override public void visitBlockStatement(BlockStatement block)

    - #### @Override public void visitBooleanExpression(BooleanExpression expression)

    - #### @Override public void visitBreakStatement(BreakStatement statement)

    - #### @Override public void visitBytecodeExpression(BytecodeExpression cle)

    - #### @Override public void visitCaseStatement(CaseStatement statement)

    - #### @Override public void visitCastExpression(CastExpression expression)

    - #### @Override public void visitCatchStatement(CatchStatement statement)

    - #### @Override public void visitClass(ClassNode node)

    - #### @Override public void visitClassExpression(ClassExpression expression)

    - #### @Override public void visitClosureExpression(ClosureExpression expression)

    - #### @Override public void visitClosureListExpression(ClosureListExpression cle)

    - #### @Override public void visitConstantExpression(ConstantExpression expression)

    - #### @Override public void visitConstructorCallExpression(ConstructorCallExpression call)

    - #### @Override protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)

    - #### @Override public void visitContinueStatement(ContinueStatement statement)

    - #### @Override public void visitDoWhileLoop(DoWhileStatement loop)

    - #### @Override protected void visitEmptyStatement(EmptyStatement statement)

    - #### @Override public void visitExpressionStatement(ExpressionStatement statement)

    - #### @Override public void visitField(FieldNode node)

    - #### @Override public void visitFieldExpression(FieldExpression expression)

    - #### @Override public void visitForLoop(ForStatement forLoop)

    - #### @Override public void visitGStringExpression(GStringExpression expression)

    - #### @Override public void visitIfElse(IfStatement ifElse)

    - #### @Override public void visitImports(ModuleNode node)

    - #### @Override public void visitListExpression(ListExpression expression)

    - #### @Override public void visitMapEntryExpression(MapEntryExpression expression)

    - #### @Override public void visitMapExpression(MapExpression expression)

    - #### @Override public void visitMethodCallExpression(MethodCallExpression call)

    - #### @Override public void visitMethodPointerExpression(MethodPointerExpression expression)

    - #### @Override public void visitNotExpression(NotExpression expression)

    - #### @Override public void visitPackage(PackageNode node)

    - #### @Override public void visitPostfixExpression(PostfixExpression expression)

    - #### @Override public void visitPrefixExpression(PrefixExpression expression)

    - #### @Override public void visitProperty(PropertyNode node)

    - #### @Override public void visitPropertyExpression(PropertyExpression expression)

    - #### @Override public void visitRangeExpression(RangeExpression expression)

    - #### @Override public void visitReturnStatement(ReturnStatement statement)

    - #### @Override public void visitShortTernaryExpression(ElvisOperatorExpression expression)

    - #### @Override public void visitSpreadExpression(SpreadExpression expression)

    - #### @Override public void visitSpreadMapExpression(SpreadMapExpression expression)

    - #### @Override public void visitStaticMethodCallExpression(StaticMethodCallExpression call)

    - #### @Override public void visitSwitch(SwitchStatement statement)

    - #### @Override public void visitSynchronizedStatement(SynchronizedStatement statement)

    - #### @Override public void visitTernaryExpression(TernaryExpression expression)

    - #### @Override public void visitThrowStatement(ThrowStatement statement)

    - #### @Override public void visitTryCatchFinally(TryCatchStatement statement)

    - #### @Override public void visitTupleExpression(TupleExpression expression)

    - #### @Override public void visitUnaryMinusExpression(UnaryMinusExpression expression)

    - #### @Override public void visitUnaryPlusExpression(UnaryPlusExpression expression)

    - #### @Override public void visitVariableExpression(VariableExpression expression)

    - #### @Override public void visitWhileLoop(WhileStatement loop)