| Modifier and Type | Field and Description |
|---|---|
| protected final StaticTypeCheckingVisitor |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addStaticTypeError(final String
the message for the error msg, final ASTNode the expression which is the root cause of the error expr)Adds a type checking error, which will be displayed to the user during compilation. |
| public void | afterMethodCall(MethodCall call)
Allows the extension to perform additional tasks after the type checker actually visits a method call. |
| public void | afterVisitClass(ClassNode
a class node node)Allows the extension to perform additional tasks after the type checker actually visited a class node. |
| public void | afterVisitMethod(MethodNode
a method node node)Allows the extension to perform additional tasks after the type checker actually visited a method node. |
| public boolean | Returns: false if the type checker should visit the node, or true if this extension replaces what the type checker would do with the method call.Allows the extension to perform additional tasks before the type checker actually visits a method call. |
| public boolean | Returns: false if the type checker should visit the node, or true if this extension replaces what the type checker would do with the class.a class node node)Allows the extension to perform additional tasks before the type checker actually visits a class node. |
| public boolean | Returns: false if the type checker should visit the node, or true if this extension replaces what the type checker would do with the method.a method node node)Allows the extension to perform additional tasks before the type checker actually visits a method node. |
| public ClassNode | Returns: a classnode representing List<componentType>the classnode for the component type of the list componentType)Builds a parametrized class node for List, to represent List<X> |
| public ClassNode | Returns: a class node for Map<keyType,valueType>the classnode type of the key keyType, ClassNode the classnode type of the value valueType)Builds a parametrized class node representing the Map<keyType,valueType> type. |
| public ClassNode | |
| public ClassNode | |
| public boolean | |
| public boolean | existsProperty(final PropertyExpression pexp, final boolean checkForReadOnly, final ClassCodeVisitorSupport visitor)
|
| public ClassNode | Returns: null if it's not a static method call, or the class node for the receiver instead.a method call call)Given a method call, first checks that it's a static method call, and if it is, returns the class node for the receiver. |
| public void | finish()
Subclasses should implement this method if they need to perform additional checks after the type checker has finished its work. |
| public ClassNode[] | |
| public MethodNode | |
| public ClassNode | |
| public List | Returns: a single element list of disambiguated selection, or more elements if still ambiguous. It is not allowed to return an empty list.the list of ambiguous methods nodes, final Expression the expression which originated the method selection process 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. |
| public boolean | Returns: boolean false if the extension does not handle this assignment, true otherwisethe type of the left hand side of the assignment, as found by the type checker lhsType, final ClassNode the type of the right hand side of the assignment, as found by the type checker rhsType, final Expression the assignment expression which triggered this call assignmentExpression)This method is called by the type checker when an assignment is not allowed by the type checker. |
| public boolean | Returns: false if the extension doesn't handle the error, true otherwisethe statement that triggered the error returnStatement, ClassNode the inferred return type for this statement inferredReturnType)Allows the extension to catch incompatible return types. |
| public List | Returns: an empty list if the extension cannot resolve the method, or a list of potential methods if the extension finds candidates. This method must not return null.the type of the receiver receiver, String the name of the called method name, ArgumentListExpression the list of arguments of the call argumentList, ClassNode[] the types of the arguments of the call argumentTypes, MethodCall the method call itself, if needed call)This method is called by the type checker when a method call cannot be resolved. |
| public boolean | Returns: boolean false if this extension doesn't resolve the attribute, true
if it resolves the attribute.the unresolved attribute aexp)This method is called by the type checker when an attribute expression cannot be resolved (for example, when an attribute doesn't exist). |
| public boolean | Returns: boolean false if this extension doesn't resolve the property, true
if it resolves the property.the unresolved property pexp)This method is called by the type checker when a property expression cannot be resolved (for example, when a property doesn't exist). |
| public boolean | Returns: boolean false if the extension doesn't handle it,
true if the extension handles this variable.the unresolved variable extension vexp)This method is called by the type checker when a variable expression cannot be resolved. |
| public boolean | Returns: true if the method call is a static method call on the receivera method call call, ClassNode a class node receiver)Given a method call, checks if it's a static method call and if it is, tells if the receiver matches the one supplied as an argument. |
| public ClassNode | Returns: a ClassNode representing the classthe name of the class whose ClassNode we want to lookup type)Lookup a ClassNode by its name from the source unit |
| public void | onMethodSelection(Expression
the expression for which a corresponding method has been found expression, MethodNode the method which has been chosen by the type checker target)Allows the extension to listen to method selection events. |
| public ClassNode | |
| public void | setup()
Subclasses should implement this method whenever they need to perform special checks before the type checker starts working. |
| public void | storeType(final Expression
the expression for which we want to store an inferred type exp, final ClassNode the type of the expression cn)Stores an inferred type for an expression. |
| typeCheckingVisitor | back to summary |
|---|---|
| protected final StaticTypeCheckingVisitor typeCheckingVisitor | |
| TypeCheckingExtension | back to summary |
|---|---|
| public TypeCheckingExtension(final StaticTypeCheckingVisitor typeCheckingVisitor) | |
| addStaticTypeError | back to summary |
|---|---|
| public void addStaticTypeError(final String msg, final ASTNode expr) Adds a type checking error, which will be displayed to the user during compilation. | |
| afterMethodCall | back to summary |
|---|---|
| public void afterMethodCall(MethodCall call) Allows the extension to perform additional tasks after the type checker actually visits a method call.
Compared to a custom visitor, this method ensures that the node being visited is a node which would have
been visited by the type checker. This is in particular important for nodes which are marked with
| |
| afterVisitClass | back to summary |
|---|---|
| public void afterVisitClass(ClassNode node) Allows the extension to perform additional tasks after the type checker actually visited a class node.
Compared to a custom visitor, this method ensures that the node being visited is a node which would have
been visited by the type checker. This is in particular important for nodes which are marked with
| |
| afterVisitMethod | back to summary |
|---|---|
| public void afterVisitMethod(MethodNode node) Allows the extension to perform additional tasks after the type checker actually visited a method node.
Compared to a custom visitor, this method ensures that the node being visited is a node which would have
been visited by the type checker. This is in particular important for nodes which are marked with
| |
| beforeMethodCall | back to summary |
|---|---|
| public boolean beforeMethodCall(MethodCall call) Allows the extension to perform additional tasks before the type checker actually visits a method call.
Compared to a custom visitor, this method ensures that the node being visited is a node which would have
been visited by the type checker. This is in particular important for nodes which are marked with
| |
| beforeVisitClass | back to summary |
|---|---|
| public boolean beforeVisitClass(ClassNode node) Allows the extension to perform additional tasks before the type checker actually visits a class node.
Compared to a custom visitor, this method ensures that the node being visited is a node which would have
been visited by the type checker. This is in particular important for nodes which are marked with
| |
| beforeVisitMethod | back to summary |
|---|---|
| public boolean beforeVisitMethod(MethodNode node) Allows the extension to perform additional tasks before the type checker actually visits a method node.
Compared to a custom visitor, this method ensures that the node being visited is a node which would have
been visited by the type checker. This is in particular important for nodes which are marked with
| |
| buildListType | back to summary |
|---|---|
| public ClassNode buildListType(ClassNode componentType) Builds a parametrized class node for List, to represent List<X> | |
| buildMapType | back to summary |
|---|---|
| public ClassNode buildMapType(ClassNode keyType, ClassNode valueType) Builds a parametrized class node representing the Map<keyType,valueType> type. | |
| classNodeFor | back to summary |
|---|---|
| public ClassNode classNodeFor(Class<T> type) | |
| classNodeFor | back to summary |
|---|---|
| public ClassNode classNodeFor(String type) | |
| existsProperty | back to summary |
|---|---|
| public boolean existsProperty(final PropertyExpression pexp, final boolean checkForReadOnly) | |
| existsProperty | back to summary |
|---|---|
| public boolean existsProperty(final PropertyExpression pexp, final boolean checkForReadOnly, final ClassCodeVisitorSupport visitor) | |
| extractStaticReceiver | back to summary |
|---|---|
| public ClassNode extractStaticReceiver(MethodCall call) Given a method call, first checks that it's a static method call, and if it is, returns the
class node for the receiver. For example, with the following code:
| |
| finish | back to summary |
|---|---|
| public void finish() Subclasses should implement this method if they need to perform additional checks after the type checker has finished its work. This is particularly useful for situations where you need multiple passes. Some checks in that case may be deferred to the end, using this method. | |
| getArgumentTypes | back to summary |
|---|---|
| public ClassNode[] getArgumentTypes(final ArgumentListExpression args) | |
| getTargetMethod | back to summary |
|---|---|
| public MethodNode getTargetMethod(final Expression expression) | |
| getType | back to summary |
|---|---|
| public ClassNode getType(final ASTNode exp) Returns the inferred type of an expression. Delegates to the type checker implementation. | |
| handleAmbiguousMethods | back to summary |
|---|---|
| public List 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. This means that when this method is called, the "nodes" parameter contains at least two methods. If the returned list still contains at least two methods, then the type checker will throw an ambiguous method call error. If the returned method contains 1 element, then the type checker will not throw any error. It is invalid to return an empty list.
| |
| handleIncompatibleAssignment | back to summary |
|---|---|
| public boolean handleIncompatibleAssignment(final ClassNode lhsType, final ClassNode rhsType, final Expression assignmentExpression) This method is called by the type checker when an assignment is not allowed by the type checker. Extensions may override this method to allow such assignments where the type checker normally disallows them.
| |
| handleIncompatibleReturnType | back to summary |
|---|---|
| public boolean handleIncompatibleReturnType(ReturnStatement returnStatement, ClassNode inferredReturnType) Allows the extension to catch incompatible return types. This event is called whenever the type checker finds that an inferred return type is incompatible with the declared return type of a method.
| |
| handleMissingMethod | back to summary |
|---|---|
| public List This method is called by the type checker when a method call cannot be resolved. Extensions may override this method to handle missing methods and prevent the type checker from throwing an error.
| |
| handleUnresolvedAttribute | back to summary |
|---|---|
| public 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). It gives the extension a chance to resolve it.
| |
| handleUnresolvedProperty | back to summary |
|---|---|
| public 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). It gives the extension a chance to resolve it.
| |
| handleUnresolvedVariableExpression | back to summary |
|---|---|
| public boolean handleUnresolvedVariableExpression(VariableExpression vexp) This method is called by the type checker when a variable expression cannot be resolved. It gives the extension a chance to resolve it for the type checker.
| |
| isStaticMethodCallOnClass | back to summary |
|---|---|
| public boolean isStaticMethodCallOnClass(MethodCall call, ClassNode receiver) Given a method call, checks if it's a static method call and if it is, tells if the receiver matches the one supplied as an argument.
| |
| lookupClassNodeFor | back to summary |
|---|---|
| public ClassNode lookupClassNodeFor(String type) Lookup a ClassNode by its name from the source unit | |
| onMethodSelection | back to summary |
|---|---|
| public void onMethodSelection(Expression expression, MethodNode target) Allows the extension to listen to method selection events. Given an expression, which may be a method call expression, a static method call expression, a pre/postfix expression, ..., if a corresponding method is found, this method is called.
| |
| parameterizedType | back to summary |
|---|---|
| public ClassNode parameterizedType(final ClassNode baseType, final ClassNode... genericsTypeArguments) | |
| setup | back to summary |
|---|---|
| public void setup() Subclasses should implement this method whenever they need to perform special checks before the type checker starts working. | |
| storeType | back to summary |
|---|---|
| public void storeType(final Expression exp, final ClassNode cn) Stores an inferred type for an expression. Delegates to the type checker.
| |