public abstract class StaticTypeCheckingSupport extends Object
Support methods for StaticTypeCheckingVisitor.
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 |
Modifiers | Name | Description |
---|---|---|
protected static ClassNode |
ArrayList_TYPE |
|
protected static ClassNode |
Collection_TYPE |
|
protected static Comparator<MethodNode> |
DGM_METHOD_NODE_COMPARATOR |
This comparator is used when we return the list of methods from DGM which name correspond to a given name. |
protected static ClassNode |
Deprecated_TYPE |
|
protected static ExtensionMethodCache |
EXTENSION_METHOD_CACHE |
|
protected static ClassNode |
GSTRING_STRING_CLASSNODE |
|
protected static ClassNode |
LinkedHashMap_TYPE |
|
protected static ClassNode |
LinkedHashSet_TYPE |
|
protected static ClassNode |
Matcher_TYPE |
|
protected static Map<String, Integer> |
NUMBER_OPS |
|
protected static Map<ClassNode, Integer> |
NUMBER_TYPES |
|
protected static ClassNode |
UNKNOWN_PARAMETER_TYPE |
This is for internal use only. |
Type Params | Return Type | Name and description |
---|---|---|
|
public static int |
allParametersAndArgumentsMatch(Parameter[] parameters, ClassNode[] argumentTypes) Determines if the specific argument types fit the parameters. |
|
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 int |
compare(MethodNode o1, MethodNode o2) |
|
public static Object |
evaluateExpression(Expression expr, CompilerConfiguration config) Evaluates expressions as found in annotation parameters. |
|
public static Object |
evaluateExpression(Expression expr, CompilerConfiguration config, GroovyClassLoader loader) Evaluates 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)
|
|
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)
|
|
public static List<MethodNode> |
findDGMMethodsByNameAndArguments(ClassLoader loader, ClassNode receiver, String name, ClassNode[] args, List<MethodNode> methods) |
|
protected static Set<MethodNode> |
findDGMMethodsForClassNode(ClassNode clazz, String name)
|
|
public static Set<MethodNode> |
findDGMMethodsForClassNode(ClassLoader loader, ClassNode clazz, String name) |
|
protected static void |
findDGMMethodsForClassNode(ClassNode clazz, String name, TreeSet<MethodNode> accumulator)
|
|
protected static void |
findDGMMethodsForClassNode(ClassLoader loader, ClassNode clazz, String name, TreeSet<MethodNode> accumulator) |
|
public static List<MethodNode> |
findSetters(ClassNode cn, String setterName, boolean voidOnly) |
|
protected static Variable |
findTargetVariable(VariableExpression ve) Given a variable expression, returns the ultimately accessed variable. |
|
protected static GenericsType |
fullyResolve(GenericsType gt, Map<GenericsTypeName, GenericsType> placeholders) Given a generics type representing SomeClass<T,V> and a resolved placeholder map, returns a new generics type for which placeholders are resolved recursively. |
|
protected static ClassNode |
fullyResolveType(ClassNode type, Map<GenericsTypeName, GenericsType> placeholders) |
|
public static ClassNode |
getCorrectedClassNode(ClassNode type, ClassNode superClass, boolean handlingGenerics) |
|
public static boolean |
implementsInterfaceOrIsSubclassOf(ClassNode type, ClassNode superOrInterface) |
|
protected static boolean |
isArrayAccessExpression(Expression expression) Returns true for expressions of the form x[...] |
|
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)
|
|
public static boolean |
isParameterizedWithGStringOrGStringString(ClassNode node)
|
|
public static boolean |
isParameterizedWithString(ClassNode node)
|
|
public static ClassNode |
isTraitSelf(VariableExpression vexp) |
|
public static boolean |
isUnboundedWildcard(GenericsType gt) |
|
public static boolean |
isUsingGenericsOrIsArrayUsingGenerics(ClassNode cn) Returns true if a class node 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) |
|
protected static boolean |
typeCheckMethodArgumentWithGenerics(ClassNode parameterType, ClassNode argumentType, boolean lastArg) Checks that the parameterized generics of an argument are compatible with the generics of the parameter. |
|
protected static boolean |
typeCheckMethodsWithGenerics(ClassNode receiver, ClassNode[] argumentTypes, MethodNode candidateMethod) |
This comparator is used when we return the list of methods from DGM which name correspond to a given name. As we also lookup for DGM methods of superclasses or interfaces, it may be possible to find two methods which have the same name and the same arguments. In that case, we should not add the method from superclass or interface otherwise the system won't be able to select the correct method, resulting in an ambiguous method selection for similar methods.
This is for internal use only. When an argument method is null, we cannot determine its type, so we use this one as a wildcard.
Determines if the specific argument types fit the parameters.
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.
left
- the class to be assigned toright
- the assignee class Everything that can be done by castToType
should be allowed for assignment.
Returns the method(s) which best fit the argument types.
Collects all interfaces of a class node, including those defined by the super class.
node
- a class for which we want to retrieve all interfacesEvaluates 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 the expression cannot be evaluated on its own, an exception is thrown.
expr
- the expression to be evaluatedconfig
- the compiler configurationEvaluates 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 the expression cannot be evaluated on its own, an exception is thrown.
expr
- the expression to be evaluatedconfig
- the compiler configurationloader
- the compiler class loaderFilter methods according to visibility
methodNodeList
- method nodes to filterenclosingClassNode
- the enclosing classGiven a variable expression, returns the ultimately accessed variable.
ve
- a variable expressionGiven a generics type representing SomeClass<T,V> and a resolved placeholder map, returns a new generics type for which placeholders are resolved recursively.
Returns true for expressions of the form x[...]
expression
- an expressionChecks 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 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.
classNode
- a class node to be tested
node
- the node to be tested
node
- the node to be testedReturns true if a class node makes use of generic types. If the class node represents an array type, then checks if the component type is using generics.
cn
- a class node for which to check if it is using genericsReturns 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() }
node
- the node to testTells if a class is one of the "accept all" classes as the left hand side of an assignment.
node
- the classnode to testCalled on method call checks in order to determine if a method call corresponds to the idiomatic o.with { ... } structure
name
- name of the method calledarguments
- method call argumentsDetermines if node is a raw type or references any generics placeholders.
Given a receiver and a method node, parameterize the method arguments using available generic type information.
receiver
- the classm
- the methodChecks that the parameterized generics of an argument are compatible with the generics of the parameter.
parameterType
- the parameter type of a methodargumentType
- the type of the argument passed to the method