Package: org.codehaus.groovy.classgen

## [Java] Class InnerClassVisitorHelper

- org.codehaus.groovy.classgen.InnerClassVisitorHelper

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

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and 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.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class 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`
    `class CodeVisitorSupport` | `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`

- - ### Method Detail

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

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

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

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

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

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

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

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