Package: org.codehaus.groovy.control

## [Java] Class StaticImportVisitor

- org.codehaus.groovy.control.StaticImportVisitor

-     public class StaticImportVisitor
      extends ClassCodeExpressionTransformer

  Visitor to resolve constants and method calls from static imports.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `StaticImportVisitor(ClassNode classNode, SourceUnit sourceUnit)` Creates a visitor that rewrites references resolved through static imports.

  - ### Methods Summary

    Methods
    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.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassCodeExpressionTransformer` | `setSourcePosition, transform, visitAnnotation, visitAssertStatement, visitCaseStatement, visitClosureExpression, visitConstructorOrMethod, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitProperty, visitReturnStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitWhileLoop`
    `class ClassCodeVisitorSupport` | `addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitClosureExpression, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitStatementAnnotations, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`
    `class CodeVisitorSupport` | `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`

- - ### Constructor Detail

    - #### public StaticImportVisitor(ClassNode classNode, SourceUnit sourceUnit)

      Creates a visitor that rewrites references resolved through static imports.

      Parameters:
        `classNode` - the class currently being transformed
        `sourceUnit` - the source unit containing the class

  - ### Method Detail

    - #### protected SourceUnit getSourceUnit()

      Returns the source unit currently being transformed.

      Returns:
        the active source unit

    - #### public Expression transform(Expression exp)

      Rewrites expressions that may target statically imported members.

      Parameters:
        `exp` - the expression to transform
      Returns:
        the transformed expression

    - #### protected Expression transformBinaryExpression(BinaryExpression be)

      Rewrites binary expressions that may reference statically imported members.

      Parameters:
        `be` - the binary expression to transform
      Returns:
        the transformed expression

    - #### protected Expression transformClosureExpression(ClosureExpression ce)

      Rewrites default parameter expressions inside closures.

      Parameters:
        `ce` - the closure expression to transform
      Returns:
        the transformed expression

    - #### protected Expression transformConstructorCallExpression(ConstructorCallExpression cce)

      Rewrites named-argument constructor calls that use statically imported members.

      Parameters:
        `cce` - the constructor call to transform
      Returns:
        the transformed expression

    - #### protected Expression transformMethodCallExpression(MethodCallExpression mce)

      Rewrites implicit-this calls that resolve to statically imported methods or properties.

      Parameters:
        `mce` - the method call to transform
      Returns:
        the transformed expression

    - #### protected Expression transformPropertyExpression(PropertyExpression pe)

      Rewrites property expressions that may resolve through static imports.

      Parameters:
        `pe` - the property expression to transform
      Returns:
        the transformed expression

    - #### protected Expression transformVariableExpression(VariableExpression ve)

      Rewrites variable expressions that resolve to statically imported fields or accessors.

      Parameters:
        `ve` - the variable expression to transform
      Returns:
        the transformed expression

    - #### public void visitAnnotations(AnnotatedNode node)

      Marks annotation traversal so imported constants can be inlined safely.

      Parameters:
        `node` - the annotated node whose annotations are being visited

    - #### @Deprecated
      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.

      Parameters:
        `node` - the method or constructor being visited
        `isConstructor` - whether `node` is a constructor