[Java] Class AbstractTypeCheckingExtension
- org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension
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.
- Since:
- 2.3.0
Field Summary
Modifiers | Name | Description |
---|---|---|
protected TypeCheckingContext | context | |
protected boolean | debug | |
protected boolean | handled |
Fields inherited from class | Fields |
---|---|
class TypeCheckingExtension | typeCheckingVisitor |
Constructor Summary
Constructor and description |
---|
AbstractTypeCheckingExtension
(StaticTypeCheckingVisitor typeCheckingVisitor) |
Methods Summary
Inherited Methods Summary
Field Detail
protected final TypeCheckingContext context
protected boolean debug
protected boolean handled
Constructor Detail
public AbstractTypeCheckingExtension(StaticTypeCheckingVisitor typeCheckingVisitor)
Method Detail
public boolean argTypeMatches(ClassNode[] argTypes, int index, Class clazz)
public boolean argTypeMatches(MethodCall call, int index, Class clazz)
public boolean argTypesMatches(ClassNode[] argTypes, Class classes)
public boolean argTypesMatches(MethodCall call, Class classes)
public void delegatesTo(ClassNode type)
public void delegatesTo(ClassNode type, int strategy)
public void delegatesTo(ClassNode type, int strategy, DelegationMetadata parent)
public boolean firstArgTypesMatches(ClassNode[] argTypes, Class classes)
public boolean firstArgTypesMatches(MethodCall call, Class classes)
public ArgumentListExpression getArguments(MethodCall call)
public AbstractTypeCheckingExtension.TypeCheckingScope getCurrentScope()
public BinaryExpression getEnclosingBinaryExpression()
public List<BinaryExpression> getEnclosingBinaryExpressionStack()
public ClassNode getEnclosingClassNode()
public List<ClassNode> getEnclosingClassNodes()
public EnclosingClosure getEnclosingClosure()
public List<TypeCheckingContext.EnclosingClosure> getEnclosingClosureStack()
public MethodNode getEnclosingMethod()
public Expression getEnclosingMethodCall()
public List<Expression> getEnclosingMethodCalls()
public List<MethodNode> getEnclosingMethods()
public Set<MethodNode> getGeneratedMethods()
@Override public ClassNode getReturnType()
public boolean isAnnotatedBy(ASTNode node, Class annotation)
public boolean isAnnotatedBy(ASTNode node, ClassNode annotation)
public boolean isDynamic(VariableExpression var)
public boolean isExtensionMethod(MethodNode node)
public boolean isGenerated(MethodNode node)
public boolean isMethodCall(Object o)
public void log(String message)
public MethodNode makeDynamic(MethodCall call)
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
public MethodNode makeDynamic(MethodCall call, ClassNode returnType)
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 call -
returnType
- the expected return type of the dynamic call
- Returns:
- a virtual method node with the same name as the expected call
public void makeDynamic(PropertyExpression pexp)
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
public void makeDynamic(PropertyExpression pexp, ClassNode returnType)
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 expression -
returnType
- the type of the property
public void makeDynamic(VariableExpression vexp)
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
public void makeDynamic(VariableExpression vexp, ClassNode returnType)
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
public MethodNode newMethod(String name, Class returnType)
public MethodNode newMethod(String name, ClassNode returnType)
public MethodNode newMethod(String name, Callable<ClassNode> returnType)
public AbstractTypeCheckingExtension.TypeCheckingScope newScope()
public AbstractTypeCheckingExtension.TypeCheckingScope newScope(Closure code)
public BinaryExpression popEnclosingBinaryExpression()
public ClassNode popEnclosingClassNode()
public EnclosingClosure popEnclosingClosure()
public MethodNode popEnclosingMethod()
public Expression popEnclosingMethodCall()
public void popTemporaryTypeInfo()
public void pushEnclosingBinaryExpression(BinaryExpression binaryExpression)
public void pushEnclosingClassNode(ClassNode classNode)
public void pushEnclosingClosureExpression(ClosureExpression closureExpression)
public void pushEnclosingMethod(MethodNode methodNode)
public void pushEnclosingMethodCall(Expression call)
public void pushTemporaryTypeInfo()
protected Object safeCall(Closure closure, Object args)
public AbstractTypeCheckingExtension.TypeCheckingScope scopeExit()
public AbstractTypeCheckingExtension.TypeCheckingScope scopeExit(Closure code)
public void setHandled(boolean handled)
public List<MethodNode> unique(MethodNode node)
<R> @SuppressWarnings("unchecked") public R withTypeChecker(Closure<R> code)
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/org/codehaus/groovy/transform/stc/AbstractTypeCheckingExtension.html