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()`
  Creates a visitor with an initial root context.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `TreeContext`
  `getLastContext()`
  Returns the most recently popped traversal context.
  `TreeContext`
  `getTreeContext()`
  Returns the current traversal context.
  `List<TreeContext>`
  `getTreePath()`
  Returns the current traversal path, starting with the last completed context.
  `static List<ASTNodePredicate>`
  `matchByClass(Class<ASTNode>... classes)`
  Creates class-based predicates for the supplied AST node classes.
  `List<TreeContext>`
  `pathMatches(List<ASTNodePredicate> predicates)`
  Returns the current path when all supplied predicates match successive parents.
  `List<TreeContext>`
  `pathUpTo(Class<ASTNode> node)`
  Returns the path up to the first node whose class matches `node`.
  `List<TreeContext>`
  `pathUpTo(Class<ASTNode> node, ASTNodePredicate predicate)`
  Returns the path up to the first node that matches the supplied class and predicate.
  `List<TreeContext>`
  `pathUpTo(ASTNodePredicate predicate)`
  Returns the path up to the first node matching the supplied predicate.
  `protected TreeContext`
  `popContext()`
  Pops the current traversal context.
  `protected void`
  `pushContext(ASTNode node)`
  Pushes a child context for the supplied AST node.
  `protected void`
  `pushContext(TreeContext ctx)`
  Pushes an explicit traversal context.
  `void`
  `visitArrayExpression(ArrayExpression expression)`
  Visits an array expression while tracking traversal context.
  `void`
  `visitAssertStatement(AssertStatement statement)`
  Visits an assert statement while tracking traversal context.
  `void`
  `visitAttributeExpression(AttributeExpression expression)`
  Visits an attribute expression while tracking traversal context.
  `void`
  `visitBinaryExpression(BinaryExpression expression)`
  Visits a binary expression while tracking traversal context.
  `void`
  `visitBitwiseNegationExpression(BitwiseNegationExpression expression)`
  Visits a bitwise-negation expression while tracking traversal context.
  `void`
  `visitBlockStatement(BlockStatement block)`
  Visits a block statement while tracking traversal context.
  `void`
  `visitBooleanExpression(BooleanExpression expression)`
  Visits a boolean expression while tracking traversal context.
  `void`
  `visitBreakStatement(BreakStatement statement)`
  Visits a break statement while tracking traversal context.
  `void`
  `visitBytecodeExpression(BytecodeExpression cle)`
  Visits a bytecode expression while tracking traversal context.
  `void`
  `visitCaseStatement(CaseStatement statement)`
  Visits a case statement while tracking traversal context.
  `void`
  `visitCastExpression(CastExpression expression)`
  Visits a cast expression while tracking traversal context.
  `void`
  `visitCatchStatement(CatchStatement statement)`
  Visits a catch statement while tracking traversal context.
  `void`
  `visitClass(ClassNode node)`
  Visits a class node while tracking traversal context.
  `void`
  `visitClassExpression(ClassExpression expression)`
  Visits a class expression while tracking traversal context.
  `void`
  `visitClosureExpression(ClosureExpression expression)`
  Visits a closure expression while tracking traversal context.
  `void`
  `visitClosureListExpression(ClosureListExpression cle)`
  Visits a closure-list expression while tracking traversal context.
  `void`
  `visitConstantExpression(ConstantExpression expression)`
  Visits a constant expression while tracking traversal context.
  `void`
  `visitConstructorCallExpression(ConstructorCallExpression call)`
  Visits a constructor call expression while tracking traversal context.
  `protected void`
  `visitConstructorOrMethod(MethodNode node, boolean isConstructor)`
  Visits a constructor or method while tracking traversal context.
  `void`
  `visitContinueStatement(ContinueStatement statement)`
  Visits a continue statement while tracking traversal context.
  `void`
  `visitDoWhileLoop(DoWhileStatement loop)`
  Visits a do-while loop while tracking traversal context.
  `void`
  `visitEmptyStatement(EmptyStatement statement)`
  Visits an empty statement while tracking traversal context.
  `void`
  `visitExpressionStatement(ExpressionStatement statement)`
  Visits an expression statement while tracking traversal context.
  `void`
  `visitField(FieldNode node)`
  Visits a field node while tracking traversal context.
  `void`
  `visitFieldExpression(FieldExpression expression)`
  Visits a field expression while tracking traversal context.
  `void`
  `visitForLoop(ForStatement forLoop)`
  Visits a for loop while tracking traversal context.
  `void`
  `visitGStringExpression(GStringExpression expression)`
  Visits a GString expression while tracking traversal context.
  `void`
  `visitIfElse(IfStatement ifElse)`
  Visits an if/else statement while tracking traversal context.
  `void`
  `visitImports(ModuleNode node)`
  Visits module imports while tracking traversal context.
  `void`
  `visitListExpression(ListExpression expression)`
  Visits a list expression while tracking traversal context.
  `void`
  `visitMapEntryExpression(MapEntryExpression expression)`
  Visits a map-entry expression while tracking traversal context.
  `void`
  `visitMapExpression(MapExpression expression)`
  Visits a map expression while tracking traversal context.
  `void`
  `visitMethodCallExpression(MethodCallExpression call)`
  Visits a method call expression while tracking traversal context.
  `void`
  `visitMethodPointerExpression(MethodPointerExpression expression)`
  Visits a method-pointer expression while tracking traversal context.
  `void`
  `visitNotExpression(NotExpression expression)`
  Visits a not expression while tracking traversal context.
  `void`
  `visitPackage(PackageNode node)`
  Visits a package node while tracking traversal context.
  `void`
  `visitPostfixExpression(PostfixExpression expression)`
  Visits a postfix expression while tracking traversal context.
  `void`
  `visitPrefixExpression(PrefixExpression expression)`
  Visits a prefix expression while tracking traversal context.
  `void`
  `visitProperty(PropertyNode node)`
  Visits a property node while tracking traversal context.
  `void`
  `visitPropertyExpression(PropertyExpression expression)`
  Visits a property expression while tracking traversal context.
  `void`
  `visitRangeExpression(RangeExpression expression)`
  Visits a range expression while tracking traversal context.
  `void`
  `visitReturnStatement(ReturnStatement statement)`
  Visits a return statement while tracking traversal context.
  `void`
  `visitShortTernaryExpression(ElvisOperatorExpression expression)`
  Visits an Elvis expression while tracking traversal context.
  `void`
  `visitSpreadExpression(SpreadExpression expression)`
  Visits a spread expression while tracking traversal context.
  `void`
  `visitSpreadMapExpression(SpreadMapExpression expression)`
  Visits a spread-map expression while tracking traversal context.
  `void`
  `visitStaticMethodCallExpression(StaticMethodCallExpression call)`
  Visits a static method call expression while tracking traversal context.
  `void`
  `visitSwitch(SwitchStatement statement)`
  Visits a switch statement while tracking traversal context.
  `void`
  `visitSwitchExpression(SwitchExpression expression)`
  Visits a first-class switch expression while tracking traversal context (GROOVY-12255).
  `void`
  `visitSynchronizedStatement(SynchronizedStatement statement)`
  Visits a synchronized statement while tracking traversal context.
  `void`
  `visitTernaryExpression(TernaryExpression expression)`
  Visits a ternary expression while tracking traversal context.
  `void`
  `visitThrowStatement(ThrowStatement statement)`
  Visits a throw statement while tracking traversal context.
  `void`
  `visitTryCatchFinally(TryCatchStatement statement)`
  Visits a try/catch/finally statement while tracking traversal context.
  `void`
  `visitTupleExpression(TupleExpression expression)`
  Visits a tuple expression while tracking traversal context.
  `void`
  `visitUnaryMinusExpression(UnaryMinusExpression expression)`
  Visits a unary-minus expression while tracking traversal context.
  `void`
  `visitUnaryPlusExpression(UnaryPlusExpression expression)`
  Visits a unary-plus expression while tracking traversal context.
  `void`
  `visitVariableExpression(VariableExpression expression)`
  Visits a variable expression while tracking traversal context.
  `void`
  `visitWhileLoop(WhileStatement loop)`
  Visits a while loop while tracking traversal context.
  `void`
  `visitYieldStatement(YieldStatement statement)`
  Visits a yield statement while tracking traversal context (GROOVY-12255).

  ### Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport

  `addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAnnotations, visitClassCodeContainer, visitConstructor, visitDeclarationExpression, visitMethod, visitObjectInitializerStatements, visitStatement, visitStatementAnnotations`

  ### Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

  `afterSwitchCaseStatementsVisited, afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, 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()
    Creates a visitor with an initial root context.

