Package: org.codehaus.groovy.transform.stc

## [Java] Class StaticTypeCheckingSupport

- org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport

-     public abstract class StaticTypeCheckingSupport
      extends Object

  Support methods for StaticTypeCheckingVisitor.

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `StaticTypeCheckingSupport.BooleanArrayStaticTypesHelper` |
    `static class` | `StaticTypeCheckingSupport.ByteArrayStaticTypesHelper` |
    `static class` | `StaticTypeCheckingSupport.CharArrayStaticTypesHelper` |
    `static class` | `StaticTypeCheckingSupport.DoubleArrayStaticTypesHelper` |
    `static class` | `StaticTypeCheckingSupport.FloatArrayStaticTypesHelper` |
    `static class` | `StaticTypeCheckingSupport.IntArrayStaticTypesHelper` |
    `static class` | `StaticTypeCheckingSupport.LongArrayStaticTypesHelper` |
    `static class` | `StaticTypeCheckingSupport.ObjectArrayStaticTypesHelper` | A DGM-like class which adds support for method calls which are handled specifically by the Groovy compiler.
    `static class` | `StaticTypeCheckingSupport.ShortArrayStaticTypesHelper` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static int` | `allParametersAndArgumentsMatch(Parameter[] parameters, ClassNode[] argumentTypes)` Checks that arguments and parameter types match.
    `` | `public static boolean` | `checkCompatibleAssignmentTypes(ClassNode left, ClassNode right)` Returns true or false depending on whether the right classnode can be assigned to the left classnode.
    `` | `public static boolean` | `checkCompatibleAssignmentTypes(ClassNode left, ClassNode right, Expression rightExpression)`
    `` | `public static boolean` | `checkCompatibleAssignmentTypes(ClassNode left, ClassNode right, Expression rightExpression, boolean allowConstructorCoercion)` Everything that can be done by `castToType` should be allowed for assignment.
    `` | `public static List<MethodNode>` | `chooseBestMethod(ClassNode receiver, Collection<MethodNode> methods, ClassNode argumentTypes)` Returns the method(s) which best fit the argument types.
    `` | `public static void` | `clearExtensionMethodCache()`
    `` | `public static void` | `clearExtensionMethodCache(ClassLoader loader)`
    `` | `public static Set<ClassNode>` | `collectAllInterfaces(ClassNode node)` Collects all interfaces of a class node, including those defined by the super class.
    `` | `public static Object` | `evaluateExpression(Expression expr, CompilerConfiguration config)` A helper method that can be used to evaluate expressions as found in annotation parameters.
    `` | `public static List<MethodNode>` | `filterMethodsByVisibility(List<MethodNode> methodNodeList, ClassNode enclosingClassNode)` Filter methods according to visibility
    `` | `public static List<MethodNode>` | `findDGMMethodsByNameAndArguments(ClassNode receiver, String name, ClassNode[] args)` deprecated: Use findDGMMethodsByNameAndArguments(ClassLoader, ClassNode, String, ClassNode[], List) instead
    `` | `public static List<MethodNode>` | `findDGMMethodsByNameAndArguments(ClassLoader loader, ClassNode receiver, String name, ClassNode[] args)`
    `` | `public static List<MethodNode>` | `findDGMMethodsByNameAndArguments(ClassNode receiver, String name, ClassNode[] args, List<MethodNode> methods)` deprecated: Use findDGMMethodsByNameAndArguments(ClassLoader, ClassNode, String, ClassNode[], List) instead
    `` | `public static List<MethodNode>` | `findDGMMethodsByNameAndArguments(ClassLoader loader, ClassNode receiver, String name, ClassNode[] args, List<MethodNode> methods)`
    `` | `public static Set<MethodNode>` | `findDGMMethodsForClassNode(ClassLoader loader, ClassNode clazz, String name)`
    `` | `public static List<MethodNode>` | `findSetters(ClassNode cn, String setterName, boolean voidOnly)`
    `` | `public static ClassNode` | `getCorrectedClassNode(ClassNode cn, ClassNode sc, boolean completed)`
    `` | `public static boolean` | `implementsInterfaceOrIsSubclassOf(ClassNode type, ClassNode superOrInterface)`
    `` | `public static boolean` | `isAssignableTo(ClassNode type, ClassNode toBeAssignedTo)` Checks if a class node is assignable to another.
    `` | `public static boolean` | `isAssignment(int op)`
    `` | `public static boolean` | `isBeingCompiled(ClassNode node)`
    `` | `public static boolean` | `isClassClassNodeWrappingConcreteType(ClassNode classNode)` Returns true if the class node represents a the class node for the Class class and if the parametrized type is a neither a placeholder or a wildcard.
    `` | `public static boolean` | `isCompareToBoolean(int op)`
    `` | `public static boolean` | `isGStringOrGStringStringLUB(ClassNode node)` Returns: true if the class node is either a GString or the LUB of String and GString.
    `` | `public static boolean` | `isParameterizedWithGStringOrGStringString(ClassNode node)` Parameters: `node` - the node to be tested
    `` | `public static boolean` | `isParameterizedWithString(ClassNode node)` Parameters: `node` - the node to be tested
    `` | `public static ClassNode` | `isTraitSelf(VariableExpression vexp)`
    `` | `public static boolean` | `isUnboundedWildcard(GenericsType gt)`
    `` | `public static boolean` | `isUsingGenericsOrIsArrayUsingGenerics(ClassNode cn)` Returns true if a class makes use of generic types.
    `` | `public static boolean` | `isUsingUncheckedGenerics(ClassNode node)` Returns true if the provided class node, when considered as a receiver of a message or as a parameter, is using a placeholder in its generics type.
    `` | `public static boolean` | `isWildcardLeftHandSide(ClassNode node)` Tells if a class is one of the "accept all" classes as the left hand side of an assignment.
    `` | `public static boolean` | `isWithCall(String name, Expression arguments)` Called on method call checks in order to determine if a method call corresponds to the idiomatic o.with { ... } structure
    `` | `public static boolean` | `missesGenericsTypes(ClassNode cn)` Determines if node is a raw type or references any generics placeholders.
    `` | `public static Parameter[]` | `parameterizeArguments(ClassNode receiver, MethodNode m)` Given a receiver and a method node, parameterize the method arguments using available generic type information.
    `` | `public static ClassNode` | `resolveClassNodeGenerics(Map<GenericsTypeName, GenericsType> resolvedPlaceholders, Map<GenericsTypeName, GenericsType> placeholdersFromContext, ClassNode currentType)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Method Detail

    - #### public static int allParametersAndArgumentsMatch(Parameter[] parameters, ClassNode[] argumentTypes)

      Checks that arguments and parameter types match.

      Returns:
        -1 if arguments do not match, 0 if arguments are of the exact type and > 0 when one or more argument is not of the exact type but still match

    - #### public static boolean checkCompatibleAssignmentTypes(ClassNode left, ClassNode right)

      Returns true or false depending on whether the right classnode can be assigned to the left classnode. This method should not add errors by itself: we let the caller decide what to do if an incompatible assignment is found.

      Parameters:
        `left` - the class to be assigned to
        `right` - the assignee class
      Returns:
        false if types are incompatible

    - #### public static boolean checkCompatibleAssignmentTypes(ClassNode left, ClassNode right, Expression rightExpression)

    - #### public static boolean checkCompatibleAssignmentTypes(ClassNode left, ClassNode right, Expression rightExpression, boolean allowConstructorCoercion)

      Everything that can be done by `castToType` should be allowed for assignment.

      See Also:
        DefaultTypeTransformation.castToType

    - #### public static List<MethodNode> chooseBestMethod(ClassNode receiver, Collection<MethodNode> methods, ClassNode argumentTypes)

      Returns the method(s) which best fit the argument types.

      Returns:
        zero or more results

    - #### public static void clearExtensionMethodCache()

    - #### public static void clearExtensionMethodCache(ClassLoader loader)

    - #### @Deprecated
      public static Set<ClassNode> collectAllInterfaces(ClassNode node)

      Collects all interfaces of a class node, including those defined by the super class.

      Parameters:
        `node` - a class for which we want to retrieve all interfaces
      Returns:
        a set of interfaces implemented by this class node

    - #### public static Object evaluateExpression(Expression expr, CompilerConfiguration config)

      A helper method that can be used to evaluate expressions as found in annotation parameters. For example, it will evaluate a constant, be it referenced directly as an integer or as a reference to a field.

      If this method throws an exception, then the expression cannot be evaluated on its own.

      Parameters:
        `expr` - the expression to be evaluated
        `config` - the compiler configuration
      Returns:
        the result of the expression

    - #### public static List<MethodNode> filterMethodsByVisibility(List<MethodNode> methodNodeList, ClassNode enclosingClassNode)

      Filter methods according to visibility

      Parameters:
        `methodNodeList` - method nodes to filter
        `enclosingClassNode` - the enclosing class
      Returns:
        filtered method nodes
      Since:
        3.0.0

    - #### @Deprecated
      public static List<MethodNode> findDGMMethodsByNameAndArguments(ClassNode receiver, String name, ClassNode[] args)

      deprecated:
        Use findDGMMethodsByNameAndArguments(ClassLoader, ClassNode, String, ClassNode[], List) instead

    - #### public static List<MethodNode> findDGMMethodsByNameAndArguments(ClassLoader loader, ClassNode receiver, String name, ClassNode[] args)

    - #### @Deprecated
      public static List<MethodNode> findDGMMethodsByNameAndArguments(ClassNode receiver, String name, ClassNode[] args, List<MethodNode> methods)

      deprecated:
        Use findDGMMethodsByNameAndArguments(ClassLoader, ClassNode, String, ClassNode[], List) instead

    - #### public static List<MethodNode> findDGMMethodsByNameAndArguments(ClassLoader loader, ClassNode receiver, String name, ClassNode[] args, List<MethodNode> methods)

    - #### public static Set<MethodNode> findDGMMethodsForClassNode(ClassLoader loader, ClassNode clazz, String name)

    - #### public static List<MethodNode> findSetters(ClassNode cn, String setterName, boolean voidOnly)

    - #### @Deprecated
      public static ClassNode getCorrectedClassNode(ClassNode cn, ClassNode sc, boolean completed)

    - #### public static boolean implementsInterfaceOrIsSubclassOf(ClassNode type, ClassNode superOrInterface)

    - #### public static boolean isAssignableTo(ClassNode type, ClassNode toBeAssignedTo)

      Checks if a class node is assignable to another. This is used for example in assignment checks where you want to verify that the assignment is valid.

      Returns:
        true if the class node is assignable to the other class node, false otherwise

    - #### public static boolean isAssignment(int op)

    - #### public static boolean isBeingCompiled(ClassNode node)

    - #### public static boolean isClassClassNodeWrappingConcreteType(ClassNode classNode)

      Returns true if the class node represents a the class node for the Class class and if the parametrized type is a neither a placeholder or a wildcard. For example, the class node Class<Foo> where Foo is a class would return true, but the class node for Class<?> would return false.

      Parameters:
        `classNode` - a class node to be tested
      Returns:
        true if it is the class node for Class and its generic type is a real class

    - #### public static boolean isCompareToBoolean(int op)

    - #### public static boolean isGStringOrGStringStringLUB(ClassNode node)

      Returns:
        true if the class node is either a GString or the LUB of String and GString.

    - #### public static boolean isParameterizedWithGStringOrGStringString(ClassNode node)

      Parameters:
        `node` - the node to be tested
      Returns:
        true if the node is using generics types and one of those types is a gstring or string/gstring lub

    - #### public static boolean isParameterizedWithString(ClassNode node)

      Parameters:
        `node` - the node to be tested
      Returns:
        true if the node is using generics types and one of those types is a string

    - #### public static ClassNode isTraitSelf(VariableExpression vexp)

    - #### public static boolean isUnboundedWildcard(GenericsType gt)

    - #### public static boolean isUsingGenericsOrIsArrayUsingGenerics(ClassNode cn)

      Returns true if a class makes use of generic types. If node represents an array type, then checks if the component type is using generics.

      Parameters:
        `cn` - a class node for which to check if it is using generics
      Returns:
        true if the type (or component type) is using generics

    - #### public static boolean isUsingUncheckedGenerics(ClassNode node)

      Returns true if the provided class node, when considered as a receiver of a message or as a parameter, is using a placeholder in its generics type. In this case, we're facing unchecked generics and type checking is limited (ex: void foo(Set s) { s.keySet() }

      Parameters:
        `node` - the node to test
      Returns:
        true if it is using any placeholder in generics types

    - #### public static boolean isWildcardLeftHandSide(ClassNode node)

      Tells if a class is one of the "accept all" classes as the left hand side of an assignment.

      Parameters:
        `node` - the classnode to test
      Returns:
        true if it's an Object, String, boolean, Boolean or Class.

    - #### public static boolean isWithCall(String name, Expression arguments)

      Called on method call checks in order to determine if a method call corresponds to the idiomatic o.with { ... } structure

      Parameters:
        `name` - name of the method called
        `arguments` - method call arguments
      Returns:
        true if the name is "with" and arguments consist of a single closure

    - #### public static boolean missesGenericsTypes(ClassNode cn)

      Determines if node is a raw type or references any generics placeholders.

    - #### public static Parameter[] parameterizeArguments(ClassNode receiver, MethodNode m)

      Given a receiver and a method node, parameterize the method arguments using available generic type information.

      Parameters:
        `receiver` - the class
        `m` - the method
      Returns:
        the parameterized arguments

    - #### public static ClassNode resolveClassNodeGenerics(Map<GenericsTypeName, GenericsType> resolvedPlaceholders, Map<GenericsTypeName, GenericsType> placeholdersFromContext, ClassNode currentType)