public class VariableScopeVisitor
extends ClassCodeVisitorSupport
Initializes the variable scopes for an AST.
| Constructor and description |
|---|
VariableScopeVisitor(SourceUnit source, boolean recurseInnerClasses)Creates a new variable scope visitor with optional recursion into inner classes. |
VariableScopeVisitor(SourceUnit source)Creates a new variable scope visitor that does not recurse into inner classes. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected SourceUnit |
getSourceUnit()* Provides access to the SourceUnit for error reporting during visitation. * Implementations must override this method. * *
|
|
public void |
prepareVisit(ClassNode node)Sets the current class node context. |
|
protected void |
visitAnnotation(AnnotationNode node)* Visits an individual AnnotationNode, traversing all member expression values. * Subclasses may override to perform custom annotation processing. * *
|
|
public void |
visitArrayExpression(ArrayExpression expression)* Visits an ArrayExpression, traversing element expressions and size expressions. * *
|
|
public void |
visitAssertStatement(AssertStatement statement)* Visits an AssertStatement, invoking the statement hook before parent traversal. * *
|
|
public void |
visitBinaryExpression(BinaryExpression expression)* Visits a BinaryExpression, traversing left and right operand expressions. * *
|
|
public void |
visitBlockStatement(BlockStatement statement)* Visits a BlockStatement, invoking the statement hook before parent traversal. * *
|
|
public void |
visitCastExpression(CastExpression expression)* Visits a CastExpression, traversing the operand expression. * *
|
|
public void |
visitCatchStatement(CatchStatement statement)* Visits a CatchStatement, processing variable annotations and invoking the statement hook. * *
|
|
public void |
visitClass(ClassNode node)* Visits a ClassNode, processing its annotations, package, imports, contents, and object initializers. * *
|
|
public void |
visitClassExpression(ClassExpression expression)* Visits a ClassExpression. No traversal is performed as class expressions contain no child expressions. * *
|
|
public void |
visitClosureExpression(ClosureExpression expression)* Visits a ClosureExpression with annotation processing, traversing parameter annotations * before delegating to parent traversal. * *
|
|
public void |
visitConstantExpression(ConstantExpression expression)* Visits a ConstantExpression. No traversal is performed as constants contain no child expressions. * *
|
|
public void |
visitConstructorCallExpression(ConstructorCallExpression expression)* Visits a ConstructorCallExpression, traversing its argument list. * *
|
|
protected void |
visitConstructorOrMethod(MethodNode node, boolean isConstructor)* Visits a constructor or method node (implementation detail for both visit methods). * Processes the node's annotations, all parameter annotations, and code block. * *
|
|
public void |
visitDeclarationExpression(DeclarationExpression expression)* Visits a DeclarationExpression with annotation processing, traversing expression annotations * before delegating to parent traversal. * *
|
|
public void |
visitDoWhileLoop(DoWhileStatement statement)* Visits a DoWhileStatement, invoking statement hooks before parent traversal. * *
|
|
public void |
visitExpressionStatement(ExpressionStatement statement)* Visits an ExpressionStatement, invoking the statement hook before parent traversal. * *
|
|
public void |
visitField(FieldNode node)* Visits a FieldNode, processing its annotations and initial value expression if present. * *
|
|
public void |
visitFieldExpression(FieldExpression expression)* Visits a FieldExpression. No traversal is performed as field expressions contain no child expressions. * *
|
|
public void |
visitForLoop(ForStatement statement)* Visits a ForStatement, invoking statement hooks and processing loop variable annotations. * *
|
|
public void |
visitIfElse(IfStatement statement)* Visits an IfStatement, invoking the statement hook before parent traversal. * *
|
|
public void |
visitMethodCallExpression(MethodCallExpression expression)* Visits a MethodCallExpression, traversing the object expression, * method expression, and argument list. * *
|
|
public void |
visitProperty(PropertyNode node)* Visits a PropertyNode, processing its annotations, initial value expression, * and getter/setter blocks if present. * *
|
|
public void |
visitPropertyExpression(PropertyExpression expression)* Visits a PropertyExpression, traversing the object and property name expressions. * *
|
|
public void |
visitReturnStatement(ReturnStatement statement)* Visits a ReturnStatement, invoking the statement hook before parent traversal. * *
|
|
public void |
visitSwitch(SwitchStatement statement)* Visits a SwitchStatement, invoking the statement hook before parent traversal. * *
|
|
public void |
visitVariableExpression(VariableExpression expression)* Visits a VariableExpression. No traversal is performed as variable expressions contain no child expressions. * *
|
|
public void |
visitWhileLoop(WhileStatement statement)* Visits a WhileStatement, invoking statement hooks before parent traversal. * *
|
Creates a new variable scope visitor with optional recursion into inner classes.
source - the source unit being processedrecurseInnerClasses - whether to recurse into inner classesCreates a new variable scope visitor that does not recurse into inner classes.
source - the source unit being processed* Provides access to the SourceUnit for error reporting during visitation. * Implementations must override this method. * *
Sets the current class node context.
* Visits an individual AnnotationNode, traversing all member expression values. * Subclasses may override to perform custom annotation processing. * *
node - the annotation node to visit* Visits an ArrayExpression, traversing element expressions and size expressions. * *
expression - the array expression* Visits an AssertStatement, invoking the statement hook before parent traversal. * *
statement - the assert statement to visit* Visits a BinaryExpression, traversing left and right operand expressions. * *
expression - the binary expression* Visits a BlockStatement, invoking the statement hook before parent traversal. * *
statement - the block statement to visit* Visits a CastExpression, traversing the operand expression. * *
expression - the cast expression* Visits a CatchStatement, processing variable annotations and invoking the statement hook. * *
statement - the catch statement to visit* Visits a ClassNode, processing its annotations, package, imports, contents, and object initializers. * *
node - the class node to visit* Visits a ClassExpression. No traversal is performed as class expressions contain no child expressions. * *
expression - the class expression* Visits a ClosureExpression with annotation processing, traversing parameter annotations * before delegating to parent traversal. * *
expression - the closure expression to visit* Visits a ConstantExpression. No traversal is performed as constants contain no child expressions. * *
expression - the constant expression* Visits a ConstructorCallExpression, traversing its argument list. * *
call - the constructor call expression* Visits a constructor or method node (implementation detail for both visit methods). * Processes the node's annotations, all parameter annotations, and code block. * *
node - the method or constructor node
*isConstructor - true if node is a constructor, false if it is a method* Visits a DeclarationExpression with annotation processing, traversing expression annotations * before delegating to parent traversal. * *
expression - the declaration expression to visit* Visits a DoWhileStatement, invoking statement hooks before parent traversal. * *
statement - the do-while statement to visit* Visits an ExpressionStatement, invoking the statement hook before parent traversal. * *
statement - the expression statement to visit* Visits a FieldNode, processing its annotations and initial value expression if present. * *
node - the field node to visit* Visits a FieldExpression. No traversal is performed as field expressions contain no child expressions. * *
expression - the field expression* Visits a ForStatement, invoking statement hooks and processing loop variable annotations. * *
statement - the for statement to visit* Visits an IfStatement, invoking the statement hook before parent traversal. * *
statement - the if statement to visit* Visits a MethodCallExpression, traversing the object expression, * method expression, and argument list. * *
call - the method call expression* Visits a PropertyNode, processing its annotations, initial value expression, * and getter/setter blocks if present. * *
node - the property node to visit* Visits a PropertyExpression, traversing the object and property name expressions. * *
expression - the property expression* Visits a ReturnStatement, invoking the statement hook before parent traversal. * *
statement - the return statement to visit* Visits a SwitchStatement, invoking the statement hook before parent traversal. * *
statement - the switch statement to visit* Visits a VariableExpression. No traversal is performed as variable expressions contain no child expressions. * *
expression - the variable expression* Visits a WhileStatement, invoking statement hooks before parent traversal. * *
statement - the while statement to visitCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.