public interface Variable
Interface marking an AST node as representing a variable in Groovy/Java scope. Typical implementations include VariableExpression, FieldNode, PropertyNode, and Parameter. Provides unified access to variable metadata such as type, scope context, and modifiers.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Expression |
getInitialExpression()Returns the initialization expression for this variable, or null if no initialization is present. |
|
public int |
getModifiers()Returns the modifiers (access flags) for this variable as per org.objectweb.asm.Opcodes.
|
|
public String |
getName()Returns the name of the variable. |
|
public ClassNode |
getOriginType()Returns the original type of this variable before any type wrapping or transformation. |
|
public ClassNode |
getType()Returns the type of the variable. |
|
public boolean |
hasInitialExpression()Returns true if this variable has an initialization expression. |
|
public boolean |
isClosureSharedVariable()Returns true if this variable is shared with and accessed by nested closures. |
|
public boolean |
isDynamicTyped()Returns true if this variable has dynamic type information that could not be resolved at compile time. |
|
public boolean |
isFinal()Returns true if this variable is declared with the final modifier. |
|
public boolean |
isInStaticContext()Returns true if this variable is declared or used in a static context. |
|
public boolean |
isPrivate()Returns true if this variable is declared with the private modifier. |
|
public boolean |
isProtected()Returns true if this variable is declared with the protected modifier. |
|
public boolean |
isPublic()Returns true if this variable is declared with the public modifier. |
|
public boolean |
isStatic()Returns true if this variable is declared with the static modifier. |
|
public boolean |
isVolatile()Returns true if this variable is declared with the volatile modifier,
indicating that memory visibility is required for multi-threaded access. |
|
public void |
setClosureSharedVariable(boolean inClosure)Marks this variable as shared with nested closures. |
Returns the initialization expression for this variable, or null if no initialization is present. For fields and local variables, this may contain the right-hand side of an assignment; for parameters, this represents a default value.
Returns the modifiers (access flags) for this variable as per org.objectweb.asm.Opcodes.
May include visibility modifiers (public, protected, private), static, final, etc.
Returns the name of the variable.
Returns the original type of this variable before any type wrapping or transformation. For primitive types, this preserves the distinction between boxed and unboxed forms.
Returns the type of the variable. If the type is not yet determined, implementations may return a dynamic or placeholder type.
Returns true if this variable has an initialization expression.
Returns true if this variable is shared with and accessed by nested closures. Shared variables require special handling in bytecode generation to ensure proper access semantics.
Returns true if this variable has dynamic type information that could not be resolved at compile time.
Returns true if this variable is declared with the final modifier.
Returns true if this variable is declared or used in a static context. A static context includes static initializers, static field declarations, static method bodies, and class-level code without instance access.
Returns true if this variable is declared with the private modifier.
Returns true if this variable is declared with the protected modifier.
Returns true if this variable is declared with the public modifier.
Returns true if this variable is declared with the static modifier.
Returns true if this variable is declared with the volatile modifier,
indicating that memory visibility is required for multi-threaded access.
Marks this variable as shared with nested closures. This affects code generation and variable access patterns.
inClosure - true if shared with closures