- ## Method Details

  - ### getTreeContext

    public TreeContext getTreeContext()
    Returns the current traversal context.
    Returns:
      the current context, or `null`

  - ### getLastContext

    public TreeContext getLastContext()
    Returns the most recently popped traversal context.
    Returns:
      the last completed context

  - ### pushContext

    protected void pushContext(TreeContext ctx)
    Pushes an explicit traversal context.
    Parameters:
      `ctx` - the context to push

  - ### popContext

    protected TreeContext popContext()
    Pops the current traversal context.
    Returns:
      the popped context

  - ### pushContext

    protected void pushContext(ASTNode node)
    Pushes a child context for the supplied AST node.
    Parameters:
      `node` - the node to enter

  - ### visitClass

    public void visitClass(ClassNode node)
    Visits a class node while tracking traversal context.
    Specified by:
      `visitClass` in interface `GroovyClassVisitor`
    Overrides:
      `visitClass` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the class node to visit

  - ### visitPackage

    public void visitPackage(PackageNode node)
    Visits a package node while tracking traversal context.
    Overrides:
      `visitPackage` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the package node, may be null

  - ### visitImports

    public void visitImports(ModuleNode node)
    Visits module imports while tracking traversal context.
    Overrides:
      `visitImports` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the module node containing imports, may be null

  - ### visitConstructorOrMethod

    protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
    Visits a constructor or method while tracking traversal context.
    Overrides:
      `visitConstructorOrMethod` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the method or constructor node
      `isConstructor` - true if node is a constructor, false if it is a method

  - ### visitField

    public void visitField(FieldNode node)
    Visits a field node while tracking traversal context.
    Specified by:
      `visitField` in interface `GroovyClassVisitor`
    Overrides:
      `visitField` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the field node to visit

  - ### visitProperty

    public void visitProperty(PropertyNode node)
    Visits a property node while tracking traversal context.
    Specified by:
      `visitProperty` in interface `GroovyClassVisitor`
    Overrides:
      `visitProperty` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the property node to visit

  - ### visitMethodCallExpression

    public void visitMethodCallExpression(MethodCallExpression call)
    Visits a method call expression while tracking traversal context.
    Specified by:
      `visitMethodCallExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitMethodCallExpression` in class `CodeVisitorSupport`
    Parameters:
      `call` - the method call expression

  - ### visitStaticMethodCallExpression

    public void visitStaticMethodCallExpression(StaticMethodCallExpression call)
    Visits a static method call expression while tracking traversal context.
    Specified by:
      `visitStaticMethodCallExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitStaticMethodCallExpression` in class `CodeVisitorSupport`
    Parameters:
      `call` - the static method call expression

  - ### visitConstructorCallExpression

    public void visitConstructorCallExpression(ConstructorCallExpression call)
    Visits a constructor call expression while tracking traversal context.
    Specified by:
      `visitConstructorCallExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitConstructorCallExpression` in class `CodeVisitorSupport`
    Parameters:
      `call` - the constructor call expression

  - ### visitBinaryExpression

    public void visitBinaryExpression(BinaryExpression expression)
    Visits a binary expression while tracking traversal context.
    Specified by:
      `visitBinaryExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitBinaryExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the binary expression

  - ### visitTernaryExpression

    public void visitTernaryExpression(TernaryExpression expression)
    Visits a ternary expression while tracking traversal context.
    Specified by:
      `visitTernaryExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitTernaryExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the ternary expression

  - ### visitShortTernaryExpression

    public void visitShortTernaryExpression(ElvisOperatorExpression expression)
    Visits an Elvis expression while tracking traversal context.
    Specified by:
      `visitShortTernaryExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitShortTernaryExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the elvis operator expression

  - ### visitPostfixExpression

    public void visitPostfixExpression(PostfixExpression expression)
    Visits a postfix expression while tracking traversal context.
    Specified by:
      `visitPostfixExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitPostfixExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the postfix expression

  - ### visitPrefixExpression

    public void visitPrefixExpression(PrefixExpression expression)
    Visits a prefix expression while tracking traversal context.
    Specified by:
      `visitPrefixExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitPrefixExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the prefix expression

  - ### visitBooleanExpression

    public void visitBooleanExpression(BooleanExpression expression)
    Visits a boolean expression while tracking traversal context.
    Specified by:
      `visitBooleanExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitBooleanExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the boolean expression

  - ### visitNotExpression

    public void visitNotExpression(NotExpression expression)
    Visits a not expression while tracking traversal context.
    Specified by:
      `visitNotExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitNotExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the not expression

  - ### visitClosureExpression

    public void visitClosureExpression(ClosureExpression expression)
    Visits a closure expression while tracking traversal context.
    Specified by:
      `visitClosureExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitClosureExpression` in class `ClassCodeVisitorSupport`
    Parameters:
      `expression` - the closure expression to visit

  - ### visitTupleExpression

    public void visitTupleExpression(TupleExpression expression)
    Visits a tuple expression while tracking traversal context.
    Specified by:
      `visitTupleExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitTupleExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the tuple expression

  - ### visitListExpression

    public void visitListExpression(ListExpression expression)
    Visits a list expression while tracking traversal context.
    Specified by:
      `visitListExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitListExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the list expression

  - ### visitArrayExpression

    public void visitArrayExpression(ArrayExpression expression)
    Visits an array expression while tracking traversal context.
    Specified by:
      `visitArrayExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitArrayExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the array expression

  - ### visitMapExpression

    public void visitMapExpression(MapExpression expression)
    Visits a map expression while tracking traversal context.
    Specified by:
      `visitMapExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitMapExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the map expression

  - ### visitMapEntryExpression

    public void visitMapEntryExpression(MapEntryExpression expression)
    Visits a map-entry expression while tracking traversal context.
    Specified by:
      `visitMapEntryExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitMapEntryExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the map entry expression

  - ### visitRangeExpression

    public void visitRangeExpression(RangeExpression expression)
    Visits a range expression while tracking traversal context.
    Specified by:
      `visitRangeExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitRangeExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the range expression

  - ### visitSpreadExpression

    public void visitSpreadExpression(SpreadExpression expression)
    Visits a spread expression while tracking traversal context.
    Specified by:
      `visitSpreadExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitSpreadExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the spread expression

  - ### visitSpreadMapExpression

    public void visitSpreadMapExpression(SpreadMapExpression expression)
    Visits a spread-map expression while tracking traversal context.
    Specified by:
      `visitSpreadMapExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitSpreadMapExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the spread map expression

  - ### visitMethodPointerExpression

    public void visitMethodPointerExpression(MethodPointerExpression expression)
    Visits a method-pointer expression while tracking traversal context.
    Specified by:
      `visitMethodPointerExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitMethodPointerExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the method pointer expression

  - ### visitUnaryMinusExpression

    public void visitUnaryMinusExpression(UnaryMinusExpression expression)
    Visits a unary-minus expression while tracking traversal context.
    Specified by:
      `visitUnaryMinusExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitUnaryMinusExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the unary minus expression

  - ### visitUnaryPlusExpression

    public void visitUnaryPlusExpression(UnaryPlusExpression expression)
    Visits a unary-plus expression while tracking traversal context.
    Specified by:
      `visitUnaryPlusExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitUnaryPlusExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the unary plus expression

  - ### visitBitwiseNegationExpression

    public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)
    Visits a bitwise-negation expression while tracking traversal context.
    Specified by:
      `visitBitwiseNegationExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitBitwiseNegationExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the bitwise negation expression

  - ### visitCastExpression

    public void visitCastExpression(CastExpression expression)
    Visits a cast expression while tracking traversal context.
    Specified by:
      `visitCastExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitCastExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the cast expression

  - ### visitConstantExpression

    public void visitConstantExpression(ConstantExpression expression)
    Visits a constant expression while tracking traversal context.
    Specified by:
      `visitConstantExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitConstantExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the constant expression

  - ### visitClassExpression

    public void visitClassExpression(ClassExpression expression)
    Visits a class expression while tracking traversal context.
    Specified by:
      `visitClassExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitClassExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the class expression

  - ### visitVariableExpression

    public void visitVariableExpression(VariableExpression expression)
    Visits a variable expression while tracking traversal context.
    Specified by:
      `visitVariableExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitVariableExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the variable expression

  - ### visitPropertyExpression

    public void visitPropertyExpression(PropertyExpression expression)
    Visits a property expression while tracking traversal context.
    Specified by:
      `visitPropertyExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitPropertyExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the property expression

  - ### visitAttributeExpression

    public void visitAttributeExpression(AttributeExpression expression)
    Visits an attribute expression while tracking traversal context.
    Specified by:
      `visitAttributeExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitAttributeExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the attribute expression

  - ### visitFieldExpression

    public void visitFieldExpression(FieldExpression expression)
    Visits a field expression while tracking traversal context.
    Specified by:
      `visitFieldExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitFieldExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the field expression

  - ### visitGStringExpression

    public void visitGStringExpression(GStringExpression expression)
    Visits a GString expression while tracking traversal context.
    Specified by:
      `visitGStringExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitGStringExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the GString expression

  - ### visitClosureListExpression

    public void visitClosureListExpression(ClosureListExpression cle)
    Visits a closure-list expression while tracking traversal context.
    Specified by:
      `visitClosureListExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitClosureListExpression` in class `CodeVisitorSupport`
    Parameters:
      `cle` - the closure list expression

  - ### visitBytecodeExpression

    public void visitBytecodeExpression(BytecodeExpression cle)
    Visits a bytecode expression while tracking traversal context.
    Specified by:
      `visitBytecodeExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitBytecodeExpression` in class `CodeVisitorSupport`
    Parameters:
      `cle` - the bytecode expression

  - ### visitAssertStatement

    public void visitAssertStatement(AssertStatement statement)
    Visits an assert statement while tracking traversal context.
    Specified by:
      `visitAssertStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitAssertStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the assert statement to visit

  - ### visitBlockStatement

    public void visitBlockStatement(BlockStatement block)
    Visits a block statement while tracking traversal context.
    Specified by:
      `visitBlockStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitBlockStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `block` - the block statement to visit
    See Also:
      - `CodeVisitorSupport.visitForLoop(ForStatement)`
      - `CodeVisitorSupport.visitWhileLoop(WhileStatement)`

  - ### visitBreakStatement

    public void visitBreakStatement(BreakStatement statement)
    Visits a break statement while tracking traversal context.
    Specified by:
      `visitBreakStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitBreakStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the break statement to visit

  - ### visitCaseStatement

    public void visitCaseStatement(CaseStatement statement)
    Visits a case statement while tracking traversal context.
    Specified by:
      `visitCaseStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitCaseStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the case statement to visit

  - ### visitCatchStatement

    public void visitCatchStatement(CatchStatement statement)
    Visits a catch statement while tracking traversal context.
    Specified by:
      `visitCatchStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitCatchStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the catch statement to visit

  - ### visitContinueStatement

    public void visitContinueStatement(ContinueStatement statement)
    Visits a continue statement while tracking traversal context.
    Specified by:
      `visitContinueStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitContinueStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the continue statement to visit

  - ### visitDoWhileLoop

    public void visitDoWhileLoop(DoWhileStatement loop)
    Visits a do-while loop while tracking traversal context.
    Specified by:
      `visitDoWhileLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitDoWhileLoop` in class `ClassCodeVisitorSupport`
    Parameters:
      `loop` - the do-while statement to visit

  - ### visitExpressionStatement

    public void visitExpressionStatement(ExpressionStatement statement)
    Visits an expression statement while tracking traversal context.
    Specified by:
      `visitExpressionStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitExpressionStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the expression statement to visit

  - ### visitForLoop

    public void visitForLoop(ForStatement forLoop)
    Visits a for loop while tracking traversal context.
    Specified by:
      `visitForLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitForLoop` in class `ClassCodeVisitorSupport`
    Parameters:
      `forLoop` - the for statement to visit

  - ### visitIfElse

    public void visitIfElse(IfStatement ifElse)
    Visits an if/else statement while tracking traversal context.
    Specified by:
      `visitIfElse` in interface `GroovyCodeVisitor`
    Overrides:
      `visitIfElse` in class `ClassCodeVisitorSupport`
    Parameters:
      `ifElse` - the if statement to visit

  - ### visitReturnStatement

    public void visitReturnStatement(ReturnStatement statement)
    Visits a return statement while tracking traversal context.
    Specified by:
      `visitReturnStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitReturnStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the return statement to visit

  - ### visitSwitch

    public void visitSwitch(SwitchStatement statement)
    Visits a switch statement while tracking traversal context.
    Specified by:
      `visitSwitch` in interface `GroovyCodeVisitor`
    Overrides:
      `visitSwitch` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the switch statement to visit

  - ### visitSwitchExpression

    public void visitSwitchExpression(SwitchExpression expression)
    Visits a first-class switch expression while tracking traversal context (GROOVY-12255).
    Specified by:
      `visitSwitchExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitSwitchExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the switch expression

  - ### visitYieldStatement

    public void visitYieldStatement(YieldStatement statement)
    Visits a yield statement while tracking traversal context (GROOVY-12255).
    Specified by:
      `visitYieldStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitYieldStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the yield statement to visit

  - ### visitSynchronizedStatement

    public void visitSynchronizedStatement(SynchronizedStatement statement)
    Visits a synchronized statement while tracking traversal context.
    Specified by:
      `visitSynchronizedStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitSynchronizedStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the synchronized statement to visit

  - ### visitThrowStatement

    public void visitThrowStatement(ThrowStatement statement)
    Visits a throw statement while tracking traversal context.
    Specified by:
      `visitThrowStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitThrowStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the throw statement to visit

  - ### visitTryCatchFinally

    public void visitTryCatchFinally(TryCatchStatement statement)
    Visits a try/catch/finally statement while tracking traversal context.
    Specified by:
      `visitTryCatchFinally` in interface `GroovyCodeVisitor`
    Overrides:
      `visitTryCatchFinally` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the try-catch statement to visit

  - ### visitWhileLoop

    public void visitWhileLoop(WhileStatement loop)
    Visits a while loop while tracking traversal context.
    Specified by:
      `visitWhileLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitWhileLoop` in class `ClassCodeVisitorSupport`
    Parameters:
      `loop` - the while statement to visit

  - ### visitEmptyStatement

    public void visitEmptyStatement(EmptyStatement statement)
    Visits an empty statement while tracking traversal context.
    Specified by:
      `visitEmptyStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitEmptyStatement` in class `CodeVisitorSupport`
    Parameters:
      `statement` - the empty statement

  - ### getTreePath

    public List<TreeContext> getTreePath()
    Returns the current traversal path, starting with the last completed context.
    Returns:
      the current tree path

  - ### pathMatches

    public List<TreeContext> pathMatches(List<ASTNodePredicate> predicates)
    Returns the current path when all supplied predicates match successive parents.
    Parameters:
      `predicates` - the predicates to match against the path
    Returns:
      the matching path, or an empty list

  - ### pathUpTo

    public List<TreeContext> pathUpTo(ASTNodePredicate predicate)
    Returns the path up to the first node matching the supplied predicate.
    Parameters:
      `predicate` - the predicate that terminates the path
    Returns:
      the matching path, or an empty list

  - ### pathUpTo

    public List<TreeContext> pathUpTo(Class<ASTNode> node)
    Returns the path up to the first node whose class matches `node`.
    Parameters:
      `node` - the node class that terminates the path
    Returns:
      the matching path, or an empty list

  - ### pathUpTo

    public List<TreeContext> pathUpTo(Class<ASTNode> node, ASTNodePredicate predicate)
    Returns the path up to the first node that matches the supplied class and predicate.
    Parameters:
      `node` - the node class that terminates the path, or `null`
      `predicate` - the predicate that terminates the path, or `null`
    Returns:
      the matching path, or an empty list

  - ### matchByClass

    public static List<ASTNodePredicate> matchByClass(Class<ASTNode>... classes)
    Creates class-based predicates for the supplied AST node classes.
    Parameters:
      `classes` - the classes to match
    Returns:
      the corresponding predicates