Package: org.codehaus.groovy.transform.stc

## [Java] Class StaticTypeCheckingVisitor

- org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor

-     public class StaticTypeCheckingVisitor
      extends ClassCodeVisitorSupport

  The main class code visitor responsible for static type checking. It will perform various inspections like checking assignment types, type inference, ... Eventually, class nodes may be annotated with inferred type information.

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `StaticTypeCheckingVisitor.SignatureCodecFactory` |

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static MethodNode` | `CLOSURE_CALL_NO_ARG` |
    `static MethodNode` | `CLOSURE_CALL_ONE_ARG` |
    `static MethodNode` | `CLOSURE_CALL_VARGS` |
    `static Statement` | `GENERATED_EMPTY_STATEMENT` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StaticTypeCheckingVisitor(SourceUnit source, ClassNode classNode)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `addError(String msg, ASTNode expr)`
    `` | `public void` | `addTypeCheckingExtension(TypeCheckingExtension extension)`
    `` | `public static String` | `extractPropertyNameFromMethodName(String prefix, String methodName)` Given a method name and a prefix, returns the name of the property that should be looked up, following the java beans rules.
    `` | `public TypeCheckingContext` | `getTypeCheckingContext()` Returns the current type checking context.
    `` | `public static ClassNode` | `inferLoopElementType(ClassNode collectionType)` Returns the inferred loop element type given a loop collection type.
    `` | `public void` | `initialize()`
    `` | `public boolean` | `isSkipMode(AnnotatedNode node)`
    `` | `public void` | `performSecondPass()`
    `` | `public void` | `setCompilationUnit(CompilationUnit compilationUnit)`
    `` | `public void` | `setMethodsToBeVisited(Set<MethodNode> methodsToBeVisited)`
    `` | `public void` | `visitArrayExpression(ArrayExpression expression)`
    `` | `public void` | `visitAttributeExpression(AttributeExpression expression)`
    `` | `public void` | `visitBinaryExpression(BinaryExpression expression)`
    `` | `public void` | `visitBitwiseNegationExpression(BitwiseNegationExpression expression)`
    `` | `public void` | `visitBlockStatement(BlockStatement block)`
    `` | `public void` | `visitCaseStatement(CaseStatement statement)`
    `` | `public void` | `visitCastExpression(CastExpression expression)`
    `` | `public void` | `visitClass(ClassNode node)`
    `` | `public void` | `visitClassExpression(ClassExpression expression)`
    `` | `public void` | `visitClosingBlock(BlockStatement block)`
    `` | `public void` | `visitClosureExpression(ClosureExpression expression)`
    `` | `public void` | `visitClosureExpression(ClosureExpression expression)`
    `` | `public void` | `visitConstructor(ConstructorNode node)`
    `` | `public void` | `visitConstructorCallExpression(ConstructorCallExpression call)`
    `` | `public void` | `visitExpressionStatement(ExpressionStatement statement)`
    `` | `public void` | `visitField(FieldNode node)`
    `` | `public void` | `visitForLoop(ForStatement forLoop)`
    `` | `public void` | `visitIfElse(IfStatement ifElse)`
    `` | `public void` | `visitMethod(MethodNode node)`
    `` | `public void` | `visitMethodCallExpression(MethodCallExpression mce)`
    `` | `public void` | `visitMethodCallExpression(MethodCallExpression call)`
    `` | `public void` | `visitMethodPointerExpression(MethodPointerExpression expression)`
    `` | `public void` | `visitNotExpression(NotExpression expression)`
    `` | `public void` | `visitPostfixExpression(PostfixExpression expression)`
    `` | `public void` | `visitPrefixExpression(PrefixExpression expression)`
    `` | `public void` | `visitProperty(PropertyNode node)`
    `` | `public void` | `visitPropertyExpression(PropertyExpression expression)`
    `` | `public void` | `visitRangeExpression(RangeExpression expression)`
    `` | `public void` | `visitReturnStatement(ReturnStatement statement)`
    `` | `public void` | `visitReturnStatement(ReturnStatement returnStatement)`
    `` | `public void` | `visitStaticMethodCallExpression(StaticMethodCallExpression call)`
    `` | `public void` | `visitSwitch(SwitchStatement statement)`
    `` | `public void` | `visitTernaryExpression(TernaryExpression expression)`
    `` | `public void` | `visitTryCatchFinally(TryCatchStatement statement)`
    `` | `public void` | `visitUnaryMinusExpression(UnaryMinusExpression expression)`
    `` | `public void` | `visitUnaryPlusExpression(UnaryPlusExpression expression)`
    `` | `public void` | `visitVariableExpression(VariableExpression vexp)`
    `` | `public void` | `visitWhileLoop(WhileStatement loop)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassCodeVisitorSupport` | `addError, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitConstructor, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitPackage, visitProperty, visitReturnStatement, 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, 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

    - #### public static final MethodNode CLOSURE_CALL_NO_ARG

    - #### public static final MethodNode CLOSURE_CALL_ONE_ARG

    - #### public static final MethodNode CLOSURE_CALL_VARGS

    - #### public static final Statement GENERATED_EMPTY_STATEMENT

  - ### Constructor Detail

    - #### public StaticTypeCheckingVisitor(SourceUnit source, ClassNode classNode)

  - ### Method Detail

    - #### @Override
      public void addError(String msg, ASTNode expr)

    - #### public void addTypeCheckingExtension(TypeCheckingExtension extension)

    - #### public static String extractPropertyNameFromMethodName(String prefix, String methodName)

      Given a method name and a prefix, returns the name of the property that should be looked up, following the java beans rules. For example, "getName" would return "name", while "getFullName" would return "fullName". If the prefix is not found, returns null.

      Parameters:
        `prefix` - the method name prefix ("get", "is", "set", ...)
        `methodName` - the method name
      Returns:
        a property name if the prefix is found and the method matches the java beans rules, null otherwise

    - #### public TypeCheckingContext getTypeCheckingContext()

      Returns the current type checking context. The context is used internally by the type checker during type checking to store various state data.

      Returns:
        the type checking context

    - #### public static ClassNode inferLoopElementType(ClassNode collectionType)

      Returns the inferred loop element type given a loop collection type. Used, for example, to infer the element type of a `for (e in list)` loop.

      Parameters:
        `collectionType` - the type of the collection
      Returns:
        the inferred component type
      See Also:
        inferComponentType

    - #### public void initialize()

    - #### public boolean isSkipMode(AnnotatedNode node)

    - #### public void performSecondPass()

    - #### public void setCompilationUnit(CompilationUnit compilationUnit)

    - #### public void setMethodsToBeVisited(Set<MethodNode> methodsToBeVisited)

    - #### @Override
      public void visitArrayExpression(ArrayExpression expression)

    - #### @Override
      public void visitAttributeExpression(AttributeExpression expression)

    - #### @Override
      public void visitBinaryExpression(BinaryExpression expression)

    - #### @Override
      public void visitBitwiseNegationExpression(BitwiseNegationExpression expression)

    - #### @Override
      public void visitBlockStatement(BlockStatement block)

    - #### @Override
      public void visitCaseStatement(CaseStatement statement)

    - #### @Override
      public void visitCastExpression(CastExpression expression)

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

    - #### @Override
      public void visitClassExpression(ClassExpression expression)

    - #### public void visitClosingBlock(BlockStatement block)

    - #### @Override
      public void visitClosureExpression(ClosureExpression expression)

    - #### @Override
      public void visitClosureExpression(ClosureExpression expression)

    - #### @Override
      public void visitConstructor(ConstructorNode node)

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

    - #### @Override
      public void visitExpressionStatement(ExpressionStatement statement)

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

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

    - #### @Override
      public void visitIfElse(IfStatement ifElse)

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

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

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

    - #### @Override
      public void visitMethodPointerExpression(MethodPointerExpression expression)

    - #### @Override
      public void visitNotExpression(NotExpression expression)

    - #### @Override
      public void visitPostfixExpression(PostfixExpression expression)

    - #### @Override
      public void visitPrefixExpression(PrefixExpression expression)

    - #### @Override
      public void visitProperty(PropertyNode node)

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

    - #### @Override
      public void visitRangeExpression(RangeExpression expression)

    - #### @Override
      public void visitReturnStatement(ReturnStatement statement)

    - #### @Override
      public void visitReturnStatement(ReturnStatement returnStatement)

    - #### @Override
      public void visitStaticMethodCallExpression(StaticMethodCallExpression call)

    - #### @Override
      public void visitSwitch(SwitchStatement statement)

    - #### @Override
      public void visitTernaryExpression(TernaryExpression expression)

    - #### @Override
      public void visitTryCatchFinally(TryCatchStatement statement)

    - #### @Override
      public void visitUnaryMinusExpression(UnaryMinusExpression expression)

    - #### @Override
      public void visitUnaryPlusExpression(UnaryPlusExpression expression)

    - #### @Override
      public void visitVariableExpression(VariableExpression vexp)

    - #### @Override
      public void visitWhileLoop(WhileStatement loop)