Package org.codehaus.groovy.ast

# Interface GroovyCodeVisitor

All Known Implementing Classes:
  `AbstractInterruptibleASTTransformation`, `AnnotationClosureVisitor`, `AnnotationConstantsVisitor`, `AnnotationContractParameterVisitor`, `AnnotationProcessorVisitor`, `AsmClassGenerator`, `AssertStatementCreationUtility.AddAssertionCallStatementToReturnStatementVisitor`, `AssertStatementCreationUtility.AddResultReturnStatementVisitor`, `AssertStatementCreationUtility.ReturnStatementVisitor`, `ASTTransformationCollectorCodeVisitor`, `ASTTransformationVisitor`, `BaseVisitor`, `ClassCodeExpressionTransformer`, `ClassCodeVisitorSupport`, `ClassCompletionVerifier`, `ClassGenerator`, `ClosureWriter.CorrectAccessedVariableVisitor`, `CodeVisitorSupport`, `ContextualClassCodeVisitor`, `ContractElementVisitor`, `DependencyTracker`, `DomainModelInjectionVisitor`, `DummyClassGenerator`, `DynamicSetterInjectionVisitor`, `EnumCompletionVisitor`, `EnumVisitor`, `ExtendedVerifier`, `FieldASTTransformation`, `FinalVariableAnalyzer`, `GenericsVisitor`, `GinqAstBaseVisitor`, `GinqAstBuilder`, `GrabAnnotationTransformation`, `GroovyCodeVisitorAdapter`, `GroovydocVisitor`, `InnerClassCompletionVisitor`, `InnerClassVisitor`, `InnerClassVisitorHelper`, `InstanceOfVerifier`, `JavaAwareResolveVisitor`, `LabelVerifier`, `LifecycleAfterTransformationVisitor`, `LifecycleBeforeTransformationVisitor`, `MethodInvocationTrap`, `NewifyASTTransformation`, `OperatorRenameASTTransformation`, `OptimizerVisitor`, `PlaceholderVisitor`, `ResolveVisitor`, `ReturnAdderForClosures`, `SecureASTCustomizer.SecuringCodeVisitor`, `SharedVariableCollector`, `SqlWhereVisitor`, `StatementReplacer`, `StaticCompilationTransformer`, `StaticCompilationVisitor`, `StaticImportVisitor`, `StaticTypeCheckingVisitor`, `StaticTypeCheckingVisitor.VariableExpressionTypeMemoizer`, `StaticVerifier`, `TransformingCodeVisitor`, `VariableExpressionReplacer`, `VariableScopeVisitor`, `VerifierCodeVisitor`

public interface GroovyCodeVisitor
Defines the visitor interface for traversing and processing Groovy AST nodes using the visitor pattern. Implementations can perform compilation, transformation, code generation, or analysis by implementing visit methods for specific statement and expression types. The interface provides both required abstract methods and default convenience methods for handling generic collections and null values.

