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.
| Modifiers | Name | Description |
|---|---|---|
static class |
AbstractTypeCheckingExtension.TypeCheckingScope |
Map-backed scope used to share data across extension callbacks. |
| Modifiers | Name | Description |
|---|---|---|
protected TypeCheckingContext |
context |
Shared type-checking context exposed to extension helpers. |
protected boolean |
debug |
|
protected boolean |
handled |
|
| Fields inherited from class | Fields |
|---|---|
class TypeCheckingExtension |
typeCheckingVisitor |
| Constructor and description |
|---|
AbstractTypeCheckingExtension(StaticTypeCheckingVisitor typeCheckingVisitor)Creates an extension helper bound to the supplied visitor. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public boolean |
argTypeMatches(ClassNode[] argTypes, int index, Class clazz)Checks whether the argument at the supplied index matches the given class. |
|
public boolean |
argTypeMatches(MethodCall call, int index, Class clazz)Checks whether a method call argument at the supplied index matches the given class. |
|
public boolean |
argTypesMatches(ClassNode[] argTypes, Class classes)Checks whether the supplied argument types exactly match the given classes. |
|
public boolean |
argTypesMatches(MethodCall call, Class classes)Checks whether a method call argument list exactly matches the given classes. |
|
public void |
delegatesTo(ClassNode type)Sets closure delegation metadata with Closure.OWNER_FIRST. |
|
public void |
delegatesTo(ClassNode type, int strategy)Sets closure delegation metadata for the supplied type and strategy. |
|
public void |
delegatesTo(ClassNode type, int strategy, DelegationMetadata parent)Sets closure delegation metadata for the supplied type, strategy, and parent metadata. |
|
public boolean |
firstArgTypesMatches(ClassNode[] argTypes, Class classes)Checks whether the leading argument types match the given classes. |
|
public boolean |
firstArgTypesMatches(MethodCall call, Class classes)Checks whether a method call starts with arguments matching the given classes. |
|
public ArgumentListExpression |
getArguments(MethodCall call)Returns the normalized argument list for the supplied method call. |
|
public AbstractTypeCheckingExtension.TypeCheckingScope |
getCurrentScope()Returns the current scope, or null if none is active. |
|
public BinaryExpression |
getEnclosingBinaryExpression()Returns the current enclosing binary expression. |
|
public List<BinaryExpression> |
getEnclosingBinaryExpressionStack()Returns the enclosing binary-expression stack. |
|
public ClassNode |
getEnclosingClassNode()Returns the current enclosing class node. |
|
public List<ClassNode> |
getEnclosingClassNodes()Returns the enclosing class stack. |
|
public EnclosingClosure |
getEnclosingClosure()Returns the current enclosing closure metadata. |
|
public List<TypeCheckingContext.EnclosingClosure> |
getEnclosingClosureStack()Returns the enclosing closure stack. |
|
public MethodNode |
getEnclosingMethod()Returns the current enclosing method. |
|
public Expression |
getEnclosingMethodCall()Returns the current enclosing method call. |
|
public List<Expression> |
getEnclosingMethodCalls()Returns the enclosing method-call stack. |
|
public List<MethodNode> |
getEnclosingMethods()Returns the enclosing method stack. |
|
public Set<MethodNode> |
getGeneratedMethods()Returns the generated methods created by this extension. |
|
public boolean |
isAnnotatedBy(ASTNode node, Class annotation)Checks whether the node is annotated with the supplied annotation type. |
|
public boolean |
isAnnotatedBy(ASTNode node, ClassNode annotation)Checks whether the node is annotated with the supplied annotation node. |
|
public boolean |
isDynamic(VariableExpression var)Indicates whether the variable resolves dynamically. |
|
public boolean |
isExtensionMethod(MethodNode node)Indicates whether the supplied method node models an extension method. |
|
public boolean |
isGenerated(MethodNode node)Indicates whether the supplied method node was created by this extension. |
|
public boolean |
isMethodCall(Object o)Indicates whether the supplied object is a method call expression. |
|
public void |
log(String message)Logs a type-checking extension message. |
|
public MethodNode |
makeDynamic(MethodCall call)Used to instruct the type checker that the call is a dynamic method call. |
|
public MethodNode |
makeDynamic(MethodCall call, ClassNode returnType)Used to instruct the type checker that the call is a dynamic method call. |
|
public void |
makeDynamic(PropertyExpression pexp)Instructs the type checker that a property access is dynamic, returning an instance of an Object. |
|
public void |
makeDynamic(PropertyExpression pexp, ClassNode returnType)Instructs the type checker that a property access is dynamic. |
|
public void |
makeDynamic(VariableExpression vexp)Instructs the type checker that an unresolved variable is a dynamic variable of type Object. |
|
public void |
makeDynamic(VariableExpression vexp, ClassNode returnType)Instructs the type checker that an unresolved variable is a dynamic variable. |
|
public MethodNode |
newMethod(String name, Class returnType)Creates a synthetic public method with the supplied return type. |
|
public MethodNode |
newMethod(String name, ClassNode returnType)Creates a synthetic public method with the supplied return type. |
|
public MethodNode |
newMethod(String name, Callable<ClassNode> returnType)Creates a synthetic public method whose return type is resolved lazily. |
|
public AbstractTypeCheckingExtension.TypeCheckingScope |
newScope()Pushes a new extension scope onto the scope stack. |
|
public AbstractTypeCheckingExtension.TypeCheckingScope |
newScope(Closure code)Pushes a new scope and executes the supplied callback against it. |
|
public BinaryExpression |
popEnclosingBinaryExpression()Pops the current enclosing binary expression. |
|
public ClassNode |
popEnclosingClassNode()Pops the current enclosing class node. |
|
public EnclosingClosure |
popEnclosingClosure()Pops the current enclosing closure metadata. |
|
public MethodNode |
popEnclosingMethod()Pops the current enclosing method. |
|
public Expression |
popEnclosingMethodCall()Pops the current enclosing method call. |
|
public void |
popTemporaryTypeInfo()Pops the temporary type-information stack. |
|
public void |
pushEnclosingBinaryExpression(BinaryExpression binaryExpression)Pushes an enclosing binary expression onto the context stack. |
|
public void |
pushEnclosingClassNode(ClassNode classNode)Pushes an enclosing class node onto the context stack. |
|
public void |
pushEnclosingClosureExpression(ClosureExpression closureExpression)Pushes an enclosing closure expression onto the context stack. |
|
public void |
pushEnclosingMethod(MethodNode methodNode)Pushes an enclosing method onto the context stack. |
|
public void |
pushEnclosingMethodCall(Expression call)Pushes an enclosing method call onto the context stack. |
|
public void |
pushTemporaryTypeInfo()Pushes a new temporary type-information frame. |
|
protected Object |
safeCall(Closure closure, Object args)Invokes the supplied closure and reports any failure to the source unit. |
|
public AbstractTypeCheckingExtension.TypeCheckingScope |
scopeExit()Pops and returns the current scope. |
|
public AbstractTypeCheckingExtension.TypeCheckingScope |
scopeExit(Closure code)Executes the supplied callback against the current scope and then pops it. |
|
public void |
setHandled(boolean handled)Marks whether the current event was handled by the extension. |
|
public List<MethodNode> |
unique(MethodNode node)Wraps the supplied method node in a singleton list. |
<R> |
public R |
withTypeChecker(Closure<R> code)Executes the supplied closure with the type checker as delegate. |
Shared type-checking context exposed to extension helpers.
Creates an extension helper bound to the supplied visitor.
Checks whether the argument at the supplied index matches the given class.
Checks whether a method call argument at the supplied index matches the given class.
Checks whether the supplied argument types exactly match the given classes.
Checks whether a method call argument list exactly matches the given classes.
Sets closure delegation metadata with Closure.OWNER_FIRST.
Sets closure delegation metadata for the supplied type and strategy.
Sets closure delegation metadata for the supplied type, strategy, and parent metadata.
Checks whether the leading argument types match the given classes.
Checks whether a method call starts with arguments matching the given classes.
Returns the normalized argument list for the supplied method call.
Returns the current scope, or null if none is active.
Returns the current enclosing binary expression.
Returns the enclosing binary-expression stack.
Returns the current enclosing class node.
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.
Checks whether the node is annotated with the supplied annotation type.
Checks whether the node is annotated with the supplied annotation node.
Indicates whether the variable resolves dynamically.
Indicates whether the supplied method node models an extension method.
Indicates whether the supplied method node was created by this extension.
Indicates whether the supplied object is a method call expression.
Logs a type-checking extension message.
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.
call - the method call which is a dynamic method callUsed to instruct the type checker that the call is a dynamic method call. Calling this method automatically sets the handled flag to true.
call - the method call which is a dynamic method callreturnType - the expected return type of the dynamic callInstructs 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.
pexp - the property or attribute expressionInstructs the type checker that a property access is dynamic. Calling this method automatically sets the handled flag to true.
pexp - the property or attribute expressionreturnType - the type of the propertyInstructs the type checker that an unresolved variable is a dynamic variable of type Object. Calling this method automatically sets the handled flag to true.
vexp - the dynamic variableInstructs the type checker that an unresolved variable is a dynamic variable.
returnType - the type of the dynamic variable
Calling this method automatically sets the handled flag to true.vexp - the dynamic variableCreates a synthetic public method with the supplied return type.
Creates a synthetic public method with the supplied return type.
Creates a synthetic public method whose return type is resolved lazily.
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.
Pops the temporary type-information stack.
Pushes an enclosing binary expression onto the context stack.
Pushes an enclosing class node onto the context stack.
Pushes an enclosing closure expression onto the context stack.
Pushes an enclosing method onto the context stack.
Pushes an enclosing method call onto the context stack.
Pushes a new temporary type-information frame.
Invokes 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.
Marks whether the current event was handled by the extension.
Wraps the supplied method node in a singleton list.
Executes the supplied closure with the type checker as delegate.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.