Top Description Inners Fields Constructors Methods
org.codehaus.groovy.transform.stc

public Class AbstractTypeCheckingExtension

extends TypeCheckingExtension
Class Inheritance
Known Direct Subclasses
org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport, org.codehaus.groovy.transform.stc.TraitTypeCheckingExtension
Imports
groovy.lang.Closure, org.codehaus.groovy.ast.ASTNode, .AnnotatedNode, .ClassHelper, .ClassNode, .DynamicVariable, .MethodNode, .Parameter, org.codehaus.groovy.ast.expr.ArgumentListExpression, .BinaryExpression, .ClosureExpression, .Expression, .MethodCall, .MethodCallExpression, .PropertyExpression, .VariableExpression, org.codehaus.groovy.ast.stmt.EmptyStatement, org.codehaus.groovy.classgen.asm.InvocationWriter, org.objectweb.asm.Opcodes, java.util.Collections, .LinkedHashMap, .LinkedHashSet, .LinkedList, .List, .Set, java.util.concurrent.Callable, java.util.logging.Logger

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 org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport class.

Since
2.3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
protected final TypeCheckingContext
protected boolean
private final Set<MethodNode>
protected boolean
private static final Logger
private final LinkedList<AbstractTypeCheckingExtension.TypeCheckingScope>
Inherited from org.codehaus.groovy.transform.stc.TypeCheckingExtension:
typeCheckingVisitor

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
argTypeMatches(ClassNode[] argTypes, int index, Class<T> clazz)

public boolean
argTypeMatches(MethodCall call, int index, Class<T> clazz)

public boolean
argTypesMatches(ClassNode[] argTypes, Class<T>... classes)

public boolean
argTypesMatches(MethodCall call, Class<T>... classes)

public void
public void
delegatesTo(ClassNode type, int strategy)

public void
delegatesTo(ClassNode type, int strategy, DelegationMetadata parent)

public boolean
firstArgTypesMatches(ClassNode[] argTypes, Class<T>... classes)

public boolean
firstArgTypesMatches(MethodCall call, Class<T>... classes)

public ArgumentListExpression
public AbstractTypeCheckingExtension.TypeCheckingScope
public BinaryExpression
public List<BinaryExpression>
public ClassNode
public List<ClassNode>
public TypeCheckingContext.EnclosingClosure
public List<TypeCheckingContext.EnclosingClosure>
public MethodNode
public Expression
public List<Expression>
public List<MethodNode>
public Set<MethodNode>
public boolean
isAnnotatedBy(ASTNode node, Class<T> annotation)

public boolean
isAnnotatedBy(ASTNode node, ClassNode annotation)

public boolean
public boolean
public boolean
public boolean
public void
log(String message)

public MethodNode

Returns:

a virtual method node with the same name as the expected call
makeDynamic
(MethodCall
the method call which is a dynamic method call
call
)

Used to instruct the type checker that the call is a dynamic method call.

public MethodNode

Returns:

a virtual method node with the same name as the expected call
makeDynamic
(MethodCall
the method call which is a dynamic method call
call
,
ClassNode
the expected return type of the dynamic call
returnType
)

Used to instruct the type checker that the call is a dynamic method call.

public void
makeDynamic(PropertyExpression
the property or attribute expression
pexp
)

Instructs the type checker that a property access is dynamic, returning an instance of an Object.

public void
makeDynamic(PropertyExpression
the property or attribute expression
pexp
,
ClassNode
the type of the property
returnType
)

Instructs the type checker that a property access is dynamic.

public void
makeDynamic(VariableExpression
the dynamic variable
vexp
)

Instructs the type checker that an unresolved variable is a dynamic variable of type Object.

public void
makeDynamic(VariableExpression
the dynamic variable
vexp
,
ClassNode
the type of the dynamic variable Calling this method automatically sets the handled flag to true.
returnType
)

Instructs the type checker that an unresolved variable is a dynamic variable.

private static boolean
matchWithOrWithourBoxing(final ClassNode argType, final Class<T> aClass)

public MethodNode
newMethod(final String name, final Class<T> returnType)

public MethodNode
newMethod(final String name, final ClassNode returnType)

public MethodNode
newMethod(final String name, final Callable<ClassNode> returnType)

public AbstractTypeCheckingExtension.TypeCheckingScope
public AbstractTypeCheckingExtension.TypeCheckingScope
newScope(Closure<V> code)

