public class AbstractTypeCheckingExtension extends TypeCheckingExtension
Custom type checking extensions may extend this method in order to benefit from a lot of support methods.
The methods found in this class are made directly available in type checking scripts
through the GroovyTypeCheckingExtensionSupport
class.
Modifier and Type | Field and Description |
---|---|
protected TypeCheckingContext |
context |
protected boolean |
debug |
protected boolean |
handled |
typeCheckingVisitor
Constructor and Description |
---|
AbstractTypeCheckingExtension(StaticTypeCheckingVisitor typeCheckingVisitor) |
Modifier and Type | Method and Description |
---|---|
boolean |
argTypeMatches(ClassNode[] argTypes,
int index,
java.lang.Class clazz) |
boolean |
argTypeMatches(MethodCall call,
int index,
java.lang.Class clazz) |
boolean |
argTypesMatches(ClassNode[] argTypes,
java.lang.Class... classes) |
boolean |
argTypesMatches(MethodCall call,
java.lang.Class... classes) |
void |
delegatesTo(ClassNode type) |
void |
delegatesTo(ClassNode type,
int strategy) |
void |
delegatesTo(ClassNode type,
int strategy,
org.codehaus.groovy.transform.stc.DelegationMetadata parent) |
boolean |
firstArgTypesMatches(ClassNode[] argTypes,
java.lang.Class... classes) |
boolean |
firstArgTypesMatches(MethodCall call,
java.lang.Class... classes) |
ArgumentListExpression |
getArguments(MethodCall call) |
org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope |
getCurrentScope() |
BinaryExpression |
getEnclosingBinaryExpression() |
java.util.List<BinaryExpression> |
getEnclosingBinaryExpressionStack() |
ClassNode |
getEnclosingClassNode() |
java.util.List<ClassNode> |
getEnclosingClassNodes() |
TypeCheckingContext.EnclosingClosure |
getEnclosingClosure() |
java.util.List<TypeCheckingContext.EnclosingClosure> |
getEnclosingClosureStack() |
MethodNode |
getEnclosingMethod() |
Expression |
getEnclosingMethodCall() |
java.util.List<Expression> |
getEnclosingMethodCalls() |
java.util.List<MethodNode> |
getEnclosingMethods() |
java.util.Set<MethodNode> |
getGeneratedMethods() |
boolean |
isAnnotatedBy(ASTNode node,
java.lang.Class annotation) |
boolean |
isAnnotatedBy(ASTNode node,
ClassNode annotation) |
boolean |
isDynamic(VariableExpression var) |
boolean |
isExtensionMethod(MethodNode node) |
boolean |
isGenerated(MethodNode node) |
boolean |
isMethodCall(java.lang.Object o) |
void |
log(java.lang.String message) |
MethodNode |
makeDynamic(MethodCall call)
Used to instruct the type checker that the call is a dynamic method call.
|
MethodNode |
makeDynamic(MethodCall call,
ClassNode returnType)
Used to instruct the type checker that the call is a dynamic method call.
|
void |
makeDynamic(PropertyExpression pexp)
Instructs the type checker that a property access is dynamic, returning an instance of an Object.
|
void |
makeDynamic(PropertyExpression pexp,
ClassNode returnType)
Instructs the type checker that a property access is dynamic.
|
void |
makeDynamic(VariableExpression vexp)
Instructs the type checker that an unresolved variable is a dynamic variable of type Object.
|
void |
makeDynamic(VariableExpression vexp,
ClassNode returnType)
Instructs the type checker that an unresolved variable is a dynamic variable.
|
MethodNode |
newMethod(java.lang.String name,
java.util.concurrent.Callable<ClassNode> returnType) |
MethodNode |
newMethod(java.lang.String name,
java.lang.Class returnType) |
MethodNode |
newMethod(java.lang.String name,
ClassNode returnType) |
org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope |
newScope() |
org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope |
newScope(Closure code) |
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() |
protected java.lang.Object |
safeCall(Closure closure,
java.lang.Object... args) |
org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope |
scopeExit() |
org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope |
scopeExit(Closure code) |
void |
setHandled(boolean handled) |
java.util.List<MethodNode> |
unique(MethodNode node) |
<R> R |
withTypeChecker(Closure<R> code) |
addStaticTypeError, afterMethodCall, afterVisitClass, afterVisitMethod, beforeMethodCall, beforeVisitClass, beforeVisitMethod, buildListType, buildMapType, classNodeFor, classNodeFor, existsProperty, existsProperty, extractStaticReceiver, finish, getArgumentTypes, getTargetMethod, getType, handleAmbiguousMethods, handleIncompatibleAssignment, handleIncompatibleReturnType, handleMissingMethod, handleUnresolvedAttribute, handleUnresolvedProperty, handleUnresolvedVariableExpression, isStaticMethodCallOnClass, lookupClassNodeFor, onMethodSelection, parameterizedType, setup, storeType
protected final TypeCheckingContext context
protected boolean handled
protected boolean debug
public AbstractTypeCheckingExtension(StaticTypeCheckingVisitor typeCheckingVisitor)
public void setHandled(boolean handled)
public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope newScope()
public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope newScope(Closure code)
public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope scopeExit()
public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope getCurrentScope()
public org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension.TypeCheckingScope scopeExit(Closure code)
public boolean isGenerated(MethodNode node)
public java.util.List<MethodNode> unique(MethodNode node)
public MethodNode newMethod(java.lang.String name, java.lang.Class returnType)
public MethodNode newMethod(java.lang.String name, ClassNode returnType)
public MethodNode newMethod(java.lang.String name, java.util.concurrent.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 isAnnotatedBy(ASTNode node, java.lang.Class annotation)
public boolean isDynamic(VariableExpression var)
public boolean isExtensionMethod(MethodNode node)
public ArgumentListExpression getArguments(MethodCall call)
protected java.lang.Object safeCall(Closure closure, java.lang.Object... args)
public boolean isMethodCall(java.lang.Object o)
public boolean argTypesMatches(ClassNode[] argTypes, java.lang.Class... classes)
public boolean argTypesMatches(MethodCall call, java.lang.Class... classes)
public boolean firstArgTypesMatches(ClassNode[] argTypes, java.lang.Class... classes)
public boolean firstArgTypesMatches(MethodCall call, java.lang.Class... classes)
public boolean argTypeMatches(ClassNode[] argTypes, int index, java.lang.Class clazz)
public boolean argTypeMatches(MethodCall call, int index, java.lang.Class clazz)
public <R> R withTypeChecker(Closure<R> code)
public MethodNode makeDynamic(MethodCall call)
call
- the method call which is a dynamic method callpublic MethodNode makeDynamic(MethodCall call, ClassNode returnType)
call
- the method call which is a dynamic method callreturnType
- the expected return type of the dynamic callpublic void makeDynamic(PropertyExpression pexp)
pexp
- the property or attribute expressionpublic void makeDynamic(PropertyExpression pexp, ClassNode returnType)
pexp
- the property or attribute expressionreturnType
- the type of the propertypublic void makeDynamic(VariableExpression vexp)
vexp
- the dynamic variablepublic void makeDynamic(VariableExpression vexp, ClassNode returnType)
returnType
- the type of the dynamic variable
Calling this method automatically sets the handled flag to true.vexp
- the dynamic variablepublic void log(java.lang.String message)
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 java.util.List<MethodNode> getEnclosingMethods()
public MethodNode getEnclosingMethod()
public void popTemporaryTypeInfo()
public void pushEnclosingClassNode(ClassNode classNode)
public BinaryExpression popEnclosingBinaryExpression()
public java.util.List<ClassNode> getEnclosingClassNodes()
public java.util.List<TypeCheckingContext.EnclosingClosure> getEnclosingClosureStack()
public ClassNode popEnclosingClassNode()
public void pushEnclosingMethod(MethodNode methodNode)
public java.util.Set<MethodNode> getGeneratedMethods()
public java.util.List<BinaryExpression> getEnclosingBinaryExpressionStack()
public TypeCheckingContext.EnclosingClosure getEnclosingClosure()
public java.util.List<Expression> getEnclosingMethodCalls()
public void pushEnclosingMethodCall(Expression call)
public TypeCheckingContext.EnclosingClosure popEnclosingClosure()
public void pushTemporaryTypeInfo()