Package org.codehaus.groovy.classgen
Class VariableScopeVisitor
java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.classgen.VariableScopeVisitor
- All Implemented Interfaces:
GroovyClassVisitor,GroovyCodeVisitor,ErrorCollecting
Initializes the variable scopes for an AST.
-
Constructor Summary
ConstructorsConstructorDescriptionVariableScopeVisitor(SourceUnit source) VariableScopeVisitor(SourceUnit source, boolean recurseInnerClasses) -
Method Summary
Modifier and TypeMethodDescriptionprotected SourceUnitProvides access to theSourceUnitfor error reporting during visitation.voidprepareVisit(ClassNode node) Sets the current class node context.protected voidVisits an individualAnnotationNode, traversing all member expression values.voidvisitArrayExpression(ArrayExpression expression) Visits anArrayExpression, traversing element expressions and size expressions.voidvisitAssertStatement(AssertStatement statement) Visits anAssertStatement, invoking the statement hook before parent traversal.voidvisitBinaryExpression(BinaryExpression expression) Visits aBinaryExpression, traversing left and right operand expressions.voidvisitBlockStatement(BlockStatement statement) Visits aBlockStatement, invoking the statement hook before parent traversal.voidvisitCastExpression(CastExpression expression) Visits aCastExpression, traversing the operand expression.voidvisitCatchStatement(CatchStatement statement) Visits aCatchStatement, processing variable annotations and invoking the statement hook.voidvisitClass(ClassNode node) Visits aClassNode, processing its annotations, package, imports, contents, and object initializers.voidvisitClassExpression(ClassExpression expression) Visits aClassExpression.voidvisitClosureExpression(ClosureExpression expression) Visits aClosureExpressionwith annotation processing, traversing parameter annotations before delegating to parent traversal.voidvisitConstantExpression(ConstantExpression expression) Visits aConstantExpression.voidVisits aConstructorCallExpression, traversing its argument list.protected voidvisitConstructorOrMethod(MethodNode node, boolean isConstructor) Visits a constructor or method node (implementation detail for both visit methods).voidvisitDeclarationExpression(DeclarationExpression expression) Visits aDeclarationExpressionwith annotation processing, traversing expression annotations before delegating to parent traversal.voidvisitDoWhileLoop(DoWhileStatement statement) Visits aDoWhileStatement, invoking statement hooks before parent traversal.voidvisitExpressionStatement(ExpressionStatement statement) Visits anExpressionStatement, invoking the statement hook before parent traversal.voidvisitField(FieldNode node) Visits aFieldNode, processing its annotations and initial value expression if present.voidvisitFieldExpression(FieldExpression expression) Visits aFieldExpression.voidvisitForLoop(ForStatement statement) Visits aForStatement, invoking statement hooks and processing loop variable annotations.voidvisitIfElse(IfStatement statement) Visits anIfStatement, invoking the statement hook before parent traversal.voidvisitMethodCallExpression(MethodCallExpression expression) Visits aMethodCallExpression, traversing the object expression, method expression, and argument list.voidvisitProperty(PropertyNode node) Visits aPropertyNode, processing its annotations, initial value expression, and getter/setter blocks if present.voidvisitPropertyExpression(PropertyExpression expression) Visits aPropertyExpression, traversing the object and property name expressions.voidvisitReturnStatement(ReturnStatement statement) Visits aReturnStatement, invoking the statement hook before parent traversal.voidvisitSwitch(SwitchStatement statement) Visits aSwitchStatement, invoking the statement hook before parent traversal.voidvisitVariableExpression(VariableExpression expression) Visits aVariableExpression.voidvisitWhileLoop(WhileStatement statement) Visits aWhileStatement, invoking statement hooks before parent traversal.Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, visitAnnotations, visitAnnotations, visitBreakStatement, visitCaseStatement, visitClassCodeContainer, visitConstructor, visitContinueStatement, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitStatement, visitStatementAnnotations, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinallyMethods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitAttributeExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitClosureListExpression, visitEmptyStatement, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpressionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor
visit, visit, visitEmptyExpression, visitListOfExpressions
-
Constructor Details
-
VariableScopeVisitor
-
VariableScopeVisitor
-
-
Method Details
-
getSourceUnit
Description copied from class:ClassCodeVisitorSupportProvides access to theSourceUnitfor error reporting during visitation. Implementations must override this method.- Specified by:
getSourceUnitin classClassCodeVisitorSupport- Returns:
- the source unit for this visitor
-
prepareVisit
Sets the current class node context. -
visitClass
Description copied from class:ClassCodeVisitorSupportVisits aClassNode, processing its annotations, package, imports, contents, and object initializers.- Specified by:
visitClassin interfaceGroovyClassVisitor- Overrides:
visitClassin classClassCodeVisitorSupport- Parameters:
node- the class node to visit
-
visitField
Description copied from class:ClassCodeVisitorSupportVisits aFieldNode, processing its annotations and initial value expression if present.- Specified by:
visitFieldin interfaceGroovyClassVisitor- Overrides:
visitFieldin classClassCodeVisitorSupport- Parameters:
node- the field node to visit
-
visitProperty
Description copied from class:ClassCodeVisitorSupportVisits aPropertyNode, processing its annotations, initial value expression, and getter/setter blocks if present.- Specified by:
visitPropertyin interfaceGroovyClassVisitor- Overrides:
visitPropertyin classClassCodeVisitorSupport- Parameters:
node- the property node to visit
-
visitAnnotation
Description copied from class:ClassCodeVisitorSupportVisits an individualAnnotationNode, traversing all member expression values. Subclasses may override to perform custom annotation processing.- Overrides:
visitAnnotationin classClassCodeVisitorSupport- Parameters:
node- the annotation node to visit
-
visitConstructorOrMethod
Description copied from class:ClassCodeVisitorSupportVisits a constructor or method node (implementation detail for both visit methods). Processes the node's annotations, all parameter annotations, and code block.- Overrides:
visitConstructorOrMethodin classClassCodeVisitorSupport- Parameters:
node- the method or constructor nodeisConstructor- true if node is a constructor, false if it is a method
-
visitAssertStatement
Description copied from class:ClassCodeVisitorSupportVisits anAssertStatement, invoking the statement hook before parent traversal.- Specified by:
visitAssertStatementin interfaceGroovyCodeVisitor- Overrides:
visitAssertStatementin classClassCodeVisitorSupport- Parameters:
statement- the assert statement to visit
-
visitBlockStatement
Description copied from class:ClassCodeVisitorSupportVisits aBlockStatement, invoking the statement hook before parent traversal.- Specified by:
visitBlockStatementin interfaceGroovyCodeVisitor- Overrides:
visitBlockStatementin classClassCodeVisitorSupport- Parameters:
statement- the block statement to visit- See Also:
-
visitCatchStatement
Description copied from class:ClassCodeVisitorSupportVisits aCatchStatement, processing variable annotations and invoking the statement hook.- Specified by:
visitCatchStatementin interfaceGroovyCodeVisitor- Overrides:
visitCatchStatementin classClassCodeVisitorSupport- Parameters:
statement- the catch statement to visit
-
visitDoWhileLoop
Description copied from class:ClassCodeVisitorSupportVisits aDoWhileStatement, invoking statement hooks before parent traversal.- Specified by:
visitDoWhileLoopin interfaceGroovyCodeVisitor- Overrides:
visitDoWhileLoopin classClassCodeVisitorSupport- Parameters:
statement- the do-while statement to visit
-
visitExpressionStatement
Description copied from class:ClassCodeVisitorSupportVisits anExpressionStatement, invoking the statement hook before parent traversal.- Specified by:
visitExpressionStatementin interfaceGroovyCodeVisitor- Overrides:
visitExpressionStatementin classClassCodeVisitorSupport- Parameters:
statement- the expression statement to visit
-
visitForLoop
Description copied from class:ClassCodeVisitorSupportVisits aForStatement, invoking statement hooks and processing loop variable annotations.- Specified by:
visitForLoopin interfaceGroovyCodeVisitor- Overrides:
visitForLoopin classClassCodeVisitorSupport- Parameters:
statement- the for statement to visit
-
visitIfElse
Description copied from class:ClassCodeVisitorSupportVisits anIfStatement, invoking the statement hook before parent traversal.- Specified by:
visitIfElsein interfaceGroovyCodeVisitor- Overrides:
visitIfElsein classClassCodeVisitorSupport- Parameters:
statement- the if statement to visit
-
visitReturnStatement
Description copied from class:ClassCodeVisitorSupportVisits aReturnStatement, invoking the statement hook before parent traversal.- Specified by:
visitReturnStatementin interfaceGroovyCodeVisitor- Overrides:
visitReturnStatementin classClassCodeVisitorSupport- Parameters:
statement- the return statement to visit
-
visitSwitch
Description copied from class:ClassCodeVisitorSupportVisits aSwitchStatement, invoking the statement hook before parent traversal.- Specified by:
visitSwitchin interfaceGroovyCodeVisitor- Overrides:
visitSwitchin classClassCodeVisitorSupport- Parameters:
statement- the switch statement to visit
-
visitWhileLoop
Description copied from class:ClassCodeVisitorSupportVisits aWhileStatement, invoking statement hooks before parent traversal.- Specified by:
visitWhileLoopin interfaceGroovyCodeVisitor- Overrides:
visitWhileLoopin classClassCodeVisitorSupport- Parameters:
statement- the while statement to visit
-
visitArrayExpression
Description copied from class:CodeVisitorSupportVisits anArrayExpression, traversing element expressions and size expressions.- Specified by:
visitArrayExpressionin interfaceGroovyCodeVisitor- Overrides:
visitArrayExpressionin classCodeVisitorSupport- Parameters:
expression- the array expression
-
visitBinaryExpression
Description copied from class:CodeVisitorSupportVisits aBinaryExpression, traversing left and right operand expressions.- Specified by:
visitBinaryExpressionin interfaceGroovyCodeVisitor- Overrides:
visitBinaryExpressionin classCodeVisitorSupport- Parameters:
expression- the binary expression
-
visitCastExpression
Description copied from class:CodeVisitorSupportVisits aCastExpression, traversing the operand expression.- Specified by:
visitCastExpressionin interfaceGroovyCodeVisitor- Overrides:
visitCastExpressionin classCodeVisitorSupport- Parameters:
expression- the cast expression
-
visitClassExpression
Description copied from class:CodeVisitorSupportVisits aClassExpression. No traversal is performed as class expressions contain no child expressions.- Specified by:
visitClassExpressionin interfaceGroovyCodeVisitor- Overrides:
visitClassExpressionin classCodeVisitorSupport- Parameters:
expression- the class expression
-
visitClosureExpression
Description copied from class:ClassCodeVisitorSupportVisits aClosureExpressionwith annotation processing, traversing parameter annotations before delegating to parent traversal.- Specified by:
visitClosureExpressionin interfaceGroovyCodeVisitor- Overrides:
visitClosureExpressionin classClassCodeVisitorSupport- Parameters:
expression- the closure expression to visit
-
visitConstantExpression
Description copied from class:CodeVisitorSupportVisits aConstantExpression. No traversal is performed as constants contain no child expressions.- Specified by:
visitConstantExpressionin interfaceGroovyCodeVisitor- Overrides:
visitConstantExpressionin classCodeVisitorSupport- Parameters:
expression- the constant expression
-
visitConstructorCallExpression
Description copied from class:CodeVisitorSupportVisits aConstructorCallExpression, traversing its argument list.- Specified by:
visitConstructorCallExpressionin interfaceGroovyCodeVisitor- Overrides:
visitConstructorCallExpressionin classCodeVisitorSupport- Parameters:
expression- the constructor call expression
-
visitDeclarationExpression
Description copied from class:ClassCodeVisitorSupportVisits aDeclarationExpressionwith annotation processing, traversing expression annotations before delegating to parent traversal.- Specified by:
visitDeclarationExpressionin interfaceGroovyCodeVisitor- Overrides:
visitDeclarationExpressionin classClassCodeVisitorSupport- Parameters:
expression- the declaration expression to visit
-
visitFieldExpression
Description copied from class:CodeVisitorSupportVisits aFieldExpression. No traversal is performed as field expressions contain no child expressions.- Specified by:
visitFieldExpressionin interfaceGroovyCodeVisitor- Overrides:
visitFieldExpressionin classCodeVisitorSupport- Parameters:
expression- the field expression
-
visitMethodCallExpression
Description copied from class:CodeVisitorSupportVisits aMethodCallExpression, traversing the object expression, method expression, and argument list.- Specified by:
visitMethodCallExpressionin interfaceGroovyCodeVisitor- Overrides:
visitMethodCallExpressionin classCodeVisitorSupport- Parameters:
expression- the method call expression
-
visitPropertyExpression
Description copied from class:CodeVisitorSupportVisits aPropertyExpression, traversing the object and property name expressions.- Specified by:
visitPropertyExpressionin interfaceGroovyCodeVisitor- Overrides:
visitPropertyExpressionin classCodeVisitorSupport- Parameters:
expression- the property expression
-
visitVariableExpression
Description copied from class:CodeVisitorSupportVisits aVariableExpression. No traversal is performed as variable expressions contain no child expressions.- Specified by:
visitVariableExpressionin interfaceGroovyCodeVisitor- Overrides:
visitVariableExpressionin classCodeVisitorSupport- Parameters:
expression- the variable expression
-