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

public Class TraitTypeCheckingExtension

extends AbstractTypeCheckingExtension
Class Inheritance
Imports
org.codehaus.groovy.ast.ClassHelper, .ClassNode, .MethodNode, .Parameter, org.codehaus.groovy.ast.expr.ArgumentListExpression, .MethodCall, .MethodCallExpression, .VariableExpression, org.codehaus.groovy.transform.trait.TraitASTTransformation, .Traits, java.util.ArrayList, .Arrays, .Collections, .LinkedHashSet, .List

A type checking extension that will take care of handling errors which are specific to traits. In particular, it will handle the "super" method calls within a trait.
Since
2.3.0

Field Summary

Modifier and TypeField and Description
private static final List<MethodNode>
Inherited from org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension:
contextdebughandled

Constructor Summary

AccessConstructor and Description
public
TraitTypeCheckingExtension(final StaticTypeCheckingVisitor
the type checking visitor
typeCheckingVisitor
)

Builds a type checking extension relying on a Groovy script (type checking DSL).

Method Summary

Modifier and TypeMethod and Description
private List<MethodNode>
convertToDynamicCall(MethodCall call, ClassNode receiver, String[] decomposed, ClassNode[] argumentTypes)

public List<MethodNode>
handleMissingMethod(final ClassNode
the type of the receiver
receiver
,
final String
the name of the called method
name
,
final ArgumentListExpression
the list of arguments of the call
argumentList
,
final ClassNode[]
the types of the arguments of the call
argumentTypes
,
final MethodCall
the method call itself, if needed
call
)

Overrides org.codehaus.groovy.transform.stc.TypeCheckingExtension.handleMissingMethod.

This method is called by the type checker when a method call cannot be resolved.
private ClassNode
inferTraitMethodReturnType(ClassNode nextTrait, String methodName, ClassNode[] paramTypes)

private static boolean
private static boolean
public void
setup()

Overrides org.codehaus.groovy.transform.stc.TypeCheckingExtension.setup.

Subclasses should implement this method whenever they need to perform special checks before the type checker starts working.
Inherited from org.codehaus.groovy.transform.stc.AbstractTypeCheckingExtension:
argTypeMatchesargTypeMatchesargTypesMatchesargTypesMatchesdelegatesTodelegatesTodelegatesTofirstArgTypesMatchesfirstArgTypesMatchesgetArgumentsgetCurrentScopegetEnclosingBinaryExpressiongetEnclosingBinaryExpressionStackgetEnclosingClassNodegetEnclosingClassNodesgetEnclosingClosuregetEnclosingClosureStackgetEnclosingMethodgetEnclosingMethodCallgetEnclosingMethodCallsgetEnclosingMethodsgetGeneratedMethodsisAnnotatedByisAnnotatedByisDynamicisExtensionMethodisGeneratedisMethodCalllogmakeDynamicmakeDynamicmakeDynamicmakeDynamicmakeDynamicmakeDynamicnewMethodnewMethodnewMethodnewScopenewScopepopEnclosingBinaryExpressionpopEnclosingClassNodepopEnclosingClosurepopEnclosingMethodpopEnclosingMethodCallpopTemporaryTypeInfopushEnclosingBinaryExpressionpushEnclosingClassNodepushEnclosingClosureExpressionpushEnclosingMethodpushEnclosingMethodCallpushTemporaryTypeInfosafeCallscopeExitscopeExitsetHandleduniquewithTypeChecker

Field Detail

NOTFOUNDback to summary
private static final List<MethodNode> NOTFOUND

Constructor Detail

TraitTypeCheckingExtensionback to summary
public TraitTypeCheckingExtension(final StaticTypeCheckingVisitor typeCheckingVisitor)

Builds a type checking extension relying on a Groovy script (type checking DSL).

Parameters
typeCheckingVisitor:StaticTypeCheckingVisitor

the type checking visitor

Method Detail

convertToDynamicCallback to summary
private List<MethodNode> convertToDynamicCall(MethodCall call, ClassNode receiver, String[] decomposed, ClassNode[] argumentTypes)
handleMissingMethodback to summary
public List<MethodNode> handleMissingMethod(final ClassNode receiver, final String name, final ArgumentListExpression argumentList, final ClassNode[] argumentTypes, final MethodCall call)

Overrides org.codehaus.groovy.transform.stc.TypeCheckingExtension.handleMissingMethod.

Doc from org.codehaus.groovy.transform.stc.TypeCheckingExtension.handleMissingMethod.

This method is called by the type checker when a method call cannot be resolved. Extensions may override this method to handle missing methods and prevent the type checker from throwing an error.

Parameters
receiver:ClassNode

the type of the receiver

name:String

the name of the called method

argumentList:ArgumentListExpression

the list of arguments of the call

argumentTypes:ClassNode[]

the types of the arguments of the call

call:MethodCall

the method call itself, if needed

Returns:List<MethodNode>

an empty list if the extension cannot resolve the method, or a list of potential methods if the extension finds candidates. This method must not return null.

Annotations
@Override
inferTraitMethodReturnTypeback to summary
private ClassNode inferTraitMethodReturnType(ClassNode nextTrait, String methodName, ClassNode[] paramTypes)
isStaticTraitReceiverback to summary
private static boolean isStaticTraitReceiver(final ClassNode receiver, final VariableExpression var)
isThisTraitReceiverback to summary
private static boolean isThisTraitReceiver(final VariableExpression var)
setupback to summary
public void setup()

Overrides org.codehaus.groovy.transform.stc.TypeCheckingExtension.setup.

Doc from org.codehaus.groovy.transform.stc.TypeCheckingExtension.setup.

Subclasses should implement this method whenever they need to perform special checks before the type checker starts working.

Annotations
@Override