Package: org.codehaus.groovy.transform.sc

## [Java] Class StaticCompilationVisitor

- org.codehaus.groovy.transform.sc.StaticCompilationVisitor

- This visitor is responsible for amending the AST with static compilation metadata or transform the AST so that a class or a method can be statically compiled. It may also throw errors specific to static compilation which are not considered as an error at the type check pass. For example, usage of spread operator is not allowed in statically compiled portions of code, while it may be statically checked. Static compilation relies on static type checking, which explains why this visitor extends the type checker visitor.

  Authors:
    Cedric Champeau

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static MethodNode` | `ARRAYLIST_ADD_METHOD` |
    `static ClassNode` | `ARRAYLIST_CLASSNODE` |
    `static MethodNode` | `ARRAYLIST_CONSTRUCTOR` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class StaticTypeCheckingVisitor` | `CLOSUREPARAMS_CLASSNODE, CLOSURE_CALL_NO_ARG, CLOSURE_CALL_ONE_ARG, CLOSURE_CALL_VARGS, CURRENT_SIGNATURE_PROTOCOL, CURRENT_SIGNATURE_PROTOCOL_VERSION, DELEGATES_TO, DELEGATES_TO_TARGET, DGM_CLASSNODE, EMPTY_METHODNODE_LIST, ENUMERATION_TYPE, ERROR_COLLECTOR, GENERATED_EMPTY_STATEMENT, GET_DELEGATE, GET_OWNER, GET_THISOBJECT, ITERABLE_TYPE, LINKEDHASHMAP_CLASSNODE, MAP_ENTRY_TYPE, TYPECHECKED_CLASSNODE, TYPECHECKING_ANNOTATIONS, TYPECHECKING_INFO_NODE, currentField, currentProperty, extension, returnAdder, returnListener, typeCheckingContext`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StaticCompilationVisitor (org.codehaus.groovy.control.SourceUnit unit, ClassNode node)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected boolean` | `existsProperty(PropertyExpression pexp, boolean checkForReadOnly, ClassCodeVisitorSupport visitor)`
    `` | `protected MethodNode` | `findMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode... args)`
    `` | `protected ClassNode[]` | `getTypeCheckingAnnotations()`
    `` | `static boolean` | `isStaticallyCompiled(AnnotatedNode node)`
    `` | `void` | `visitClass(ClassNode node)`
    `` | `void` | `visitConstructorCallExpression(ConstructorCallExpression call)`
    `` | `void` | `visitForLoop(ForStatement forLoop)`
    `` | `void` | `visitMethod(MethodNode node)`
    `` | `void` | `visitMethodCallExpression(MethodCallExpression call)`
    `` | `void` | `visitPropertyExpression(PropertyExpression pexp)`
    `` | `void` | `visitSpreadExpression(SpreadExpression expression)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class StaticTypeCheckingVisitor` | `addAmbiguousErrorMessage, addAssignmentError, addCategoryMethodCallError, addClosureReturnType, addError, addNoMatchingMethodError, addReceivers, addStaticTypeError, addTypeCheckingExtension, addTypeCheckingInfoAnnotation, addUnsupportedPreOrPostfixExpressionError, areCategoryMethodCalls, checkCast, checkClosureParameters, checkForbiddenSpreadArgument, checkGroovyConstructorMap, checkGroovyStyleConstructor, checkGroovyStyleConstructor, checkReturnType, collectAllInterfaceMethodsByName, existsProperty, existsProperty, extractPropertyNameFromMethodName, extractTemporaryTypeInfoKey, extractTypesFromParameters, findCurrentInstanceOfClass, findInstanceOfNotReturnExpression, findMethod, findMethodOrFail, findMethodsWithGenerated, formatArgumentList, getArgumentTypes, getDelegationMetadata, getGroupOperationResultType, getInferredReturnType, getInferredReturnTypeFromWithClosureArgument, getOriginalDeclarationType, getResultType, getSourceUnit, getTemporaryTypesForExpression, getType, getTypeCheckingAnnotations, getTypeCheckingContext, hasRHSIncompleteGenericTypeInfo, hasSetter, inferClosureParameterTypes, inferComponentType, inferDiamondType, inferListExpressionType, inferLoopElementType, inferMapExpressionType, inferReturnTypeGenerics, inferReturnTypeGenerics, initialize, isClassInnerClassOrEqualTo, isClosureCall, isNullConstant, isSecondPassNeededForControlStructure, isSkipMode, isSkippedInnerClass, makeOwnerList, performSecondPass, popAssignmentTracking, prettyPrintMethodList, pushAssignmentTracking, pushInstanceOfTypeInfo, restoreVariableExpressionMetadata, saveVariableExpressionMetadata, setCompilationUnit, setMethodsToBeVisited, shouldSkipClassNode, shouldSkipMethodNode, silentlyVisitMethodNode, startMethodInference, storeInferredReturnType, storeInferredTypeForPropertyExpression, storeTargetMethod, storeType, typeCheckAssignment, typeCheckClosureCall, typeCheckMapConstructor, typeCheckMethodsWithGenericsOrFail, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitCaseStatement, visitCastExpression, visitClass, visitClassExpression, visitClosingBlock, visitClosureExpression, visitConstructor, visitConstructorCallExpression, visitConstructorOrMethod, visitField, visitForLoop, visitIfElse, visitInstanceofNot, visitMethod, visitMethodCallArguments, visitMethodCallExpression, visitPostfixExpression, visitPrefixExpression, visitProperty, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitStaticMethodCallExpression, visitSwitch, visitTernaryExpression, visitTryCatchFinally, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop, wrapTypeIfNecessary`
    `class ClassCodeVisitorSupport` | `addError, getSourceUnit, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`
    `class CodeVisitorSupport` | `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, visitListExpression, visitListOfExpressions, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Field Detail

    - #### public static final MethodNode ARRAYLIST_ADD_METHOD

    - #### public static final ClassNode ARRAYLIST_CLASSNODE

    - #### public static final MethodNode ARRAYLIST_CONSTRUCTOR

  - ### Constructor Detail

    - #### public StaticCompilationVisitor(org.codehaus.groovy.control.SourceUnit unit, ClassNode node)

  - ### Method Detail

    - #### @Override protected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly, ClassCodeVisitorSupport visitor)

    - #### @Override protected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode... args)

    - #### @Override protected ClassNode[] getTypeCheckingAnnotations()

    - #### public static boolean isStaticallyCompiled(AnnotatedNode node)

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

    - #### @Override public void visitConstructorCallExpression(ConstructorCallExpression call)

    - #### @Override public void visitForLoop(ForStatement forLoop)

    - #### @Override public void visitMethod(MethodNode node)

    - #### @Override public void visitMethodCallExpression(MethodCallExpression call)

    - #### @Override public void visitPropertyExpression(PropertyExpression pexp)

    - #### @Override public void visitSpreadExpression(SpreadExpression expression)