Class AbstractTypeCheckingExtension
java.lang.Object
org.codehaus.groovy.transform.stc.TypeCheckingExtension
org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension
- Direct Known Subclasses:
GroovyTypeCheckingExtensionSupport,TraitTypeCheckingExtension
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.
- Since:
- 2.3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMap-backed scope used to share data across extension callbacks. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TypeCheckingContextShared type-checking context exposed to extension helpers.protected booleanprotected booleanFields inherited from class org.codehaus.groovy.transform.stc.TypeCheckingExtension
typeCheckingVisitor -
Constructor Summary
ConstructorsConstructorDescriptionAbstractTypeCheckingExtension(StaticTypeCheckingVisitor typeCheckingVisitor) Creates an extension helper bound to the supplied visitor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanargTypeMatches(ClassNode[] argTypes, int index, Class clazz) Checks whether the argument at the supplied index matches the given class.booleanargTypeMatches(MethodCall call, int index, Class clazz) Checks whether a method call argument at the supplied index matches the given class.booleanargTypesMatches(ClassNode[] argTypes, Class... classes) Checks whether the supplied argument types exactly match the given classes.booleanargTypesMatches(MethodCall call, Class... classes) Checks whether a method call argument list exactly matches the given classes.voiddelegatesTo(ClassNode type) Sets closure delegation metadata withClosure.OWNER_FIRST.voiddelegatesTo(ClassNode type, int strategy) Sets closure delegation metadata for the supplied type and strategy.voiddelegatesTo(ClassNode type, int strategy, org.codehaus.groovy.transform.stc.DelegationMetadata parent) Sets closure delegation metadata for the supplied type, strategy, and parent metadata.booleanfirstArgTypesMatches(ClassNode[] argTypes, Class... classes) Checks whether the leading argument types match the given classes.booleanfirstArgTypesMatches(MethodCall call, Class... classes) Checks whether a method call starts with arguments matching the given classes.getArguments(MethodCall call) Returns the normalized argument list for the supplied method call.Returns the current scope, ornullif none is active.Returns the current enclosing binary expression.Returns the enclosing binary-expression stack.Returns the current enclosing class node.Returns the enclosing class stack.Returns the current enclosing closure metadata.Returns the enclosing closure stack.Returns the current enclosing method.Returns the current enclosing method call.Returns the enclosing method-call stack.Returns the enclosing method stack.Returns the generated methods created by this extension.booleanisAnnotatedBy(ASTNode node, Class annotation) Checks whether the node is annotated with the supplied annotation type.booleanisAnnotatedBy(ASTNode node, ClassNode annotation) Checks whether the node is annotated with the supplied annotation node.booleanIndicates whether the variable resolves dynamically.booleanisExtensionMethod(MethodNode node) Indicates whether the supplied method node models an extension method.booleanisGenerated(MethodNode node) Indicates whether the supplied method node was created by this extension.booleanIndicates whether the supplied object is a method call expression.voidLogs a type-checking extension message.makeDynamic(MethodCall call) Used to instruct the type checker that the call is a dynamic method call.makeDynamic(MethodCall call, ClassNode returnType) Used to instruct the type checker that the call is a dynamic method call.voidInstructs the type checker that a property access is dynamic, returning an instance of an Object.voidmakeDynamic(PropertyExpression pexp, ClassNode returnType) Instructs the type checker that a property access is dynamic.voidInstructs the type checker that an unresolved variable is a dynamic variable of type Object.voidmakeDynamic(VariableExpression vexp, ClassNode returnType) Instructs the type checker that an unresolved variable is a dynamic variable.Creates a synthetic public method with the supplied return type.Creates a synthetic public method whose return type is resolved lazily.Creates a synthetic public method with the supplied return type.newScope()Pushes a new extension scope onto the scope stack.Pushes a new scope and executes the supplied callback against it.Pops the current enclosing binary expression.Pops the current enclosing class node.Pops the current enclosing closure metadata.Pops the current enclosing method.Pops the current enclosing method call.voidPops the temporary type-information stack.voidpushEnclosingBinaryExpression(BinaryExpression binaryExpression) Pushes an enclosing binary expression onto the context stack.voidpushEnclosingClassNode(ClassNode classNode) Pushes an enclosing class node onto the context stack.voidpushEnclosingClosureExpression(ClosureExpression closureExpression) Pushes an enclosing closure expression onto the context stack.voidpushEnclosingMethod(MethodNode methodNode) Pushes an enclosing method onto the context stack.voidPushes an enclosing method call onto the context stack.voidPushes a new temporary type-information frame.protected ObjectInvokes the supplied closure and reports any failure to the source unit.Pops and returns the current scope.Executes the supplied callback against the current scope and then pops it.voidsetHandled(boolean handled) Marks whether the current event was handled by the extension.unique(MethodNode node) Wraps the supplied method node in a singleton list.<R> RwithTypeChecker(Closure<R> code) Executes the supplied closure with the type checker as delegate.Methods inherited from class org.codehaus.groovy.transform.stc.TypeCheckingExtension
addStaticTypeError, afterMethodCall, afterVisitClass, afterVisitMethod, beforeMethodCall, beforeVisitClass, beforeVisitMethod, buildListType, buildMapType, classNodeFor, classNodeFor, existsProperty, existsProperty, extractStaticReceiver, finish, getArgumentTypes, getOptions, getTargetMethod, getType, handleAmbiguousMethods, handleIncompatibleAssignment, handleIncompatibleReturnType, handleMissingMethod, handleUnresolvedAttribute, handleUnresolvedProperty, handleUnresolvedVariableExpression, isStaticMethodCallOnClass, lookupClassNodeFor, onMethodSelection, parameterizedType, setOptions, setup, storeType
-
Field Details
-
context
Shared type-checking context exposed to extension helpers. -
debug
protected boolean debug -
handled
protected boolean handled
-
-
Constructor Details
-
AbstractTypeCheckingExtension
Creates an extension helper bound to the supplied visitor.
-
-
Method Details
-
setHandled
public void setHandled(boolean handled) Marks whether the current event was handled by the extension. -
newScope
Pushes a new extension scope onto the scope stack. -
newScope
Pushes a new scope and executes the supplied callback against it. -
scopeExit
Pops and returns the current scope. -
getCurrentScope
Returns the current scope, ornullif none is active. -
scopeExit
Executes the supplied callback against the current scope and then pops it. -
isGenerated
Indicates whether the supplied method node was created by this extension. -
unique
Wraps the supplied method node in a singleton list. -
newMethod
Creates a synthetic public method with the supplied return type. -
newMethod
Creates a synthetic public method with the supplied return type. -
newMethod
Creates a synthetic public method whose return type is resolved lazily. -
delegatesTo
Sets closure delegation metadata withClosure.OWNER_FIRST. -
delegatesTo
Sets closure delegation metadata for the supplied type and strategy. -
delegatesTo
public void delegatesTo(ClassNode type, int strategy, org.codehaus.groovy.transform.stc.DelegationMetadata parent) Sets closure delegation metadata for the supplied type, strategy, and parent metadata. -
isAnnotatedBy
Checks whether the node is annotated with the supplied annotation type. -
isAnnotatedBy
Checks whether the node is annotated with the supplied annotation node. -
isDynamic
Indicates whether the variable resolves dynamically. -
isExtensionMethod
Indicates whether the supplied method node models an extension method. -
getArguments
Returns the normalized argument list for the supplied method call. -
safeCall
Invokes the supplied closure and reports any failure to the source unit. -
isMethodCall
Indicates whether the supplied object is a method call expression. -
argTypesMatches
Checks whether the supplied argument types exactly match the given classes. -
argTypesMatches
Checks whether a method call argument list exactly matches the given classes. -
firstArgTypesMatches
Checks whether the leading argument types match the given classes. -
firstArgTypesMatches
Checks whether a method call starts with arguments matching the given classes. -
argTypeMatches
Checks whether the argument at the supplied index matches the given class. -
argTypeMatches
Checks whether a method call argument at the supplied index matches the given class. -
withTypeChecker
public <R> R withTypeChecker(@DelegatesTo(value=StaticTypeCheckingVisitor.class,strategy=1) @ClosureParams(value=SimpleType.class,options="org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor") Closure<R> code) Executes the supplied closure with the type checker as delegate. -
makeDynamic
Used to instruct the type checker that the call is a dynamic method call. Calling this method automatically sets the handled flag to true. The expected return type of the dynamic method call is Object.- Parameters:
call- the method call which is a dynamic method call- Returns:
- a virtual method node with the same name as the expected call
-
makeDynamic
Used to instruct the type checker that the call is a dynamic method call. Calling this method automatically sets the handled flag to true.- Parameters:
call- the method call which is a dynamic method callreturnType- the expected return type of the dynamic call- Returns:
- a virtual method node with the same name as the expected call
-
makeDynamic
Instructs the type checker that a property access is dynamic, returning an instance of an Object. Calling this method automatically sets the handled flag to true.- Parameters:
pexp- the property or attribute expression
-
makeDynamic
Instructs the type checker that a property access is dynamic. Calling this method automatically sets the handled flag to true.- Parameters:
pexp- the property or attribute expressionreturnType- the type of the property
-
makeDynamic
Instructs the type checker that an unresolved variable is a dynamic variable of type Object. Calling this method automatically sets the handled flag to true.- Parameters:
vexp- the dynamic variable
-
makeDynamic
Instructs the type checker that an unresolved variable is a dynamic variable.- Parameters:
returnType- the type of the dynamic variable Calling this method automatically sets the handled flag to true.vexp- the dynamic variable
-
log
Logs a type-checking extension message. -
getEnclosingBinaryExpression
Returns the current enclosing binary expression. -
pushEnclosingBinaryExpression
Pushes an enclosing binary expression onto the context stack. -
pushEnclosingClosureExpression
Pushes an enclosing closure expression onto the context stack. -
getEnclosingMethodCall
Returns the current enclosing method call. -
popEnclosingMethodCall
Pops the current enclosing method call. -
popEnclosingMethod
Pops the current enclosing method. -
getEnclosingClassNode
Returns the current enclosing class node. -
getEnclosingMethods
Returns the enclosing method stack. -
getEnclosingMethod
Returns the current enclosing method. -
popTemporaryTypeInfo
public void popTemporaryTypeInfo()Pops the temporary type-information stack. -
pushEnclosingClassNode
Pushes an enclosing class node onto the context stack. -
popEnclosingBinaryExpression
Pops the current enclosing binary expression. -
getEnclosingClassNodes
Returns the enclosing class stack. -
getEnclosingClosureStack
Returns the enclosing closure stack. -
popEnclosingClassNode
Pops the current enclosing class node. -
pushEnclosingMethod
Pushes an enclosing method onto the context stack. -
getGeneratedMethods
Returns the generated methods created by this extension. -
getEnclosingBinaryExpressionStack
Returns the enclosing binary-expression stack. -
getEnclosingClosure
Returns the current enclosing closure metadata. -
getEnclosingMethodCalls
Returns the enclosing method-call stack. -
pushEnclosingMethodCall
Pushes an enclosing method call onto the context stack. -
popEnclosingClosure
Pops the current enclosing closure metadata. -
pushTemporaryTypeInfo
public void pushTemporaryTypeInfo()Pushes a new temporary type-information frame.
-