Package org.codehaus.groovy.ast

# Class InnerClassNode

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.ClassNode
org.codehaus.groovy.ast.InnerClassNode

All Implemented Interfaces:
  `GroovydocHolder<AnnotatedNode>`, `NodeMetaDataHandler`

Direct Known Subclasses:
  `EnumConstantClassNode`, `InterfaceHelperClassNode`

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`

- ## Field Summary

  ### Fields inherited from class org.codehaus.groovy.ast.ClassNode

  `clazz, EMPTY_ARRAY, isPrimaryNode, lazyInitLock, SUPER, THIS`

  ### Fields inherited from interface groovy.lang.groovydoc.GroovydocHolder

  `DOC_COMMENT`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ClassNode`
  `getOuterClass()`
  Returns the class that encloses this inner class, or null if this is a top-level class.
  `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.
  `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.
  `VariableScope`
  `getVariableScope()`
  Returns the variable scope associated with this inner class, tracking declarations and references for closure and method boundary analysis.
  `boolean`
  `isAnonymous()`
  Returns whether this inner class represents an anonymous class (created with inline expressions).
  `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.
  `void`
  `setAnonymous(boolean anonymous)`
  Marks this inner class as anonymous if not already set.
  `void`
  `setVariableScope(VariableScope scope)`
  Sets the variable scope that manages variables declared and referenced within this inner class.

  ### Methods inherited from class org.codehaus.groovy.ast.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, getOuterClasses, getOuterClassType, getPackage, getPackageName, getPermittedSubclasses, getPlainNodeReference, getPlainNodeReference, getProperties, getProperty, getRecordComponents, getSetterMethod, getSetterMethod, getSuperClass, getText, getTransforms, getTypeAnnotations, getTypeAnnotations, getTypeClass, getUnresolvedInterfaces, getUnresolvedInterfaces, getUnresolvedName, getUnresolvedSuperClass, getUnresolvedSuperClass, hasDeclaredMethod, hashCode, hasMethod, hasPackageName, hasPossibleMethod, hasPossibleStaticMethod, hasProperty, implementsAnyInterfaces, implementsInterface, isAbstract, isAnnotated, isAnnotationDefinition, isArray, isDerivedFrom, isDerivedFromGroovyObject, isEnum, isGenericsPlaceHolder, isInterface, isPrimaryClassNode, isRecord, isRedirectNode, isResolved, isScript, isScriptBody, 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`

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

  `addAnnotation, addAnnotation, addAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`

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

  `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler

  `copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData`

- ## Constructor Details

  - ### InnerClassNode

    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:
      - `Opcodes`

  - ### InnerClassNode

    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:
      - `Opcodes`

- ## Method Details

  - ### getOuterClass

    public ClassNode getOuterClass()
    Returns the class that encloses this inner class, or null if this is a top-level class.
    Overrides:
      `getOuterClass` in class `ClassNode`
    Returns:
      the enclosing `ClassNode`, or null
    See Also:
      - `ClassNode.getOuterClasses()`

  - ### getOuterMostClass

    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

  - ### getOuterField

    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.
    Overrides:
      `getOuterField` in class `ClassNode`
    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(String)`

  - ### getVariableScope

    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`

  - ### setVariableScope

    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

  - ### isSealed

    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.
    Overrides:
      `isSealed` in class `ClassNode`
    Returns:
      true if this inner class is sealed and not anonymous

  - ### isAnonymous

    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

  - ### setAnonymous

    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.
    Parameters:
      `anonymous` - true to mark this inner class as anonymous
    Throws:
      `IllegalArgumentException` - if attempting to demote from anonymous to non-anonymous