public class GroovyTypeCheckingExtensionSupport extends TypeCheckingExtension
TypeCheckingExtension,
this class adds a number of utility methods aimed at leveraging the syntax of the Groovy language to improve
expressivity and conciseness.| Modifier and Type | Class and Description |
|---|---|
static class |
GroovyTypeCheckingExtensionSupport.TypeCheckingDSL |
typeCheckingVisitor| Constructor and Description |
|---|
GroovyTypeCheckingExtensionSupport(StaticTypeCheckingVisitor typeCheckingVisitor,
String scriptPath,
CompilationUnit compilationUnit)
Builds a type checking extension relying on a Groovy script (type checking DSL).
|
| Modifier and Type | Method and Description |
|---|---|
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 |
argTypeMatches(ClassNode[] argTypes,
int index,
Class clazz) |
boolean |
argTypeMatches(MethodCall call,
int index,
Class clazz) |
boolean |
argTypesMatches(ClassNode[] argTypes,
Class... classes) |
boolean |
argTypesMatches(MethodCall call,
Class... classes) |
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 |
delegatesTo(ClassNode type) |
void |
delegatesTo(ClassNode type,
int strategy) |
void |
delegatesTo(ClassNode type,
int strategy,
org.codehaus.groovy.transform.stc.DelegationMetadata parent) |
void |
finish()
Subclasses should implement this method if they need to perform additional
checks after the type checker has finished its work.
|
boolean |
firstArgTypesMatches(ClassNode[] argTypes,
Class... classes) |
boolean |
firstArgTypesMatches(MethodCall call,
Class... classes) |
ArgumentListExpression |
getArguments(MethodCall call) |
org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope |
getCurrentScope() |
BinaryExpression |
getEnclosingBinaryExpression() |
List<BinaryExpression> |
getEnclosingBinaryExpressionStack() |
ClassNode |
getEnclosingClassNode() |
List<ClassNode> |
getEnclosingClassNodes() |
TypeCheckingContext.EnclosingClosure |
getEnclosingClosure() |
List<TypeCheckingContext.EnclosingClosure> |
getEnclosingClosureStack() |
MethodNode |
getEnclosingMethod() |
Expression |
getEnclosingMethodCall() |
List<Expression> |
getEnclosingMethodCalls() |
List<MethodNode> |
getEnclosingMethods() |
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.
|
List<MethodNode> |
handleMissingMethod(ClassNode receiver,
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.
|
boolean |
isAnnotatedBy(ASTNode node,
Class annotation) |
boolean |
isAnnotatedBy(ASTNode node,
ClassNode annotation) |
boolean |
isDynamic(VariableExpression var) |
boolean |
isExtensionMethod(MethodNode node) |
boolean |
isGenerated(MethodNode node) |
boolean |
isMethodCall(Object o) |
MethodNode |
newMethod(String name,
Callable<ClassNode> returnType) |
MethodNode |
newMethod(String name,
Class returnType) |
MethodNode |
newMethod(String name,
ClassNode returnType) |
org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope |
newScope() |
org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope |
newScope(Closure code) |
void |
onMethodSelection(Expression expression,
MethodNode target)
Allows the extension to listen to method selection events.
|
BinaryExpression |
popEnclosingBinaryExpression() |
ClassNode |
popEnclosingClassNode() |
TypeCheckingContext.EnclosingClosure |
popEnclosingClosure() |
MethodNode |
popEnclosingMethod() |
Expression |
popEnclosingMethodCall() |
void |
popTemporaryTypeInfo() |
void |
pushEnclosingBinaryExpression(BinaryExpression binaryExpression) |
void |
pushEnclosingClassNode(ClassNode classNode) |
void |
pushEnclosingClosureExpression(ClosureExpression closureExpression) |
void |
pushEnclosingMethod(MethodNode methodNode) |
void |
pushEnclosingMethodCall(Expression call) |
void |
pushTemporaryTypeInfo() |
org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope |
scopeExit() |
org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope |
scopeExit(Closure code) |
void |
setHandled(boolean handled) |
void |
setup()
Subclasses should implement this method whenever they need to perform
special checks before the type checker starts working.
|
List<MethodNode> |
unique(MethodNode node) |
<R> R |
withTypeChecker(Closure<R> code) |
addStaticTypeError, classNodeFor, classNodeFor, existsProperty, existsProperty, getArgumentTypes, getTargetMethod, getType, lookupClassNodeFor, parameterizedType, storeTypepublic GroovyTypeCheckingExtensionSupport(StaticTypeCheckingVisitor typeCheckingVisitor, String scriptPath, CompilationUnit compilationUnit)
typeCheckingVisitor - the type checking visitorscriptPath - the path to the type checking script (in classpath)compilationUnit - public void setup()
TypeCheckingExtensionsetup in class TypeCheckingExtensionpublic void finish()
TypeCheckingExtensionfinish in class TypeCheckingExtensionpublic void setHandled(boolean handled)
public org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope newScope()
public org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope newScope(Closure code)
public org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope scopeExit()
public org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope getCurrentScope()
public org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingScope scopeExit(Closure code)
public boolean isGenerated(MethodNode node)
public List<MethodNode> unique(MethodNode node)
public MethodNode newMethod(String name, Class returnType)
public MethodNode newMethod(String name, ClassNode returnType)
public MethodNode newMethod(String name, Callable<ClassNode> returnType)
public void delegatesTo(ClassNode type)
public void delegatesTo(ClassNode type, int strategy)
public void delegatesTo(ClassNode type, int strategy, org.codehaus.groovy.transform.stc.DelegationMetadata parent)
public boolean isDynamic(VariableExpression var)
public boolean isExtensionMethod(MethodNode node)
public ArgumentListExpression getArguments(MethodCall call)
public 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 afterMethodCall(MethodCall call)
TypeCheckingExtensionTypeCheckingMode.SKIP.afterMethodCall in class TypeCheckingExtensioncall - a method call, either a MethodCallExpression or a StaticMethodCallExpressionpublic boolean beforeMethodCall(MethodCall call)
TypeCheckingExtensionTypeCheckingMode.SKIP.beforeMethodCall in class TypeCheckingExtensioncall - a method call, either a MethodCallExpression or a StaticMethodCallExpressionpublic 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 void afterVisitMethod(MethodNode node)
TypeCheckingExtensionTypeCheckingMode.SKIP.afterVisitMethod in class TypeCheckingExtensionnode - a method nodepublic boolean beforeVisitClass(ClassNode node)
TypeCheckingExtensionTypeCheckingMode.SKIP.beforeVisitClass in class TypeCheckingExtensionnode - a class nodepublic void afterVisitClass(ClassNode node)
TypeCheckingExtensionTypeCheckingMode.SKIP.afterVisitClass in class TypeCheckingExtensionnode - a class nodepublic boolean beforeVisitMethod(MethodNode node)
TypeCheckingExtensionTypeCheckingMode.SKIP.beforeVisitMethod in class TypeCheckingExtensionnode - a method nodepublic 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 triggerred this callboolean false if the extension does not handle this assignment, true otherwisepublic List<MethodNode> handleMissingMethod(ClassNode receiver, 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 boolean isMethodCall(Object o)
public boolean argTypesMatches(MethodCall call, Class... classes)
public boolean firstArgTypesMatches(MethodCall call, Class... classes)
public boolean argTypeMatches(MethodCall call, int index, Class clazz)
public <R> R withTypeChecker(Closure<R> code)
public BinaryExpression getEnclosingBinaryExpression()
public void pushEnclosingBinaryExpression(BinaryExpression binaryExpression)
public void pushEnclosingClosureExpression(ClosureExpression closureExpression)
public Expression getEnclosingMethodCall()
public Expression popEnclosingMethodCall()
public MethodNode popEnclosingMethod()
public ClassNode getEnclosingClassNode()
public List<MethodNode> getEnclosingMethods()
public MethodNode getEnclosingMethod()
public void popTemporaryTypeInfo()
public void pushEnclosingClassNode(ClassNode classNode)
public BinaryExpression popEnclosingBinaryExpression()
public List<TypeCheckingContext.EnclosingClosure> getEnclosingClosureStack()
public ClassNode popEnclosingClassNode()
public void pushEnclosingMethod(MethodNode methodNode)
public List<BinaryExpression> getEnclosingBinaryExpressionStack()
public TypeCheckingContext.EnclosingClosure getEnclosingClosure()
public List<Expression> getEnclosingMethodCalls()
public void pushEnclosingMethodCall(Expression call)
public TypeCheckingContext.EnclosingClosure popEnclosingClosure()
public void pushTemporaryTypeInfo()