ContextualClassCodeVisitor (Groovy 3.0.7)

Package org.codehaus.groovy.macro.matcher

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

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `TreeContext` | `getLastContext()` |
    `TreeContext` | `getTreeContext()` |
    `List<TreeContext>` | `getTreePath()` |
    `static List<ASTNodePredicate>` | `matchByClass​(Class<ASTNode>... classes)` |
    `List<TreeContext>` | `pathMatches​(List<ASTNodePredicate> predicates)` |
    `List<TreeContext>` | `pathUpTo​(Class<ASTNode> node)` |
    `List<TreeContext>` | `pathUpTo​(Class<ASTNode> node, ASTNodePredicate predicate)` |
    `List<TreeContext>` | `pathUpTo​(ASTNodePredicate predicate)` |
    `protected TreeContext` | `popContext()` |
    `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` | `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)` | Visit a ClassNode.
    `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)` | 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` | `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)` | 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` | `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)` |

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

- - ### Constructor Detail

    - #### ContextualClassCodeVisitor

          public ContextualClassCodeVisitor()

  - ### 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 interface `GroovyClassVisitor`
      Overrides:
        `visitClass` in class `ClassCodeVisitorSupport`

    - #### visitPackage

          public void visitPackage​(PackageNode node)

      Overrides:
        `visitPackage` in class `ClassCodeVisitorSupport`

    - #### visitImports

          public void visitImports​(ModuleNode node)

      Overrides:
        `visitImports` in class `ClassCodeVisitorSupport`

    - #### visitConstructorOrMethod

          protected void visitConstructorOrMethod​(MethodNode node,
                                                  boolean isConstructor)

      Overrides:
        `visitConstructorOrMethod` in class `ClassCodeVisitorSupport`

    - #### visitField

          public void visitField​(FieldNode node)

      Description copied from interface: `GroovyClassVisitor`
      Visit a FieldNode.
      Specified by:
        `visitField` in interface `GroovyClassVisitor`
      Overrides:
        `visitField` in class `ClassCodeVisitorSupport`

    - #### visitProperty

          public void visitProperty​(PropertyNode node)

      Description copied from interface: `GroovyClassVisitor`
      Visit a PropertyNode.
      Specified by:
        `visitProperty` in interface `GroovyClassVisitor`
      Overrides:
        `visitProperty` in class `ClassCodeVisitorSupport`

    - #### visitMethodCallExpression

          public void visitMethodCallExpression​(MethodCallExpression call)

      Specified by:
        `visitMethodCallExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitMethodCallExpression` in class `CodeVisitorSupport`

    - #### visitStaticMethodCallExpression

          public void visitStaticMethodCallExpression​(StaticMethodCallExpression call)

      Specified by:
        `visitStaticMethodCallExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitStaticMethodCallExpression` in class `CodeVisitorSupport`

    - #### visitConstructorCallExpression

          public void visitConstructorCallExpression​(ConstructorCallExpression call)

      Specified by:
        `visitConstructorCallExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitConstructorCallExpression` in class `CodeVisitorSupport`

    - #### visitBinaryExpression

          public void visitBinaryExpression​(BinaryExpression expression)

      Specified by:
        `visitBinaryExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitBinaryExpression` in class `CodeVisitorSupport`

    - #### visitTernaryExpression

          public void visitTernaryExpression​(TernaryExpression expression)

      Specified by:
        `visitTernaryExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitTernaryExpression` in class `CodeVisitorSupport`

    - #### visitShortTernaryExpression

          public void visitShortTernaryExpression​(ElvisOperatorExpression expression)

      Specified by:
        `visitShortTernaryExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitShortTernaryExpression` in class `CodeVisitorSupport`

    - #### visitPostfixExpression

          public void visitPostfixExpression​(PostfixExpression expression)

      Specified by:
        `visitPostfixExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitPostfixExpression` in class `CodeVisitorSupport`

    - #### visitPrefixExpression

          public void visitPrefixExpression​(PrefixExpression expression)

      Specified by:
        `visitPrefixExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitPrefixExpression` in class `CodeVisitorSupport`

    - #### visitBooleanExpression

          public void visitBooleanExpression​(BooleanExpression expression)

      Specified by:
        `visitBooleanExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitBooleanExpression` in class `CodeVisitorSupport`

    - #### visitNotExpression

          public void visitNotExpression​(NotExpression expression)

      Specified by:
        `visitNotExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitNotExpression` in class `CodeVisitorSupport`

    - #### visitClosureExpression

          public void visitClosureExpression​(ClosureExpression expression)

      Specified by:
        `visitClosureExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitClosureExpression` in class `CodeVisitorSupport`

    - #### visitTupleExpression

          public void visitTupleExpression​(TupleExpression expression)

      Specified by:
        `visitTupleExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitTupleExpression` in class `CodeVisitorSupport`

    - #### visitListExpression

          public void visitListExpression​(ListExpression expression)

      Specified by:
        `visitListExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitListExpression` in class `CodeVisitorSupport`

    - #### visitArrayExpression

          public void visitArrayExpression​(ArrayExpression expression)

      Specified by:
        `visitArrayExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitArrayExpression` in class `CodeVisitorSupport`

    - #### visitMapExpression

          public void visitMapExpression​(MapExpression expression)

      Specified by:
        `visitMapExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitMapExpression` in class `CodeVisitorSupport`

    - #### visitMapEntryExpression

          public void visitMapEntryExpression​(MapEntryExpression expression)

      Specified by:
        `visitMapEntryExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitMapEntryExpression` in class `CodeVisitorSupport`

    - #### visitRangeExpression

          public void visitRangeExpression​(RangeExpression expression)

      Specified by:
        `visitRangeExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitRangeExpression` in class `CodeVisitorSupport`

    - #### visitSpreadExpression

          public void visitSpreadExpression​(SpreadExpression expression)

      Specified by:
        `visitSpreadExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitSpreadExpression` in class `CodeVisitorSupport`

    - #### visitSpreadMapExpression

          public void visitSpreadMapExpression​(SpreadMapExpression expression)

      Specified by:
        `visitSpreadMapExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitSpreadMapExpression` in class `CodeVisitorSupport`

    - #### visitMethodPointerExpression

          public void visitMethodPointerExpression​(MethodPointerExpression expression)

      Specified by:
        `visitMethodPointerExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitMethodPointerExpression` in class `CodeVisitorSupport`

    - #### visitUnaryMinusExpression

          public void visitUnaryMinusExpression​(UnaryMinusExpression expression)

      Specified by:
        `visitUnaryMinusExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitUnaryMinusExpression` in class `CodeVisitorSupport`

    - #### visitUnaryPlusExpression

          public void visitUnaryPlusExpression​(UnaryPlusExpression expression)

      Specified by:
        `visitUnaryPlusExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitUnaryPlusExpression` in class `CodeVisitorSupport`

    - #### visitBitwiseNegationExpression

          public void visitBitwiseNegationExpression​(BitwiseNegationExpression expression)

      Specified by:
        `visitBitwiseNegationExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitBitwiseNegationExpression` in class `CodeVisitorSupport`

    - #### visitCastExpression

          public void visitCastExpression​(CastExpression expression)

      Specified by:
        `visitCastExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitCastExpression` in class `CodeVisitorSupport`

    - #### visitConstantExpression

          public void visitConstantExpression​(ConstantExpression expression)

      Specified by:
        `visitConstantExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitConstantExpression` in class `CodeVisitorSupport`

    - #### visitClassExpression

          public void visitClassExpression​(ClassExpression expression)

      Specified by:
        `visitClassExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitClassExpression` in class `CodeVisitorSupport`

    - #### visitVariableExpression

          public void visitVariableExpression​(VariableExpression expression)

      Specified by:
        `visitVariableExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitVariableExpression` in class `CodeVisitorSupport`

    - #### visitPropertyExpression

          public void visitPropertyExpression​(PropertyExpression expression)

      Specified by:
        `visitPropertyExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitPropertyExpression` in class `CodeVisitorSupport`

    - #### visitAttributeExpression

          public void visitAttributeExpression​(AttributeExpression expression)

      Specified by:
        `visitAttributeExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitAttributeExpression` in class `CodeVisitorSupport`

    - #### visitFieldExpression

          public void visitFieldExpression​(FieldExpression expression)

      Specified by:
        `visitFieldExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitFieldExpression` in class `CodeVisitorSupport`

    - #### visitGStringExpression

          public void visitGStringExpression​(GStringExpression expression)

      Specified by:
        `visitGStringExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitGStringExpression` in class `CodeVisitorSupport`

    - #### visitClosureListExpression

          public void visitClosureListExpression​(ClosureListExpression cle)

      Specified by:
        `visitClosureListExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitClosureListExpression` in class `CodeVisitorSupport`

    - #### visitBytecodeExpression

          public void visitBytecodeExpression​(BytecodeExpression cle)

      Specified by:
        `visitBytecodeExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitBytecodeExpression` in class `CodeVisitorSupport`

    - #### visitAssertStatement

          public void visitAssertStatement​(AssertStatement statement)

      Specified by:
        `visitAssertStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitAssertStatement` in class `ClassCodeVisitorSupport`

    - #### visitBlockStatement

          public void visitBlockStatement​(BlockStatement block)

      Specified by:
        `visitBlockStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitBlockStatement` in class `ClassCodeVisitorSupport`

    - #### visitBreakStatement

          public void visitBreakStatement​(BreakStatement statement)

      Specified by:
        `visitBreakStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitBreakStatement` in class `ClassCodeVisitorSupport`

    - #### visitCaseStatement

          public void visitCaseStatement​(CaseStatement statement)

      Specified by:
        `visitCaseStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitCaseStatement` in class `ClassCodeVisitorSupport`

    - #### visitCatchStatement

          public void visitCatchStatement​(CatchStatement statement)

      Specified by:
        `visitCatchStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitCatchStatement` in class `ClassCodeVisitorSupport`

    - #### visitContinueStatement

          public void visitContinueStatement​(ContinueStatement statement)

      Specified by:
        `visitContinueStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitContinueStatement` in class `ClassCodeVisitorSupport`

    - #### visitDoWhileLoop

          public void visitDoWhileLoop​(DoWhileStatement loop)

      Specified by:
        `visitDoWhileLoop` in interface `GroovyCodeVisitor`
      Overrides:
        `visitDoWhileLoop` in class `ClassCodeVisitorSupport`

    - #### visitExpressionStatement

          public void visitExpressionStatement​(ExpressionStatement statement)

      Specified by:
        `visitExpressionStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitExpressionStatement` in class `ClassCodeVisitorSupport`

    - #### visitForLoop

          public void visitForLoop​(ForStatement forLoop)

      Specified by:
        `visitForLoop` in interface `GroovyCodeVisitor`
      Overrides:
        `visitForLoop` in class `ClassCodeVisitorSupport`

    - #### visitIfElse

          public void visitIfElse​(IfStatement ifElse)

      Specified by:
        `visitIfElse` in interface `GroovyCodeVisitor`
      Overrides:
        `visitIfElse` in class `ClassCodeVisitorSupport`

    - #### visitReturnStatement

          public void visitReturnStatement​(ReturnStatement statement)

      Specified by:
        `visitReturnStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitReturnStatement` in class `ClassCodeVisitorSupport`

    - #### visitSwitch

          public void visitSwitch​(SwitchStatement statement)

      Specified by:
        `visitSwitch` in interface `GroovyCodeVisitor`
      Overrides:
        `visitSwitch` in class `ClassCodeVisitorSupport`

    - #### visitSynchronizedStatement

          public void visitSynchronizedStatement​(SynchronizedStatement statement)

      Specified by:
        `visitSynchronizedStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitSynchronizedStatement` in class `ClassCodeVisitorSupport`

    - #### visitThrowStatement

          public void visitThrowStatement​(ThrowStatement statement)

      Specified by:
        `visitThrowStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitThrowStatement` in class `ClassCodeVisitorSupport`

    - #### visitTryCatchFinally

          public void visitTryCatchFinally​(TryCatchStatement statement)

      Specified by:
        `visitTryCatchFinally` in interface `GroovyCodeVisitor`
      Overrides:
        `visitTryCatchFinally` in class `ClassCodeVisitorSupport`

    - #### visitWhileLoop

          public void visitWhileLoop​(WhileStatement loop)

      Specified by:
        `visitWhileLoop` in interface `GroovyCodeVisitor`
      Overrides:
        `visitWhileLoop` in class `ClassCodeVisitorSupport`

    - #### visitEmptyStatement

          public void visitEmptyStatement​(EmptyStatement statement)

      Specified by:
        `visitEmptyStatement` in interface `GroovyCodeVisitor`
      Overrides:
        `visitEmptyStatement` in class `CodeVisitorSupport`

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