public BinaryExpression
public ClassNode
public TypeCheckingContext.EnclosingClosure
public MethodNode
public Expression
public void
public void
public void
public void
public void
pushEnclosingMethod(final MethodNode methodNode)

public void
public void
protected Object
safeCall(Closure<V> closure, Object... args)

public AbstractTypeCheckingExtension.TypeCheckingScope
public AbstractTypeCheckingExtension.TypeCheckingScope
scopeExit(Closure<V> code)

public void
setHandled(final boolean handled)

public List<MethodNode>
public <R> R
Inherited from org.codehaus.groovy.transform.stc.TypeCheckingExtension:
addStaticTypeErrorafterMethodCallafterVisitClassafterVisitMethodbeforeMethodCallbeforeVisitClassbeforeVisitMethodbuildListTypebuildMapTypeclassNodeForclassNodeForexistsPropertyexistsPropertyextractStaticReceiverfinishgetArgumentTypesgetTargetMethodgetTypehandleAmbiguousMethodshandleIncompatibleAssignmenthandleIncompatibleReturnTypehandleMissingMethodhandleUnresolvedAttributehandleUnresolvedPropertyhandleUnresolvedVariableExpressionisStaticMethodCallOnClasslookupClassNodeForonMethodSelectionparameterizedTypesetupstoreType

Field Detail

contextback to summary
protected final TypeCheckingContext context
debugback to summary
protected boolean debug
generatedMethodsback to summary
private final Set<MethodNode> generatedMethods
handledback to summary
protected boolean handled
LOGback to summary
private static final Logger LOG
scopeDataback to summary
private final LinkedList<AbstractTypeCheckingExtension.TypeCheckingScope> scopeData

Constructor Detail

AbstractTypeCheckingExtensionback to summary
public AbstractTypeCheckingExtension(final StaticTypeCheckingVisitor typeCheckingVisitor)

Method Detail

argTypeMatchesback to summary
public boolean argTypeMatches(ClassNode[] argTypes, int index, Class<T> clazz)
argTypeMatchesback to summary
public boolean argTypeMatches(MethodCall call, int index, Class<T> clazz)
argTypesMatchesback to summary
public boolean argTypesMatches(ClassNode[] argTypes, Class<T>... classes)
argTypesMatchesback to summary
public boolean argTypesMatches(MethodCall call, Class<T>... classes)
delegatesToback to summary
public void delegatesTo(ClassNode type)
delegatesToback to summary
public void delegatesTo(ClassNode type, int strategy)
delegatesToback to summary
public void delegatesTo(ClassNode type, int strategy, DelegationMetadata parent)
firstArgTypesMatchesback to summary
public boolean firstArgTypesMatches(ClassNode[] argTypes, Class<T>... classes)
firstArgTypesMatchesback to summary
public boolean firstArgTypesMatches(MethodCall call, Class<T>... classes)
getArgumentsback to summary
public ArgumentListExpression getArguments(MethodCall call)
getCurrentScopeback to summary
public AbstractTypeCheckingExtension.TypeCheckingScope getCurrentScope()
getEnclosingBinaryExpressionback to summary
public BinaryExpression getEnclosingBinaryExpression()
getEnclosingBinaryExpressionStackback to summary
public List<BinaryExpression> getEnclosingBinaryExpressionStack()
getEnclosingClassNodeback to summary
public ClassNode getEnclosingClassNode()
getEnclosingClassNodesback to summary
public List<ClassNode> getEnclosingClassNodes()
getEnclosingClosureback to summary
public TypeCheckingContext.EnclosingClosure getEnclosingClosure()
getEnclosingClosureStackback to summary
public List<TypeCheckingContext.EnclosingClosure> getEnclosingClosureStack()
getEnclosingMethodback to summary
public MethodNode getEnclosingMethod()
getEnclosingMethodCallback to summary
public Expression getEnclosingMethodCall()
getEnclosingMethodCallsback to summary
public List<Expression> getEnclosingMethodCalls()
getEnclosingMethodsback to summary
public List<MethodNode> getEnclosingMethods()
getGeneratedMethodsback to summary
public Set<MethodNode> getGeneratedMethods()
isAnnotatedByback to summary
public boolean isAnnotatedBy(ASTNode node, Class<T> annotation)
isAnnotatedByback to summary
public boolean isAnnotatedBy(ASTNode node, ClassNode annotation)
isDynamicback to summary
public boolean isDynamic(VariableExpression var)
isExtensionMethodback to summary
public boolean isExtensionMethod(MethodNode node)
isGeneratedback to summary
public boolean isGenerated(MethodNode node)
isMethodCallback to summary
public boolean isMethodCall(Object o)
logback to summary
public void log(String message)
makeDynamicback to summary
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:MethodCall

