Package org.codehaus.groovy.control
Class StaticImportVisitor
java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeExpressionTransformer
org.codehaus.groovy.control.StaticImportVisitor
- All Implemented Interfaces:
ExpressionTransformer,GroovyClassVisitor,GroovyCodeVisitor,ErrorCollecting
Visitor to resolve constants and method calls from static imports.
-
Constructor Summary
ConstructorsConstructorDescriptionStaticImportVisitor(ClassNode classNode, SourceUnit sourceUnit) Creates a visitor that rewrites references resolved through static imports. -
Method Summary
Modifier and TypeMethodDescriptionprotected SourceUnitReturns the source unit currently being transformed.transform(Expression exp) Rewrites expressions that may target statically imported members.protected ExpressionRewrites binary expressions that may reference statically imported members.protected ExpressionRewrites default parameter expressions inside closures.protected ExpressionRewrites named-argument constructor calls that use statically imported members.protected ExpressionRewrites implicit-this calls that resolve to statically imported methods or properties.protected ExpressionRewrites property expressions that may resolve through static imports.protected ExpressionRewrites variable expressions that resolve to statically imported fields or accessors.voidMarks annotation traversal so imported constants can be inlined safely.voidvisitClass(ClassNode classNode, SourceUnit sourceUnit) Deprecated.protected voidvisitConstructorOrMethod(MethodNode node, boolean isConstructor) Tracks the current method while transforming static-import references.Methods inherited from class org.codehaus.groovy.ast.ClassCodeExpressionTransformer
setSourcePosition, visitAnnotation, visitAssertStatement, visitCaseStatement, visitClosureExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitProperty, visitReturnStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitWhileLoopMethods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, visitAnnotations, visitBlockStatement, visitBreakStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitContinueStatement, visitDeclarationExpression, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitStatement, visitStatementAnnotations, visitTryCatchFinallyMethods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpressionMethods 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
-
StaticImportVisitor
Creates a visitor that rewrites references resolved through static imports.- Parameters:
classNode- the class currently being transformedsourceUnit- the source unit containing the class
-
-
Method Details
-
visitClass
Deprecated. -
visitConstructorOrMethod
Tracks the current method while transforming static-import references.- Overrides:
visitConstructorOrMethodin classClassCodeExpressionTransformer- Parameters:
node- the method or constructor being visitedisConstructor- whethernodeis a constructor
-
visitAnnotations
Marks annotation traversal so imported constants can be inlined safely.- Overrides:
visitAnnotationsin classClassCodeVisitorSupport- Parameters:
node- the annotated node whose annotations are being visited
-
transform
Rewrites expressions that may target statically imported members.- Specified by:
transformin interfaceExpressionTransformer- Overrides:
transformin classClassCodeExpressionTransformer- Parameters:
exp- the expression to transform- Returns:
- the transformed expression
-
transformBinaryExpression
Rewrites binary expressions that may reference statically imported members.- Parameters:
be- the binary expression to transform- Returns:
- the transformed expression
-
transformVariableExpression
Rewrites variable expressions that resolve to statically imported fields or accessors.- Parameters:
ve- the variable expression to transform- Returns:
- the transformed expression
-
transformMethodCallExpression
Rewrites implicit-this calls that resolve to statically imported methods or properties.- Parameters:
mce- the method call to transform- Returns:
- the transformed expression
-
transformConstructorCallExpression
Rewrites named-argument constructor calls that use statically imported members.- Parameters:
cce- the constructor call to transform- Returns:
- the transformed expression
-
transformClosureExpression
Rewrites default parameter expressions inside closures.- Parameters:
ce- the closure expression to transform- Returns:
- the transformed expression
-
transformPropertyExpression
Rewrites property expressions that may resolve through static imports.- Parameters:
pe- the property expression to transform- Returns:
- the transformed expression
-
getSourceUnit
Returns the source unit currently being transformed.- Specified by:
getSourceUnitin classClassCodeVisitorSupport- Returns:
- the active source unit
-