See Also:
  - `Statement`
  - `Expression`
  - `ClassCodeVisitorSupport`
  - `CodeVisitorSupport`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default void`
  `visit(Expression expression)`
  Convenience method to visit an expression if it is not null.
  `default void`
  `visit(Statement statement)`
  Convenience method to visit a statement if it is not null.
  `void`
  `visitArgumentlistExpression(ArgumentListExpression expression)`
  Visits an argument list expression (method arguments).
  `void`
  `visitArrayExpression(ArrayExpression expression)`
  Visits an array expression.
  `void`
  `visitAssertStatement(AssertStatement statement)`
  Visits an assert statement.
  `void`
  `visitAttributeExpression(AttributeExpression expression)`
  Visits an attribute expression (object@property, accessing direct field without getters).
  `void`
  `visitBinaryExpression(BinaryExpression expression)`
  Visits a binary expression (left op right).
  `void`
  `visitBitwiseNegationExpression(BitwiseNegationExpression expression)`
  Visits a bitwise negation expression (~expr).
  `void`
  `visitBlockStatement(BlockStatement statement)`
  Visits a block statement (list of statements enclosed in braces).
  `void`
  `visitBooleanExpression(BooleanExpression expression)`
  Visits a boolean expression.
  `void`
  `visitBreakStatement(BreakStatement statement)`
  Visits a break statement.
  `void`
  `visitBytecodeExpression(BytecodeExpression expression)`
  Visits a bytecode expression (direct JVM bytecode instructions).
  `void`
  `visitCaseStatement(CaseStatement statement)`
  Visits a case clause within a switch statement.
  `void`
  `visitCastExpression(CastExpression expression)`
  Visits a cast expression ((Type) expr).
  `void`
  `visitCatchStatement(CatchStatement statement)`
  Visits a catch clause within a try-catch statement.
  `void`
  `visitClassExpression(ClassExpression expression)`
  Visits a class expression.
  `void`
  `visitClosureExpression(ClosureExpression expression)`
  Visits a closure expression.
  `void`
  `visitClosureListExpression(ClosureListExpression expression)`
  Visits a closure list expression.
  `void`
  `visitConstantExpression(ConstantExpression expression)`
  Visits a constant expression (literal value).
  `void`
  `visitConstructorCallExpression(ConstructorCallExpression expression)`
  Visits a constructor call expression.
  `void`
  `visitContinueStatement(ContinueStatement statement)`
  Visits a continue statement.
  `void`
  `visitDeclarationExpression(DeclarationExpression expression)`
  Visits a declaration expression (variable declaration with initialization).
  `void`
  `visitDoWhileLoop(DoWhileStatement statement)`
  Visits a do-while loop statement.
  `default void`
  `visitEmptyExpression(EmptyExpression expression)`
  Visits an empty expression.
  `default void`
  `visitEmptyStatement(EmptyStatement statement)`
  Visits an empty statement.
  `void`
  `visitExpressionStatement(ExpressionStatement statement)`
  Visits an expression statement (an expression used as a statement).
  `void`
  `visitFieldExpression(FieldExpression expression)`
  Visits a field expression.
  `void`
  `visitForLoop(ForStatement statement)`
  Visits a for loop statement.
  `void`
  `visitGStringExpression(GStringExpression expression)`
  Visits a GString expression (string with interpolations).
  `void`
  `visitIfElse(IfStatement statement)`
  Visits an if-else statement.
  `void`
  `visitLambdaExpression(LambdaExpression expression)`
  Visits a lambda expression.
  `void`
  `visitListExpression(ListExpression expression)`
  Visits a list expression.
  `default void`
  `visitListOfExpressions(List<? extends Expression> list)`
  Convenience method to visit a list of expressions.
  `void`
  `visitMapEntryExpression(MapEntryExpression expression)`
  Visits a map entry expression (key: value pair within a map).
  `void`
  `visitMapExpression(MapExpression expression)`
  Visits a map expression.
  `void`
  `visitMethodCallExpression(MethodCallExpression expression)`
  Visits a method call expression.
  `void`
  `visitMethodPointerExpression(MethodPointerExpression expression)`
  Visits a method pointer expression (`object.&methodName`).
  `void`
  `visitMethodReferenceExpression(MethodReferenceExpression expression)`
  Visits a method reference expression (obj::method).
  `void`
  `visitNotExpression(NotExpression expression)`
  Visits a not expression (!expr).
  `void`
  `visitPostfixExpression(PostfixExpression expression)`
  Visits a postfix expression (expr op).
  `void`
  `visitPrefixExpression(PrefixExpression expression)`
  Visits a prefix expression (op expr).
  `void`
  `visitPropertyExpression(PropertyExpression expression)`
  Visits a property expression (object.property).
  `void`
  `visitRangeExpression(RangeExpression expression)`
  Visits a range expression.
  `void`
  `visitReturnStatement(ReturnStatement statement)`
  Visits a return statement.
  `void`
  `visitShortTernaryExpression(ElvisOperatorExpression expression)`
  Visits an Elvis operator expression (shorthand ternary with implicit condition check).
  `void`
  `visitSpreadExpression(SpreadExpression expression)`
  Visits a spread expression (*expr, spreading collection elements).
  `void`
  `visitSpreadMapExpression(SpreadMapExpression expression)`
  Visits a spread map expression (*:map, spreading map entries).
  `void`
  `visitStaticMethodCallExpression(StaticMethodCallExpression expression)`
  Visits a static method call expression.
  `void`
  `visitSwitch(SwitchStatement statement)`
  Visits a switch statement.
  `void`
  `visitSynchronizedStatement(SynchronizedStatement statement)`
  Visits a synchronized statement.
  `void`
  `visitTernaryExpression(TernaryExpression expression)`
  Visits a ternary expression (condition ? trueExpr : falseExpr).
  `void`
  `visitThrowStatement(ThrowStatement statement)`
  Visits a throw statement.
  `void`
  `visitTryCatchFinally(TryCatchStatement statement)`
  Visits a try-catch-finally statement.
  `void`
  `visitTupleExpression(TupleExpression expression)`
  Visits a tuple expression (comma-separated expressions grouped in parentheses).
  `void`
  `visitUnaryMinusExpression(UnaryMinusExpression expression)`
  Visits a unary minus expression (-expr).
  `void`
  `visitUnaryPlusExpression(UnaryPlusExpression expression)`
  Visits a unary plus expression (+expr).
  `void`
  `visitVariableExpression(VariableExpression expression)`
  Visits a variable expression.
  `void`
  `visitWhileLoop(WhileStatement statement)`
  Visits a while loop statement.

- ## Method Details

  - ### visitBlockStatement

    void visitBlockStatement(BlockStatement statement)
    Visits a block statement (list of statements enclosed in braces).
    Parameters:
      `statement` - the `BlockStatement` to process

  - ### visitForLoop

    void visitForLoop(ForStatement statement)
    Visits a for loop statement.
    Parameters:
      `statement` - the `ForStatement` to process

  - ### visitWhileLoop

    void visitWhileLoop(WhileStatement statement)
    Visits a while loop statement.
    Parameters:
      `statement` - the `WhileStatement` to process

  - ### visitDoWhileLoop

    void visitDoWhileLoop(DoWhileStatement statement)
    Visits a do-while loop statement.
    Parameters:
      `statement` - the `DoWhileStatement` to process

  - ### visitIfElse

    void visitIfElse(IfStatement statement)
    Visits an if-else statement.
    Parameters:
      `statement` - the `IfStatement` to process

  - ### visitExpressionStatement

    void visitExpressionStatement(ExpressionStatement statement)
    Visits an expression statement (an expression used as a statement).
    Parameters:
      `statement` - the `ExpressionStatement` to process

  - ### visitReturnStatement

    void visitReturnStatement(ReturnStatement statement)
    Visits a return statement.
    Parameters:
      `statement` - the `ReturnStatement` to process

  - ### visitAssertStatement

    void visitAssertStatement(AssertStatement statement)
    Visits an assert statement.
    Parameters:
      `statement` - the `AssertStatement` to process

  - ### visitTryCatchFinally

    void visitTryCatchFinally(TryCatchStatement statement)
    Visits a try-catch-finally statement.
    Parameters:
      `statement` - the `TryCatchStatement` to process

  - ### visitSwitch

    void visitSwitch(SwitchStatement statement)
    Visits a switch statement.
    Parameters:
      `statement` - the `SwitchStatement` to process

  - ### visitCaseStatement

    void visitCaseStatement(CaseStatement statement)
    Visits a case clause within a switch statement.
    Parameters:
      `statement` - the `CaseStatement` to process

  - ### visitBreakStatement

    void visitBreakStatement(BreakStatement statement)
    Visits a break statement.
    Parameters:
      `statement` - the `BreakStatement` to process

  - ### visitContinueStatement

    void visitContinueStatement(ContinueStatement statement)
    Visits a continue statement.
    Parameters:
      `statement` - the `ContinueStatement` to process

  - ### visitThrowStatement

    void visitThrowStatement(ThrowStatement statement)
    Visits a throw statement.
    Parameters:
      `statement` - the `ThrowStatement` to process

  - ### visitSynchronizedStatement

    void visitSynchronizedStatement(SynchronizedStatement statement)
    Visits a synchronized statement.
    Parameters:
      `statement` - the `SynchronizedStatement` to process

  - ### visitCatchStatement

    void visitCatchStatement(CatchStatement statement)
    Visits a catch clause within a try-catch statement.
    Parameters:
      `statement` - the `CatchStatement` to process

  - ### visitEmptyStatement

    default void visitEmptyStatement(EmptyStatement statement)
    Visits an empty statement. Default implementation does nothing.
    Parameters:
      `statement` - the `EmptyStatement` to process

  - ### visit

    default void visit(Statement statement)
    Convenience method to visit a statement if it is not null. Delegates to the statement's visit method.
    Parameters:
      `statement` - the `Statement` to process, or null to do nothing

  - ### visitMethodCallExpression

    void visitMethodCallExpression(MethodCallExpression expression)
    Visits a method call expression.
    Parameters:
      `expression` - the `MethodCallExpression` to process

  - ### visitStaticMethodCallExpression

    void visitStaticMethodCallExpression(StaticMethodCallExpression expression)
    Visits a static method call expression.
    Parameters:
      `expression` - the `StaticMethodCallExpression` to process

  - ### visitConstructorCallExpression

    void visitConstructorCallExpression(ConstructorCallExpression expression)
    Visits a constructor call expression.
    Parameters:
      `expression` - the `ConstructorCallExpression` to process

  - ### visitTernaryExpression

    void visitTernaryExpression(TernaryExpression expression)
    Visits a ternary expression (condition ? trueExpr : falseExpr).
    Parameters:
      `expression` - the `TernaryExpression` to process

  - ### visitShortTernaryExpression

    void visitShortTernaryExpression(ElvisOperatorExpression expression)
    Visits an Elvis operator expression (shorthand ternary with implicit condition check).
    Parameters:
      `expression` - the `ElvisOperatorExpression` to process

  - ### visitBinaryExpression

    void visitBinaryExpression(BinaryExpression expression)
    Visits a binary expression (left op right).
    Parameters:
      `expression` - the `BinaryExpression` to process

  - ### visitPrefixExpression

    void visitPrefixExpression(PrefixExpression expression)
    Visits a prefix expression (op expr).
    Parameters:
      `expression` - the `PrefixExpression` to process

  - ### visitPostfixExpression

    void visitPostfixExpression(PostfixExpression expression)
    Visits a postfix expression (expr op).
    Parameters:
      `expression` - the `PostfixExpression` to process

  - ### visitBooleanExpression

    void visitBooleanExpression(BooleanExpression expression)
    Visits a boolean expression.
    Parameters:
      `expression` - the `BooleanExpression` to process

  - ### visitClosureExpression

    void visitClosureExpression(ClosureExpression expression)
    Visits a closure expression.
    Parameters:
      `expression` - the `ClosureExpression` to process

  - ### visitLambdaExpression

    void visitLambdaExpression(LambdaExpression expression)
    Visits a lambda expression.
    Parameters:
      `expression` - the `LambdaExpression` to process

  - ### visitTupleExpression

    void visitTupleExpression(TupleExpression expression)
    Visits a tuple expression (comma-separated expressions grouped in parentheses).
    Parameters:
      `expression` - the `TupleExpression` to process

  - ### visitMapExpression

    void visitMapExpression(MapExpression expression)
    Visits a map expression.
    Parameters:
      `expression` - the `MapExpression` to process

  - ### visitMapEntryExpression

    void visitMapEntryExpression(MapEntryExpression expression)
    Visits a map entry expression (key: value pair within a map).
    Parameters:
      `expression` - the `MapEntryExpression` to process

  - ### visitListExpression

    void visitListExpression(ListExpression expression)
    Visits a list expression.
    Parameters:
      `expression` - the `ListExpression` to process

  - ### visitRangeExpression

    void visitRangeExpression(RangeExpression expression)
    Visits a range expression.
    Parameters:
      `expression` - the `RangeExpression` to process

  - ### visitPropertyExpression

    void visitPropertyExpression(PropertyExpression expression)
    Visits a property expression (object.property).
    Parameters:
      `expression` - the `PropertyExpression` to process

  - ### visitAttributeExpression

    void visitAttributeExpression(AttributeExpression expression)
    Visits an attribute expression (object@property, accessing direct field without getters).
    Parameters:
      `expression` - the `AttributeExpression` to process

  - ### visitFieldExpression

    void visitFieldExpression(FieldExpression expression)
    Visits a field expression.
    Parameters:
      `expression` - the `FieldExpression` to process

  - ### visitMethodPointerExpression

    void visitMethodPointerExpression(MethodPointerExpression expression)
    Visits a method pointer expression (`object.&methodName`).
    Parameters:
      `expression` - the `MethodPointerExpression` to process

  - ### visitMethodReferenceExpression

    void visitMethodReferenceExpression(MethodReferenceExpression expression)
    Visits a method reference expression (obj::method).
    Parameters:
      `expression` - the `MethodReferenceExpression` to process

  - ### visitConstantExpression

    void visitConstantExpression(ConstantExpression expression)
    Visits a constant expression (literal value).
    Parameters:
      `expression` - the `ConstantExpression` to process

  - ### visitClassExpression

    void visitClassExpression(ClassExpression expression)
    Visits a class expression.
    Parameters:
      `expression` - the `ClassExpression` to process

  - ### visitVariableExpression

    void visitVariableExpression(VariableExpression expression)
    Visits a variable expression.
    Parameters:
      `expression` - the `VariableExpression` to process

  - ### visitDeclarationExpression

    void visitDeclarationExpression(DeclarationExpression expression)
    Visits a declaration expression (variable declaration with initialization).
    Parameters:
      `expression` - the `DeclarationExpression` to process

  - ### visitGStringExpression

    void visitGStringExpression(GStringExpression expression)
    Visits a GString expression (string with interpolations).
    Parameters:
      `expression` - the `GStringExpression` to process

  - ### visitArrayExpression

    void visitArrayExpression(ArrayExpression expression)
    Visits an array expression.
    Parameters:
      `expression` - the `ArrayExpression` to process

  - ### visitSpreadExpression

    void visitSpreadExpression(SpreadExpression expression)
    Visits a spread expression (*expr, spreading collection elements).
    Parameters:
      `expression` - the `SpreadExpression` to process

  - ### visitSpreadMapExpression

    void visitSpreadMapExpression(SpreadMapExpression expression)
    Visits a spread map expression (*:map, spreading map entries).
    Parameters:
      `expression` - the `SpreadMapExpression` to process

  - ### visitNotExpression

    void visitNotExpression(NotExpression expression)
    Visits a not expression (!expr).
    Parameters:
      `expression` - the `NotExpression` to process

  - ### visitUnaryMinusExpression

    void visitUnaryMinusExpression(UnaryMinusExpression expression)
    Visits a unary minus expression (-expr).
    Parameters:
      `expression` - the `UnaryMinusExpression` to process

  - ### visitUnaryPlusExpression

    void visitUnaryPlusExpression(UnaryPlusExpression expression)
    Visits a unary plus expression (+expr).
    Parameters:
      `expression` - the `UnaryPlusExpression` to process

  - ### visitBitwiseNegationExpression

    void visitBitwiseNegationExpression(BitwiseNegationExpression expression)
    Visits a bitwise negation expression (~expr).
    Parameters:
      `expression` - the `BitwiseNegationExpression` to process

  - ### visitCastExpression

    void visitCastExpression(CastExpression expression)
    Visits a cast expression ((Type) expr).
    Parameters:
      `expression` - the `CastExpression` to process

  - ### visitArgumentlistExpression

    void visitArgumentlistExpression(ArgumentListExpression expression)
    Visits an argument list expression (method arguments).
    Parameters:
      `expression` - the `ArgumentListExpression` to process

  - ### visitClosureListExpression

    void visitClosureListExpression(ClosureListExpression expression)
    Visits a closure list expression.
    Parameters:
      `expression` - the `ClosureListExpression` to process

  - ### visitBytecodeExpression

    void visitBytecodeExpression(BytecodeExpression expression)
    Visits a bytecode expression (direct JVM bytecode instructions).
    Parameters:
      `expression` - the `BytecodeExpression` to process

  - ### visitEmptyExpression

    default void visitEmptyExpression(EmptyExpression expression)
    Visits an empty expression. Default implementation does nothing.
    Parameters:
      `expression` - the `EmptyExpression` to process

  - ### visitListOfExpressions

    default void visitListOfExpressions(List<? extends Expression> list)
    Convenience method to visit a list of expressions. Iterates through the list and calls the visit method on each non-null expression.
    Parameters:
      `list` - the list of `Expression`s to process, or null to do nothing

  - ### visit

    default void visit(Expression expression)
    Convenience method to visit an expression if it is not null. Delegates to the expression's visit method.
    Parameters:
      `expression` - the `Expression` to process, or null to do nothing