the method call which is a dynamic method call

Returns:MethodNode

a virtual method node with the same name as the expected call

makeDynamicback to summary
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:MethodCall

the method call which is a dynamic method call

returnType:ClassNode

the expected return type of the dynamic call

Returns:MethodNode

a virtual method node with the same name as the expected call

makeDynamicback to summary
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:PropertyExpression

the property or attribute expression

makeDynamicback to summary
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:PropertyExpression

the property or attribute expression

returnType:ClassNode

the type of the property

makeDynamicback to summary
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:VariableExpression

the dynamic variable

makeDynamicback to summary
public void makeDynamic(VariableExpression vexp, ClassNode returnType)

Instructs the type checker that an unresolved variable is a dynamic variable.

Parameters
vexp:VariableExpression

the dynamic variable

returnType:ClassNode

the type of the dynamic variable Calling this method automatically sets the handled flag to true.

matchWithOrWithourBoxingback to summary
private static boolean matchWithOrWithourBoxing(final ClassNode argType, final Class<T> aClass)
newMethodback to summary
public MethodNode newMethod(final String name, final Class<T> returnType)
newMethodback to summary
public MethodNode newMethod(final String name, final ClassNode returnType)
newMethodback to summary
public MethodNode newMethod(final String name, final Callable<ClassNode> returnType)
newScopeback to summary
public AbstractTypeCheckingExtension.TypeCheckingScope newScope()
newScopeback to summary
public AbstractTypeCheckingExtension.TypeCheckingScope newScope(Closure<V> code)
popEnclosingBinaryExpressionback to summary
public BinaryExpression popEnclosingBinaryExpression()
popEnclosingClassNodeback to summary
public ClassNode popEnclosingClassNode()
popEnclosingClosureback to summary
public TypeCheckingContext.EnclosingClosure popEnclosingClosure()
popEnclosingMethodback to summary
public MethodNode popEnclosingMethod()
popEnclosingMethodCallback to summary
public Expression popEnclosingMethodCall()
popTemporaryTypeInfoback to summary
public void popTemporaryTypeInfo()
pushEnclosingBinaryExpressionback to summary
public void pushEnclosingBinaryExpression(final BinaryExpression binaryExpression)
pushEnclosingClassNodeback to summary
public void pushEnclosingClassNode(final ClassNode classNode)
pushEnclosingClosureExpressionback to summary
public void pushEnclosingClosureExpression(final ClosureExpression closureExpression)
pushEnclosingMethodback to summary
public void pushEnclosingMethod(final MethodNode methodNode)
pushEnclosingMethodCallback to summary
public void pushEnclosingMethodCall(final Expression call)
pushTemporaryTypeInfoback to summary
public void pushTemporaryTypeInfo()
safeCallback to summary
protected Object safeCall(Closure<V> closure, Object... args)
scopeExitback to summary
public AbstractTypeCheckingExtension.TypeCheckingScope scopeExit()
scopeExitback to summary
public AbstractTypeCheckingExtension.TypeCheckingScope scopeExit(Closure<V> code)
setHandledback to summary
public void setHandled(final boolean handled)
uniqueback to summary
public List<MethodNode> unique(MethodNode node)
withTypeCheckerback to summary
public <R> R withTypeChecker(Closure<R> code)
Annotations
@SuppressWarnings:unchecked
org.codehaus.groovy.transform.stc back to summary

private Class AbstractTypeCheckingExtension.TypeCheckingScope

extends LinkedHashMap<String, Object>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final AbstractTypeCheckingExtension.TypeCheckingScope
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public AbstractTypeCheckingExtension.TypeCheckingScope
Inherited from java.util.LinkedHashMap:
clearcontainsValueentrySetforEachgetgetOrDefaultkeySetnewLinkedHashMapputFirstputLastremoveEldestEntryreplaceAllreversedsequencedEntrySetsequencedKeySetsequencedValuesvalues

Field Detail

parentback to summary
private final AbstractTypeCheckingExtension.TypeCheckingScope parent
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.LinkedHashMap.serialVersionUID.

Constructor Detail

TypeCheckingScopeback to summary
private TypeCheckingScope(final AbstractTypeCheckingExtension.TypeCheckingScope parentScope)

Method Detail

getParentback to summary
public AbstractTypeCheckingExtension.TypeCheckingScope getParent()