StaticCompilationVisitor (Groovy 2.4.16)
Date: 2018-12-09

org.codehaus.groovy.transform.sc

## Class StaticCompilationVisitor

- java.lang.Object
- - org.codehaus.groovy.ast.CodeVisitorSupport
  - - org.codehaus.groovy.ast.ClassCodeVisitorSupport
    - - org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor
      - - org.codehaus.groovy.transform.sc.StaticCompilationVisitor

- All Implemented Interfaces:
    GroovyClassVisitor, GroovyCodeVisitor

      public class StaticCompilationVisitor
      extends StaticTypeCheckingVisitor

  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.
  Author:
    Cedric Champeau

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor

      `StaticTypeCheckingVisitor.SignatureCodecFactory, StaticTypeCheckingVisitor.VariableExpressionTypeMemoizer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static MethodNode` | `ARRAYLIST_ADD_METHOD`
    `static ClassNode` | `ARRAYLIST_CLASSNODE`
    `static MethodNode` | `ARRAYLIST_CONSTRUCTOR`

    - ### Fields inherited from class org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor

      `CLOSURE_CALL_NO_ARG, CLOSURE_CALL_ONE_ARG, CLOSURE_CALL_VARGS, CLOSUREPARAMS_CLASSNODE, CURRENT_SIGNATURE_PROTOCOL, CURRENT_SIGNATURE_PROTOCOL_VERSION, currentField, currentProperty, DELEGATES_TO, DELEGATES_TO_TARGET, DGM_CLASSNODE, EMPTY_METHODNODE_LIST, ENUMERATION_TYPE, ERROR_COLLECTOR, extension, GENERATED_EMPTY_STATEMENT, GET_DELEGATE, GET_OWNER, GET_THISOBJECT, ITERABLE_TYPE, LINKEDHASHMAP_CLASSNODE, MAP_ENTRY_TYPE, returnAdder, returnListener, TYPECHECKING_ANNOTATIONS, TYPECHECKING_INFO_NODE, typeCheckingContext`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StaticCompilationVisitor(SourceUnit unit, ClassNode node)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `existsProperty(PropertyExpression pexp, boolean checkForReadOnly, ClassCodeVisitorSupport visitor)` Checks whether a property exists on the receiver, or on any of the possible receiver classes (found in the temporary type information table)
    `protected MethodNode` | `findMethodOrFail(Expression expr, ClassNode receiver, java.lang.String name, ClassNode... args)`
    `protected ClassNode[]` | `getTypeCheckingAnnotations()` Returns the list of type checking annotations class nodes.
    `static boolean` | `isStaticallyCompiled(AnnotatedNode node)`
    `void` | `visitClass(ClassNode node)` Visit a ClassNode.
    `void` | `visitConstructorCallExpression(ConstructorCallExpression call)`
    `void` | `visitForLoop(ForStatement forLoop)`
    `void` | `visitMethod(MethodNode node)` Visit a MethodNode.
    `void` | `visitMethodCallExpression(MethodCallExpression call)`
    `void` | `visitPropertyExpression(PropertyExpression pexp)`
    `void` | `visitSpreadExpression(SpreadExpression expression)`

    - ### Methods inherited from class org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor

      `addAmbiguousErrorMessage, addAssignmentError, addCategoryMethodCallError, addClosureReturnType, addError, addNoMatchingMethodError, addReceivers, addStaticTypeError, addTypeCheckingExtension, addTypeCheckingInfoAnnotation, addUnsupportedPreOrPostfixExpressionError, areCategoryMethodCalls, checkCast, checkClosureParameters, checkForbiddenSpreadArgument, checkGroovyConstructorMap, checkGroovyStyleConstructor, checkGroovyStyleConstructor, checkReturnType, collectAllInterfaceMethodsByName, existsProperty, extractPropertyNameFromMethodName, extractTemporaryTypeInfoKey, extractTypesFromParameters, findCurrentInstanceOfClass, findMethod, findMethodsWithGenerated, formatArgumentList, getArgumentTypes, getDelegationMetadata, getGroupOperationResultType, getInferredReturnType, getInferredReturnTypeFromWithClosureArgument, getOriginalDeclarationType, getResultType, getSourceUnit, getTemporaryTypesForExpression, getType, 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, visitCaseStatement, visitCastExpression, visitClassExpression, visitClosureExpression, visitConstructor, visitConstructorOrMethod, visitField, visitIfElse, visitMethodCallArguments, visitPostfixExpression, visitPrefixExpression, visitProperty, visitRangeExpression, visitReturnStatement, visitStaticMethodCallExpression, visitSwitch, visitTernaryExpression, visitTryCatchFinally, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop, wrapTypeIfNecessary`

    - ### Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport

      `visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCatchStatement, visitClassCodeContainer, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitImports, visitObjectInitializerStatements, visitPackage, visitStatement, visitSynchronizedStatement, visitThrowStatement`

    - ### Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

      `visitArgumentlistExpression, visitArrayExpression, visitBooleanExpression, visitBytecodeExpression, visitClosureListExpression, visitConstantExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitListExpression, visitListOfExpressions, visitMapEntryExpression, visitMapExpression, visitMethodPointerExpression, visitNotExpression, visitShortTernaryExpression, visitSpreadMapExpression, visitTupleExpression`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ARRAYLIST_CLASSNODE

          public static final ClassNode ARRAYLIST_CLASSNODE

    - #### ARRAYLIST_CONSTRUCTOR

          public static final MethodNode ARRAYLIST_CONSTRUCTOR

    - #### ARRAYLIST_ADD_METHOD

          public static final MethodNode ARRAYLIST_ADD_METHOD

  - ### Constructor Detail

    - #### StaticCompilationVisitor

          public StaticCompilationVisitor(SourceUnit unit,
                                          ClassNode node)

  - ### Method Detail

    - #### getTypeCheckingAnnotations

          protected ClassNode[] getTypeCheckingAnnotations()

      Description copied from class: `StaticTypeCheckingVisitor`
      Returns the list of type checking annotations class nodes. Subclasses may override this method in order to provide additional classes which must be looked up when checking if a method or a class node should be skipped.

      The default implementation returns `TypeChecked`.

      Overrides:
        `getTypeCheckingAnnotations` in class `StaticTypeCheckingVisitor`
      Returns:
        array of class nodes

    - #### isStaticallyCompiled

          public static boolean isStaticallyCompiled(AnnotatedNode node)

    - #### visitClass

          public void visitClass(ClassNode node)

      Description copied from interface: `GroovyClassVisitor`
      Visit a ClassNode.
      Specified by:
        `visitClass` in interface `GroovyClassVisitor`
      Overrides:
        `visitClass` in class `StaticTypeCheckingVisitor`

    - #### visitMethod

          public void visitMethod(MethodNode node)

      Description copied from interface: `GroovyClassVisitor`
      Visit a MethodNode.
      Specified by:
        `visitMethod` in interface `GroovyClassVisitor`
      Overrides:
        `visitMethod` in class `StaticTypeCheckingVisitor`

    - #### visitSpreadExpression

          public void visitSpreadExpression(SpreadExpression expression)

      Specified by:
        `visitSpreadExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitSpreadExpression` in class `CodeVisitorSupport`

    - #### visitMethodCallExpression

          public void visitMethodCallExpression(MethodCallExpression call)

      Specified by:
        `visitMethodCallExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitMethodCallExpression` in class `StaticTypeCheckingVisitor`

    - #### visitConstructorCallExpression

          public void visitConstructorCallExpression(ConstructorCallExpression call)

      Specified by:
        `visitConstructorCallExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitConstructorCallExpression` in class `StaticTypeCheckingVisitor`

    - #### visitForLoop

          public void visitForLoop(ForStatement forLoop)

      Specified by:
        `visitForLoop` in interface `GroovyCodeVisitor`
      Overrides:
        `visitForLoop` in class `StaticTypeCheckingVisitor`

    - #### findMethodOrFail

          protected MethodNode findMethodOrFail(Expression expr,
                                                ClassNode receiver,
                                                java.lang.String name,
                                                ClassNode... args)

      Overrides:
        `findMethodOrFail` in class `StaticTypeCheckingVisitor`

    - #### existsProperty

          protected boolean existsProperty(PropertyExpression pexp,
                                           boolean checkForReadOnly,
                                           ClassCodeVisitorSupport visitor)

      Description copied from class: `StaticTypeCheckingVisitor`
      Checks whether a property exists on the receiver, or on any of the possible receiver classes (found in the temporary type information table)
      Overrides:
        `existsProperty` in class `StaticTypeCheckingVisitor`
      Parameters:
        `pexp` - a property expression
        `checkForReadOnly` - if true, look for property read, else for property set
        `visitor` - if not null, when the property node is found, visit it with the provided visitor
      Returns:
        true if the property is defined in any of the possible receiver classes

    - #### visitPropertyExpression

          public void visitPropertyExpression(PropertyExpression pexp)

      Specified by:
        `visitPropertyExpression` in interface `GroovyCodeVisitor`
      Overrides:
        `visitPropertyExpression` in class `StaticTypeCheckingVisitor`