public class StaticImportVisitor
extends ClassCodeExpressionTransformer
Visitor to resolve constants and method calls from static imports.
| Constructor and description |
|---|
StaticImportVisitor(ClassNode classNode, SourceUnit sourceUnit)Creates a visitor that rewrites references resolved through static imports. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected SourceUnit |
getSourceUnit()Returns the source unit currently being transformed. |
|
public Expression |
transform(Expression exp)Rewrites expressions that may target statically imported members. |
|
protected Expression |
transformBinaryExpression(BinaryExpression be)Rewrites binary expressions that may reference statically imported members. |
|
protected Expression |
transformClosureExpression(ClosureExpression ce)Rewrites default parameter expressions inside closures. |
|
protected Expression |
transformConstructorCallExpression(ConstructorCallExpression cce)Rewrites named-argument constructor calls that use statically imported members. |
|
protected Expression |
transformMethodCallExpression(MethodCallExpression mce)Rewrites implicit-this calls that resolve to statically imported methods or properties. |
|
protected Expression |
transformPropertyExpression(PropertyExpression pe)Rewrites property expressions that may resolve through static imports. |
|
protected Expression |
transformVariableExpression(VariableExpression ve)Rewrites variable expressions that resolve to statically imported fields or accessors. |
|
public void |
visitAnnotations(AnnotatedNode node)Marks annotation traversal so imported constants can be inlined safely. |
|
public void |
visitClass(ClassNode classNode, SourceUnit sourceUnit)Call StaticImportVisitor(ClassNode,SourceUnit) then visitClass(ClassNode). |
|
protected void |
visitConstructorOrMethod(MethodNode node, boolean isConstructor)Tracks the current method while transforming static-import references. |
Creates a visitor that rewrites references resolved through static imports.
classNode - the class currently being transformedsourceUnit - the source unit containing the classReturns the source unit currently being transformed.
Rewrites expressions that may target statically imported members.
exp - the expression to transformRewrites binary expressions that may reference statically imported members.
be - the binary expression to transformRewrites default parameter expressions inside closures.
ce - the closure expression to transformRewrites named-argument constructor calls that use statically imported members.
cce - the constructor call to transformRewrites implicit-this calls that resolve to statically imported methods or properties.
mce - the method call to transformRewrites property expressions that may resolve through static imports.
pe - the property expression to transformRewrites variable expressions that resolve to statically imported fields or accessors.
ve - the variable expression to transformMarks annotation traversal so imported constants can be inlined safely.
node - the annotated node whose annotations are being visitedCall StaticImportVisitor(ClassNode,SourceUnit) then visitClass(ClassNode).
Tracks the current method while transforming static-import references.
node - the method or constructor being visitedisConstructor - whether node is a constructorCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.