Package org.codehaus.groovy.classgen

# Class InnerClassVisitor

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.classgen.InnerClassVisitorHelper
org.codehaus.groovy.classgen.InnerClassVisitor

All Implemented Interfaces:
  `GroovyClassVisitor`, `GroovyCodeVisitor`, `ErrorCollecting`

public class InnerClassVisitor extends InnerClassVisitorHelper
Processes inner classes during compilation, handling the creation of synthetic fields and parameters needed for inner class instances to reference their enclosing instances. This visitor identifies and transforms inner class constructor calls to pass the appropriate enclosing instance references.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `InnerClassVisitor(CompilationUnit cu, SourceUnit su)`
  Creates a new inner class visitor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected SourceUnit`
  `getSourceUnit()`
  Provides access to the `SourceUnit` for error reporting during visitation.
  `void`
  `visitClass(ClassNode node)`
  Visits a `ClassNode`, processing its annotations, package, imports, contents, and object initializers.
  `void`
  `visitClosureExpression(ClosureExpression closure)`
  Visits a `ClosureExpression` with annotation processing, traversing parameter annotations before delegating to parent traversal.
  `void`
  `visitConstructorCallExpression(ConstructorCallExpression call)`
  Visits a `ConstructorCallExpression`, traversing its argument list.
  `protected void`
  `visitConstructorOrMethod(MethodNode node, boolean isConstructor)`
  Visits a constructor or method node (implementation detail for both visit methods).
  `void`
  `visitField(FieldNode node)`
  Visits a `FieldNode`, processing its annotations and initial value expression if present.
  `protected void`
  `visitObjectInitializerStatements(ClassNode node)`
  Visits all object initializer statements in a class, typically static or instance initialization blocks.
  `void`
  `visitProperty(PropertyNode node)`
  Visits a `PropertyNode`, processing its annotations, initial value expression, and getter/setter blocks if present.

  ### Methods inherited from class org.codehaus.groovy.classgen.InnerClassVisitorHelper

  `addFieldInit, getClassNode, getObjectDistance, isStatic, setMethodDispatcherCode, setPropertyGetterDispatcher, setPropertySetterDispatcher, shouldHandleImplicitThisForInnerClass`

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

  `addError, visitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClassCodeContainer, visitConstructor, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitIfElse, visitImports, visitMethod, visitPackage, visitReturnStatement, visitStatement, visitStatementAnnotations, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`

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

  `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureListExpression, visitConstantExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression`

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

  - ### InnerClassVisitor

    public InnerClassVisitor(CompilationUnit cu, SourceUnit su)
    Creates a new inner class visitor.
    Parameters:
      `cu` - the compilation unit (currently unused but kept for API compatibility)
      `su` - the source unit for error reporting

- ## Method Details

  - ### getSourceUnit

    protected SourceUnit getSourceUnit()
    Provides access to the `SourceUnit` for error reporting during visitation. Implementations must override this method.
    Specified by:
      `getSourceUnit` in class `ClassCodeVisitorSupport`
    Returns:
      the source unit for this visitor

  - ### visitClass

    public void visitClass(ClassNode node)
    Visits a `ClassNode`, processing its annotations, package, imports, contents, and object initializers.
    Specified by:
      `visitClass` in interface `GroovyClassVisitor`
    Overrides:
      `visitClass` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the class node to visit

  - ### visitField

    public void visitField(FieldNode node)
    Visits a `FieldNode`, processing its annotations and initial value expression if present.
    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 `PropertyNode`, processing its annotations, initial value expression, and getter/setter blocks if present.
    Specified by:
      `visitProperty` in interface `GroovyClassVisitor`
    Overrides:
      `visitProperty` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the property node to visit

  - ### visitClosureExpression

    public void visitClosureExpression(ClosureExpression closure)
    Visits a `ClosureExpression` with annotation processing, traversing parameter annotations before delegating to parent traversal.
    Specified by:
      `visitClosureExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitClosureExpression` in class `ClassCodeVisitorSupport`
    Parameters:
      `closure` - the closure expression to visit

  - ### visitObjectInitializerStatements

    protected void visitObjectInitializerStatements(ClassNode node)
    Visits all object initializer statements in a class, typically static or instance initialization blocks.
    Overrides:
      `visitObjectInitializerStatements` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the class node containing initializer statements

  - ### visitConstructorOrMethod

    protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
    Visits a constructor or method node (implementation detail for both visit methods). Processes the node's annotations, all parameter annotations, and code block.
    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

  - ### visitConstructorCallExpression

    public void visitConstructorCallExpression(ConstructorCallExpression call)
    Visits a `ConstructorCallExpression`, traversing its argument list.
    Specified by:
      `visitConstructorCallExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitConstructorCallExpression` in class `CodeVisitorSupport`
    Parameters:
      `call` - the constructor call expression