Package org.codehaus.groovy.classgen

# Class InnerClassVisitorHelper

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

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

Direct Known Subclasses:
  `InnerClassCompletionVisitor`, `InnerClassVisitor`

public abstract class InnerClassVisitorHelper extends ClassCodeVisitorSupport
Abstract base class providing helper methods for inner class visitors. This class contains utility methods for generating dispatcher code that allows inner classes to access members of their enclosing classes.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `InnerClassVisitorHelper()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected static void`
  `addFieldInit(Parameter p, FieldNode fn, BlockStatement block)`
  Adds a statement to initialize a field from a constructor parameter.
  `protected static ClassNode`
  `getClassNode(ClassNode cn, boolean isStatic)`
  Returns the class node to expose when wiring dispatch methods for an inner class.
  `protected static int`
  `getObjectDistance(ClassNode cn)`
  Calculates the inheritance distance from the supplied type to `Object`.
  `protected static boolean`
  `isStatic(InnerClassNode cn)`
  Determines whether the supplied inner class behaves as a static nested class.
  `protected static void`
  `setMethodDispatcherCode(BlockStatement block, Expression target, Parameter[] parameters)`
  Generates method dispatcher code for dynamic method invocation.
  `protected static void`
  `setPropertyGetterDispatcher(BlockStatement block, Expression target, Parameter[] parameters)`
  Generates property getter dispatcher code for dynamic property access.
  `protected static void`
  `setPropertySetterDispatcher(BlockStatement block, Expression target, Parameter[] parameters)`
  Generates property setter dispatcher code for dynamic property access.
  `protected static boolean`
  `shouldHandleImplicitThisForInnerClass(ClassNode cn)`
  Determines whether synthetic outer-instance handling should be applied to the inner class.

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

  `addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitClosureExpression, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, 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, visitConstructorCallExpression, 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

  - ### InnerClassVisitorHelper

    public InnerClassVisitorHelper()

- ## Method Details

  - ### addFieldInit

    protected static void addFieldInit(Parameter p, FieldNode fn, BlockStatement block)
    Adds a statement to initialize a field from a constructor parameter.
    Parameters:
      `p` - the parameter to read from
      `fn` - the field to initialize
      `block` - the block statement to add the initialization to

  - ### setPropertyGetterDispatcher

    protected static void setPropertyGetterDispatcher(BlockStatement block, Expression target, Parameter[] parameters)
    Generates property getter dispatcher code for dynamic property access.
    Parameters:
      `block` - the block to add the dispatcher code to
      `target` - the target object to get the property from
      `parameters` - the dispatcher method parameters (property name)

  - ### setPropertySetterDispatcher

    protected static void setPropertySetterDispatcher(BlockStatement block, Expression target, Parameter[] parameters)
    Generates property setter dispatcher code for dynamic property access.
    Parameters:
      `block` - the block to add the dispatcher code to
      `target` - the target object to set the property on
      `parameters` - the dispatcher method parameters (property name, value)

  - ### setMethodDispatcherCode

    protected static void setMethodDispatcherCode(BlockStatement block, Expression target, Parameter[] parameters)
    Generates method dispatcher code for dynamic method invocation. Handles both single arguments and spread arguments.
    Parameters:
      `block` - the block to add the dispatcher code to
      `target` - the target object to invoke methods on
      `parameters` - the dispatcher method parameters (method name, arguments)

  - ### getClassNode

    protected static ClassNode getClassNode(ClassNode cn, boolean isStatic)
    Returns the class node to expose when wiring dispatch methods for an inner class.
    Parameters:
      `cn` - the enclosing class node
      `isStatic` - whether the generated access is static
    Returns:
      the effective dispatch receiver type

  - ### getObjectDistance

    protected static int getObjectDistance(ClassNode cn)
    Calculates the inheritance distance from the supplied type to `Object`.
    Parameters:
      `cn` - the class node to measure
    Returns:
      the number of superclass hops to `Object`

  - ### isStatic

    protected static boolean isStatic(InnerClassNode cn)
    Determines whether the supplied inner class behaves as a static nested class.
    Parameters:
      `cn` - the inner class node to test
    Returns:
      `true` if no outer-instance field is required

  - ### shouldHandleImplicitThisForInnerClass

    protected static boolean shouldHandleImplicitThisForInnerClass(ClassNode cn)
    Determines whether synthetic outer-instance handling should be applied to the inner class.
    Parameters:
      `cn` - the class node to test
    Returns:
      `true` if implicit `this$0` handling is required