Package: org.codehaus.groovy.transform.sc.transformers

## [Java] Class StaticCompilationTransformer

- org.codehaus.groovy.transform.sc.transformers.StaticCompilationTransformer

-     public class StaticCompilationTransformer
      extends ClassCodeExpressionTransformer

  Some expressions use symbols as aliases to method calls (<<, +=, ...). In static compilation, if such a method call is found, we transform the original binary expression into a method call expression so that the call gets statically compiled.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected static ClassNode` | `BYTECODE_ADAPTER_CLASS` | Class node for ScriptBytecodeAdapter.
    `protected static Map<Integer, MethodNode>` | `BYTECODE_BINARY_ADAPTERS` | Comparison helpers on ScriptBytecodeAdapter keyed by Groovy token type.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StaticCompilationTransformer(SourceUnit unit, StaticTypeCheckingVisitor visitor)` Creates a static compilation transformer for the supplied source unit and visitor.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public ClassNode` | `getClassNode()` Returns the class currently enclosing the transformation context.
    `` | `protected SourceUnit` | `getSourceUnit()` Returns the source unit currently being transformed.
    `` | `public StaticTypesTypeChooser` | `getTypeChooser()` Returns the type chooser used by this transformer.
    `` | `public Expression` | `transform(Expression expr)` Dispatches expression transformation to the specialized helper for the expression type.
    `` | `public void` | `visitClass(ClassNode node)` Visits a class and then recursively visits its inner classes.
    `` | `public void` | `visitClassCodeContainer(Statement code)` Visits a statement container within the current class or method.
    `` | `protected void` | `visitConstructorOrMethod(MethodNode node, boolean isConstructor)` Visits a constructor or method unless it is explicitly marked to skip static compilation.
    `` | `public void` | `visitField(FieldNode node)` Preserves constant field initializers that must remain inline for later compilation phases.

  - ### 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`

- - ### Field Detail

    - #### protected static final ClassNode BYTECODE_ADAPTER_CLASS

      Class node for ScriptBytecodeAdapter.

    - #### protected static final Map<Integer, MethodNode> BYTECODE_BINARY_ADAPTERS

      Comparison helpers on ScriptBytecodeAdapter keyed by Groovy token type.

  - ### Constructor Detail

    - #### public StaticCompilationTransformer(SourceUnit unit, StaticTypeCheckingVisitor visitor)

      Creates a static compilation transformer for the supplied source unit and visitor.

      Parameters:
        `unit` - the source unit being transformed
        `visitor` - the visitor providing type-checking metadata

  - ### Method Detail

    - #### public ClassNode getClassNode()

      Returns the class currently enclosing the transformation context.

      Returns:
        the current enclosing class node

    - #### protected SourceUnit getSourceUnit()

      Returns the source unit currently being transformed.

      Returns:
        the active source unit

    - #### public StaticTypesTypeChooser getTypeChooser()

      Returns the type chooser used by this transformer.

      Returns:
        the static types type chooser

    - #### public Expression transform(Expression expr)

      Dispatches expression transformation to the specialized helper for the expression type.

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

    - #### public void visitClass(ClassNode node)

      Visits a class and then recursively visits its inner classes.

      Parameters:
        `node` - the class node to process

    - #### public void visitClassCodeContainer(Statement code)

      Visits a statement container within the current class or method.

      Parameters:
        `code` - the code container to visit

    - #### protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)

      Visits a constructor or method unless it is explicitly marked to skip static compilation.

      Parameters:
        `node` - the method or constructor to process
        `isConstructor` - whether `node` is a constructor

    - #### public void visitField(FieldNode node)

      Preserves constant field initializers that must remain inline for later compilation phases.

      Parameters:
        `node` - the field to process