public class DefaultTypeCheckingExtension extends TypeCheckingExtension
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<TypeCheckingExtension> |
handlers |
typeCheckingVisitor| Constructor and Description |
|---|
DefaultTypeCheckingExtension(StaticTypeCheckingVisitor typeCheckingVisitor) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHandler(TypeCheckingExtension handler) |
void |
afterMethodCall(MethodCall call)
Allows the extension to perform additional tasks after the type checker actually visits a method call.
|
void |
afterVisitClass(ClassNode node)
Allows the extension to perform additional tasks after the type checker actually visited a class node.
|
void |
afterVisitMethod(MethodNode node)
Allows the extension to perform additional tasks after the type checker actually visited a method node.
|
boolean |
beforeMethodCall(MethodCall call)
Allows the extension to perform additional tasks before the type checker actually visits a method call.
|
boolean |
beforeVisitClass(ClassNode node)
Allows the extension to perform additional tasks before the type checker actually visits a class node.
|
boolean |
beforeVisitMethod(MethodNode node)
Allows the extension to perform additional tasks before the type checker actually visits a method node.
|
void |
finish()
Subclasses should implement this method if they need to perform additional
checks after the type checker has finished its work.
|
java.util.List<MethodNode> |
handleAmbiguousMethods(java.util.List<MethodNode> nodes,
Expression origin)
This method is called by the type checker before throwing an "ambiguous method" error, giving the chance
to the extension to select the method properly.
|
boolean |
handleIncompatibleAssignment(ClassNode lhsType,
ClassNode rhsType,
Expression assignmentExpression)
This method is called by the type checker when an assignment is not allowed by the type checker.
|
boolean |
handleIncompatibleReturnType(ReturnStatement returnStatement,
ClassNode inferredReturnType)
Allows the extension to catch incompatible return types.
|
java.util.List<MethodNode> |
handleMissingMethod(ClassNode receiver,
java.lang.String name,
ArgumentListExpression argumentList,
ClassNode[] argumentTypes,
MethodCall call)
This method is called by the type checker when a method call cannot be resolved.
|
boolean |
handleUnresolvedAttribute(AttributeExpression aexp)
This method is called by the type checker when an attribute expression cannot
be resolved (for example, when an attribute doesn't exist).
|
boolean |
handleUnresolvedProperty(PropertyExpression pexp)
This method is called by the type checker when a property expression cannot
be resolved (for example, when a property doesn't exist).
|
boolean |
handleUnresolvedVariableExpression(VariableExpression vexp)
This method is called by the type checker when a variable expression cannot
be resolved.
|
void |
onMethodSelection(Expression expression,
MethodNode target)
Allows the extension to listen to method selection events.
|
void |
removeHandler(TypeCheckingExtension handler) |
void |
setup()
Subclasses should implement this method whenever they need to perform
special checks before the type checker starts working.
|
addStaticTypeError, buildListType, buildMapType, classNodeFor, classNodeFor, existsProperty, existsProperty, extractStaticReceiver, getArgumentTypes, getTargetMethod, getType, isStaticMethodCallOnClass, lookupClassNodeFor, parameterizedType, storeTypeprotected final java.util.List<TypeCheckingExtension> handlers
public DefaultTypeCheckingExtension(StaticTypeCheckingVisitor typeCheckingVisitor)
public void addHandler(TypeCheckingExtension handler)
public void removeHandler(TypeCheckingExtension handler)
public boolean handleUnresolvedVariableExpression(VariableExpression vexp)
TypeCheckingExtensionhandleUnresolvedVariableExpression in class TypeCheckingExtensionvexp - the unresolved variable extensionboolean false if the extension doesn't handle it,
true if the extension handles this variable.public boolean handleUnresolvedProperty(PropertyExpression pexp)
TypeCheckingExtensionhandleUnresolvedProperty in class TypeCheckingExtensionpexp - the unresolved propertyboolean false if this extension doesn't resolve the property, true
if it resolves the property.public boolean handleUnresolvedAttribute(AttributeExpression aexp)
TypeCheckingExtensionhandleUnresolvedAttribute in class TypeCheckingExtensionaexp - the unresolved attributeboolean false if this extension doesn't resolve the attribute, true
if it resolves the attribute.public boolean handleIncompatibleAssignment(ClassNode lhsType, ClassNode rhsType, Expression assignmentExpression)
TypeCheckingExtensionhandleIncompatibleAssignment in class TypeCheckingExtensionlhsType - the type of the left hand side of the assignment, as found by the type checkerrhsType - the type of the right hand side of the assignment, as found by the type checkerassignmentExpression - the assignment expression which triggered this callboolean false if the extension does not handle this assignment, true otherwisepublic boolean handleIncompatibleReturnType(ReturnStatement returnStatement, ClassNode inferredReturnType)
TypeCheckingExtensionhandleIncompatibleReturnType in class TypeCheckingExtensionreturnStatement - the statement that triggered the errorinferredReturnType - the inferred return type for this statementpublic java.util.List<MethodNode> handleAmbiguousMethods(java.util.List<MethodNode> nodes, Expression origin)
TypeCheckingExtensionhandleAmbiguousMethods in class TypeCheckingExtensionnodes - the list of ambiguous methodsorigin - the expression which originated the method selection processpublic java.util.List<MethodNode> handleMissingMethod(ClassNode receiver, java.lang.String name, ArgumentListExpression argumentList, ClassNode[] argumentTypes, MethodCall call)
TypeCheckingExtensionhandleMissingMethod in class TypeCheckingExtensionreceiver - the type of the receivername - the name of the called methodargumentList - the list of arguments of the callargumentTypes - the types of the arguments of the callcall - the method call itself, if neededpublic void afterVisitMethod(MethodNode node)
TypeCheckingExtensionTypeCheckingMode.SKIP.afterVisitMethod in class TypeCheckingExtensionnode - a method nodepublic boolean beforeVisitMethod(MethodNode node)
TypeCheckingExtensionTypeCheckingMode.SKIP.beforeVisitMethod in class TypeCheckingExtensionnode - a method nodepublic void afterVisitClass(ClassNode node)
TypeCheckingExtensionTypeCheckingMode.SKIP.afterVisitClass in class TypeCheckingExtensionnode - a class nodepublic boolean beforeVisitClass(ClassNode node)
TypeCheckingExtensionTypeCheckingMode.SKIP.beforeVisitClass in class TypeCheckingExtensionnode - a class nodepublic void afterMethodCall(MethodCall call)
TypeCheckingExtensionTypeCheckingMode.SKIP.afterMethodCall in class TypeCheckingExtensioncall - a method call, either a MethodCallExpression, StaticMethodCallExpression, or ConstructorCallExpressionpublic boolean beforeMethodCall(MethodCall call)
TypeCheckingExtensionTypeCheckingMode.SKIP.beforeMethodCall in class TypeCheckingExtensioncall - a method call, either a MethodCallExpression, StaticMethodCallExpression, or ConstructorCallExpressionpublic void onMethodSelection(Expression expression, MethodNode target)
TypeCheckingExtensiononMethodSelection in class TypeCheckingExtensionexpression - the expression for which a corresponding method has been foundtarget - the method which has been chosen by the type checkerpublic void setup()
TypeCheckingExtensionsetup in class TypeCheckingExtensionpublic void finish()
TypeCheckingExtensionfinish in class TypeCheckingExtension