Groovy 2.0.0-rc-4

org.codehaus.groovy.transform.stc
[Java] Class StaticTypeCheckingSupport

java.lang.Object
  org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport

public abstract class StaticTypeCheckingSupport
extends Object

Static support methods for StaticTypeCheckingVisitor.


Method Summary
static int allParametersAndArgumentsMatch(Parameter[] params, ClassNode[] args)

Checks that arguments and parameter types match.

static boolean checkCompatibleAssignmentTypes(ClassNode left, ClassNode right)

Returns true or false depending on whether the right classnode can be assigned to the left classnode.

static boolean checkCompatibleAssignmentTypes(ClassNode left, ClassNode right, Expression rightExpression)

static List chooseBestMethod(ClassNode receiver, Collection methods, ClassNode... args)

Given a list of candidate methods, returns the one which best matches the argument types

static List findDGMMethodsByNameAndArguments(ClassNode receiver, String name, ClassNode[] args)

static List findDGMMethodsByNameAndArguments(ClassNode receiver, String name, ClassNode[] args, List methods)

static boolean implementsInterfaceOrIsSubclassOf(ClassNode type, ClassNode superOrInterface)

static boolean isAssignment(int op)

static boolean isWithCall(String name, Expression callArguments)

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

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

A DGM-like method which adds support for method calls which are handled specifically by the Groovy compiler.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Method Detail

allParametersAndArgumentsMatch

public static int allParametersAndArgumentsMatch(Parameter[] params, ClassNode[] args)
Checks that arguments and parameter types match.
Parameters:
params - method parameters
args - type arguments
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


checkCompatibleAssignmentTypes

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


checkCompatibleAssignmentTypes

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


chooseBestMethod

public static List chooseBestMethod(ClassNode receiver, Collection methods, ClassNode... args)
Given a list of candidate methods, returns the one which best matches the argument types
Parameters:
receiver
methods - candidate methods
args - argument types
Returns:
the list of methods which best matches the argument types. It is still possible that multiple methods match the argument types.


findDGMMethodsByNameAndArguments

public static List findDGMMethodsByNameAndArguments(ClassNode receiver, String name, ClassNode[] args)


findDGMMethodsByNameAndArguments

public static List findDGMMethodsByNameAndArguments(ClassNode receiver, String name, ClassNode[] args, List methods)


implementsInterfaceOrIsSubclassOf

public static boolean implementsInterfaceOrIsSubclassOf(ClassNode type, ClassNode superOrInterface)


isAssignment

public static boolean isAssignment(int op)


isWithCall

public static boolean isWithCall(String name, Expression callArguments)
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
callArguments - arguments of the method
Returns:
true if the name is "with" and arguments consist of a single closure


parameterizeArguments

public static Parameter[] parameterizeArguments(ClassNode receiver, MethodNode m)
A DGM-like method which adds support for method calls which are handled specifically by the Groovy compiler.


 

Copyright © 2003-2012 The Codehaus. All rights reserved.