Package: org.codehaus.groovy.ast

## [Java] Class InnerClassNode

- org.codehaus.groovy.ast.InnerClassNode

-     public class InnerClassNode
      extends ClassNode

  Represents a nested (inner) class definition within an outer class. Inner classes maintain a reference to their enclosing ClassNode and support Groovy-specific features such as variable scoping and anonymous class detection. Automatically marks inner classes as static when defined in interfaces per JLS specifications.

  See Also:
    ClassNode
    VariableScope

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class ClassNode` | `EMPTY_ARRAY, SUPER, THIS, clazz, isPrimaryNode, lazyInitLock`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `InnerClassNode(ClassNode outerClass, String name, int modifiers, ClassNode superClass)` Creates an inner class with the specified outer class, name, modifiers, and superclass.
    `InnerClassNode(ClassNode outerClass, String name, int modifiers, ClassNode superClass, ClassNode[] interfaces, MixinNode[] mixins)` Creates an inner class with the specified outer class, name, modifiers, superclass, interfaces, and mixins.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public ClassNode` | `getOuterClass()` Returns the class that encloses this inner class, or null if this is a top-level class.
    `` | `public FieldNode` | `getOuterField(String name)` Retrieves a field from the enclosing class by name, enabling access to outer class fields from within the inner class scope.
    `` | `public ClassNode` | `getOuterMostClass()` Returns the outermost class in the nesting hierarchy by recursively traversing outer class references until reaching a class that has no outer class.
    `` | `public VariableScope` | `getVariableScope()` Returns the variable scope associated with this inner class, tracking declarations and references for closure and method boundary analysis.
    `` | `public boolean` | `isAnonymous()` Returns whether this inner class represents an anonymous class (created with inline expressions).
    `` | `public boolean` | `isSealed()` Checks if this inner class is sealed per JLS 15.9.5, returning false for anonymous classes since they cannot be further subclassed.
    `` | `public void` | `setAnonymous(boolean anonymous)` Marks this inner class as anonymous if not already set.
    `` | `public void` | `setVariableScope(VariableScope scope)` Sets the variable scope that manages variables declared and referenced within this inner class.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassNode` | `addConstructor, addConstructor, addField, addField, addFieldFirst, addFieldFirst, addInterface, addMethod, addMethod, addMixin, addObjectInitializerStatements, addProperty, addProperty, addStaticInitializerStatements, addSyntheticMethod, addTransform, addTypeAnnotation, addTypeAnnotations, asGenericsType, declaresAnyInterfaces, declaresInterface, equals, getAbstractMethods, getAllDeclaredMethods, getAllInterfaces, getAnnotations, getAnnotations, getCompileUnit, getComponentType, getDeclaredConstructor, getDeclaredConstructors, getDeclaredField, getDeclaredMethod, getDeclaredMethods, getDeclaredMethodsMap, getEnclosingMethod, getField, getFieldIndex, getFields, getGenericsTypes, getGetterMethod, getGetterMethod, getInnerClasses, getInterfaces, getMethod, getMethods, getMethods, getMixins, getModifiers, getModule, getName, getNameWithoutPackage, getObjectInitializerStatements, getOuterClass, getOuterClassType, getOuterClasses, getOuterField, getPackage, getPackageName, getPermittedSubclasses, getPlainNodeReference, getPlainNodeReference, getProperties, getProperty, getRecordComponents, getSetterMethod, getSetterMethod, getSuperClass, getText, getTransforms, getTypeAnnotations, getTypeAnnotations, getTypeClass, getUnresolvedInterfaces, getUnresolvedInterfaces, getUnresolvedName, getUnresolvedSuperClass, getUnresolvedSuperClass, hasDeclaredMethod, hasMethod, hasPackageName, hasPossibleMethod, hasPossibleStaticMethod, hasProperty, hashCode, implementsAnyInterfaces, implementsInterface, isAbstract, isAnnotated, isAnnotationDefinition, isArray, isDerivedFrom, isDerivedFromGroovyObject, isEnum, isGenericsPlaceHolder, isInterface, isPrimaryClassNode, isRecord, isRedirectNode, isResolved, isScript, isScriptBody, isSealed, isStatic, isStaticClass, isSyntheticPublic, isUsingGenerics, makeArray, parametersEqual, positionStmtsAfterEnumInitStmts, redirect, removeConstructor, removeField, removeMethod, renameField, setAnnotated, setCompileUnit, setEnclosingMethod, setGenericsPlaceHolder, setGenericsTypes, setInterfaces, setMixins, setModifiers, setModule, setName, setOuterClassType, setPermittedSubclasses, setRecordComponents, setRedirect, setScript, setScriptBody, setStaticClass, setSuperClass, setSyntheticPublic, setUnresolvedSuperClass, setUsingGenerics, toString, toString, tryFindPossibleMethod, visitContents`
    `class AnnotatedNode` | `addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Constructor Detail

    - #### public InnerClassNode(ClassNode outerClass, String name, int modifiers, ClassNode superClass)

      Creates an inner class with the specified outer class, name, modifiers, and superclass.

      Parameters:
        `outerClass` - the enclosing class, or null for top-level classes
        `name` - the fully qualified name of the inner class
        `modifiers` - the `org.objectweb.asm.Opcodes` modifiers for this class
        `superClass` - the superclass of this inner class, or ClassNode.EMPTY_ARRAY for Object
      See Also:
        org.objectweb.asm.Opcodes

    - #### public InnerClassNode(ClassNode outerClass, String name, int modifiers, ClassNode superClass, ClassNode[] interfaces, MixinNode[] mixins)

      Creates an inner class with the specified outer class, name, modifiers, superclass, interfaces, and mixins. If the outer class is an interface, the inner class is automatically marked as static.

      Parameters:
        `outerClass` - the enclosing class, or null for top-level classes
        `name` - the fully qualified name of the inner class
        `modifiers` - the `org.objectweb.asm.Opcodes` modifiers for this class
        `superClass` - the superclass of this inner class
        `interfaces` - the interfaces implemented by this inner class
        `mixins` - the mixins applied to this inner class
      See Also:
        org.objectweb.asm.Opcodes

  - ### Method Detail

    - #### public ClassNode getOuterClass()

      Returns the class that encloses this inner class, or null if this is a top-level class.

      Returns:
        the enclosing ClassNode, or null

    - #### public FieldNode getOuterField(String name)

      Retrieves a field from the enclosing class by name, enabling access to outer class fields from within the inner class scope.

      Parameters:
        `name` - the field name to retrieve from the outer class
      Returns:
        the FieldNode from the outer class, or null if not found
      See Also:
        ClassNode.getDeclaredField

    - #### public ClassNode getOuterMostClass()

      Returns the outermost class in the nesting hierarchy by recursively traversing outer class references until reaching a class that has no outer class.

      Returns:
        the topmost ClassNode in the nesting chain

    - #### public VariableScope getVariableScope()

      Returns the variable scope associated with this inner class, tracking declarations and references for closure and method boundary analysis.

      Returns:
        the VariableScope, or null if not set
      See Also:
        VariableScope

    - #### public boolean isAnonymous()

      Returns whether this inner class represents an anonymous class (created with inline expressions).

      Returns:
        true if this is an anonymous inner class

    - #### public boolean isSealed()

      Checks if this inner class is sealed per JLS 15.9.5, returning false for anonymous classes since they cannot be further subclassed.

      Returns:
        true if this inner class is sealed and not anonymous

    - #### public void setAnonymous(boolean anonymous)

      Marks this inner class as anonymous if not already set. Anonymous classes have restricted modifiers: static and abstract modifiers are removed, and final is removed for enums per JLS 15.9.5. Once set to anonymous, this state cannot be reverted.

      throws:
        IllegalArgumentException if attempting to demote from anonymous to non-anonymous
      Parameters:
        `anonymous` - true to mark this inner class as anonymous

    - #### public void setVariableScope(VariableScope scope)

      Sets the variable scope that manages variables declared and referenced within this inner class.

      Parameters:
        `scope` - the VariableScope to associate with this inner class