[Java] Class AbstractTypeCheckingExtension

  • org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension

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.

Authors:
Cdric Champeau
Since:
2.3.0

Field Summary

Fields
Modifiers Name Description
protected TypeCheckingContext context
protected boolean debug
protected boolean handled
Inherited fields
Fields inherited from class Fields
class TypeCheckingExtension typeCheckingVisitor

Constructor Summary

Constructors
Constructor and description
AbstractTypeCheckingExtension (StaticTypeCheckingVisitor typeCheckingVisitor)

Methods Summary

Methods
Type Params Return Type Name and description
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)
void delegatesTo(ClassNode type)
void delegatesTo(ClassNode type, int strategy)
void delegatesTo(ClassNode type, int strategy, DelegationMetadata parent)
boolean firstArgTypesMatches(ClassNode[] argTypes, Class... classes)
boolean firstArgTypesMatches(MethodCall call, Class... classes)
ArgumentListExpression getArguments(MethodCall call)
AbstractTypeCheckingExtension.TypeCheckingScope getCurrentScope()
BinaryExpression getEnclosingBinaryExpression()
List<BinaryExpression> getEnclosingBinaryExpressionStack()
ClassNode getEnclosingClassNode()
List<ClassNode> getEnclosingClassNodes()
EnclosingClosure getEnclosingClosure()
List<TypeCheckingContext.EnclosingClosure> getEnclosingClosureStack()
MethodNode getEnclosingMethod()
Expression getEnclosingMethodCall()
List<Expression> getEnclosingMethodCalls()
List<MethodNode> getEnclosingMethods()
Set<MethodNode> getGeneratedMethods()
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)
void log(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(String name, Class returnType)
MethodNode newMethod(String name, ClassNode returnType)
MethodNode newMethod(String name, Callable<ClassNode> returnType)
AbstractTypeCheckingExtension.TypeCheckingScope newScope()
AbstractTypeCheckingExtension.TypeCheckingScope newScope(Closure code)
BinaryExpression popEnclosingBinaryExpression()
ClassNode popEnclosingClassNode()
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 Object safeCall(Closure closure, Object... args)
AbstractTypeCheckingExtension.TypeCheckingScope scopeExit()
AbstractTypeCheckingExtension.TypeCheckingScope scopeExit(Closure code)
void setHandled(boolean handled)
List<MethodNode> unique(MethodNode node)
<R> R withTypeChecker(Closure<R> code)

Inherited Methods Summary

Inherited Methods
Methods inherited from class Name
class TypeCheckingExtension 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
class Object wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

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()

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/2.4.21/html/gapi/org/codehaus/groovy/transform/stc/AbstractTypeCheckingExtension.html