Class StaticTypeCheckingVisitor
java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor
- All Implemented Interfaces:
- GroovyClassVisitor,- GroovyCodeVisitor,- ErrorCollecting
- Direct Known Subclasses:
- StaticCompilationVisitor
The main class code visitor responsible for static type checking. It will perform various inspections like checking
 assignment types, type inference, ... Eventually, class nodes may be annotated with inferred type information.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classprotected class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final MethodNodestatic final MethodNodestatic final MethodNodeprotected static final ClassNodeprotected static final Expressionprotected static final intprotected FieldNodeprotected PropertyNodeprotected static final ClassNodeprotected static final ClassNodeprotected static final ClassNodeprotected static final List<MethodNode>protected static final ClassNodeprotected static final Objectprotected DefaultTypeCheckingExtensionstatic final Statementprotected static final MethodNodeprotected static final MethodNodeprotected static final MethodNodeprotected static final ClassNodeprotected static final ClassNodeDeprecated, for removal: This API element is subject to removal in a future version.protected static final ClassNodeprotected static final ClassNodeprotected static final ClassNodeprotected final ReturnAdderprotected final ReturnAdder.ReturnStatementListenerprotected static final ClassNodeprotected static final ClassNode[]protected static final ClassNodeprotected TypeCheckingContext
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddAmbiguousErrorMessage(List<MethodNode> foundMethods, String name, ClassNode[] args, Expression expr) protected voidaddAssignmentError(ClassNode leftType, ClassNode rightType, Expression expression) protected voidprotected voidaddClosureReturnType(ClassNode returnType) voidprotected voidaddNoMatchingMethodError(ClassNode receiver, String name, ClassNode[] args, ASTNode origin) protected voidaddNoMatchingMethodError(ClassNode receiver, String name, ClassNode[] args, Expression exp) protected voidaddReceivers(List<Receiver<String>> receivers, Collection<Receiver<String>> owners, boolean implicitThis) protected voidaddStaticTypeError(String msg, ASTNode node) voidaddTypeCheckingExtension(TypeCheckingExtension extension) protected voidprotected voidaddUnsupportedPreOrPostfixExpressionError(Expression expression) protected voidafterSwitchCaseStatementsVisited(SwitchStatement statement) protected voidprotected booleanareCategoryMethodCalls(List<MethodNode> foundMethods, String name, ClassNode[] args) protected booleancheckCast(ClassNode targetType, Expression source) protected voidcheckClosureParameters(Expression callArguments, ClassNode receiver) Deprecated, for removal: This API element is subject to removal in a future version.protected voidprotected voidcheckGroovyConstructorMap(Expression receiver, ClassNode receiverType, MapExpression mapExpression) protected MethodNodecheckGroovyStyleConstructor(ClassNode node, ClassNode[] arguments, ASTNode origin) Checks that a constructor style expression is valid regarding the number of arguments and the argument types.protected ClassNodecheckReturnType(ReturnStatement statement) protected booleanexistsProperty(PropertyExpression pexp, boolean checkForReadOnly) protected booleanexistsProperty(PropertyExpression pexp, boolean readMode, ClassCodeVisitorSupport visitor) Checks whether a property exists on the receiver, or on any of the possible receiver classes (found in the temporary type information table)static StringextractPropertyNameFromMethodName(String prefix, String methodName) Given a method name and a prefix, returns the name of the property that should be looked up, following the java beans rules.protected ObjectextractTemporaryTypeInfoKey(Expression expression) Computes the key to use forTypeCheckingContext.temporaryIfBranchTypeInformation.protected static ClassNode[]extractTypesFromParameters(Parameter[] parameters) protected ClassNodefindCurrentInstanceOfClass(Expression expression, ClassNode type) A helper method which determines which receiver class should be used in error messages when a field or attribute is not found.protected List<MethodNode>findMethod(ClassNode receiver, String name, ClassNode... args) protected MethodNodefindMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode... args) protected List<MethodNode>findMethodsWithGenerated(ClassNode receiver, String name) Returns methods defined for the specified receiver and adds "non-existing" methods that will be generated afterwards by the compiler; for example if a method is using default values and the class node is not compiled yet.protected static StringformatArgumentList(ClassNode[] nodes) protected ClassNode[]getArgumentTypes(ArgumentListExpression argumentList) protected org.codehaus.groovy.transform.stc.DelegationMetadatagetDelegationMetadata(ClosureExpression expression) protected static ClassNodeprotected ClassNodegetInferredReturnType(ASTNode node) Returns the inferred return type of a closure or method, if stored on the AST node.protected ClassNodegetInferredReturnTypeFromWithClosureArgument(Expression callArguments) In the case of a Object.with { ...protected ClassNodeprotected ClassNodegetResultType(ClassNode left, int op, ClassNode right, BinaryExpression expr) protected SourceUnitgetTemporaryTypesForExpression(Expression expression) protected ClassNodeprotected ClassNode[]Returns array of type checking annotations.Returns the current type checking context.protected static booleanhasRHSIncompleteGenericTypeInfo(ClassNode inferredRightExpressionType) Deprecated, for removal: This API element is subject to removal in a future version.protected voidinferClosureParameterTypes(ClassNode receiver, Expression arguments, ClosureExpression expression, Parameter target, MethodNode method) Performs type inference on closure argument types whenever code like this is found:foo.collect { it.toUpperCase() }.protected ClassNodeinferComponentType(ClassNode receiverType, ClassNode subscriptType) protected voidinferDiamondType(ConstructorCallExpression cce, ClassNode lType) protected ClassNodestatic ClassNodeinferLoopElementType(ClassNode collectionType) Returns the inferred loop element type given a loop collection type.protected ClassNodeprotected ClassNodeinferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments) If a method call returns a parameterized type, then perform additional inference on the return type, so that the type gets actual type arguments.protected ClassNodeinferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments, GenericsType[] explicitTypeHints) If a method call returns a parameterized type, then perform additional inference on the return type, so that the type gets actual type arguments.voidprotected static booleanisClassInnerClassOrEqualTo(ClassNode toBeChecked, ClassNode start) protected static booleanisNullConstant(Expression expression) protected booleanisSecondPassNeededForControlStructure(Map<VariableExpression, ClassNode> startTypes, Map<VariableExpression, List<ClassNode>> oldTracker) booleanisSkipMode(AnnotatedNode node) protected booleanTests if a node is an inner class node, and if it is, then checks if the enclosing method is skipped.protected static booleanisSuperExpression(Expression expression) protected static booleanisThisExpression(Expression expression) makeOwnerList(Expression objectExpression) Given an object expression (a message receiver expression), generate list of possible types.voidprotected Map<VariableExpression,ClassNode> popAssignmentTracking(Map<VariableExpression, List<ClassNode>> oldTracker) protected static StringprettyPrintMethodList(List<MethodNode> nodes) protected Map<VariableExpression,List<ClassNode>> protected voidpushInstanceOfTypeInfo(Expression objectOfInstanceOf, Expression typeExpression) Stores information about types when [objectOfInstanceof instanceof typeExpression] is visited.protected voidrestoreVariableExpressionMetadata(Map<VariableExpression, Map<StaticTypesMarker, Object>> typesBeforeVisit) protected voidsaveVariableExpressionMetadata(Set<VariableExpression> closureSharedExpressions, Map<VariableExpression, Map<StaticTypesMarker, Object>> typesBeforeVisit) voidsetCompilationUnit(CompilationUnit compilationUnit) voidsetMethodsToBeVisited(Set<MethodNode> methodsToBeVisited) protected booleanshouldSkipClassNode(ClassNode node) protected booleanprotected voidsilentlyVisitMethodNode(MethodNode directMethodCallCandidate) Visits a method call target, to infer the type.protected voidstartMethodInference(MethodNode node, ErrorCollector collector) protected ClassNodestoreInferredReturnType(ASTNode node, ClassNode type) Stores the inferred return type of a closure or method.protected voidstoreTargetMethod(Expression call, MethodNode target) protected voidstoreType(Expression exp, ClassNode cn) protected voidtypeCheckAssignment(BinaryExpression assignmentExpression, Expression leftExpression, ClassNode leftExpressionType, Expression rightExpression, ClassNode rightExpressionType) protected voidtypeCheckClosureCall(Expression arguments, ClassNode[] argumentTypes, Parameter[] parameters) protected MethodNodetypeCheckMapConstructor(ConstructorCallExpression call, ClassNode receiver, Expression arguments) protected booleantypeCheckMethodsWithGenericsOrFail(ClassNode receiver, ClassNode[] arguments, MethodNode candidateMethod, Expression location) voidvisitArrayExpression(ArrayExpression expression) voidvisitAttributeExpression(AttributeExpression expression) voidvisitBinaryExpression(BinaryExpression expression) voidvoidvisitCaseStatement(CaseStatement statement) voidvisitCastExpression(CastExpression expression) voidvisitClass(ClassNode node) Visit a ClassNode.voidvisitClassExpression(ClassExpression expression) voidvisitClosureExpression(ClosureExpression expression) voidVisit a ConstructorNode.voidprotected voidvisitConstructorOrMethod(MethodNode node, boolean isConstructor) voidvisitExpressionStatement(ExpressionStatement statement) voidvisitField(FieldNode node) Visit a FieldNode.voidvisitForLoop(ForStatement forLoop) voidvisitIfElse(IfStatement ifElse) voidvisitMethod(MethodNode node) Visit a MethodNode.protected voidvisitMethodCallArguments(ClassNode receiver, ArgumentListExpression arguments, boolean visitFunctors, MethodNode selectedMethod) voidvoidvisitMethodPointerExpression(MethodPointerExpression expression) voidvisitNotExpression(NotExpression expression) protected voidvoidvisitPostfixExpression(PostfixExpression expression) voidvisitPrefixExpression(PrefixExpression expression) voidvisitProperty(PropertyNode node) Visit a PropertyNode.voidvisitPropertyExpression(PropertyExpression expression) voidvisitRangeExpression(RangeExpression expression) voidvisitReturnStatement(ReturnStatement statement) voidvoidvisitSwitch(SwitchStatement statement) voidvisitTernaryExpression(TernaryExpression expression) voidvisitTryCatchFinally(TryCatchStatement statement) voidvisitUnaryMinusExpression(UnaryMinusExpression expression) voidvisitUnaryPlusExpression(UnaryPlusExpression expression) voidvoidvisitWhileLoop(WhileStatement loop) protected static ClassNodewrapTypeIfNecessary(ClassNode type) Returns a wrapped type if, and only if, the provided class node is a primitive type.Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupportvisitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCatchStatement, visitClassCodeContainer, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitImports, visitPackage, visitStatement, visitSynchronizedStatement, visitThrowStatementMethods inherited from class org.codehaus.groovy.ast.CodeVisitorSupportvisitArgumentlistExpression, visitBooleanExpression, visitBytecodeExpression, visitClosureListExpression, visitConstantExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodReferenceExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitTupleExpressionMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitorvisit, visit, visitEmptyExpression, visitListOfExpressions
- 
Field Details- 
ERROR_COLLECTOR
- 
EMPTY_METHODNODE_LIST
- 
TYPECHECKED_CLASSNODE
- 
TYPECHECKING_ANNOTATIONS
- 
TYPECHECKING_INFO_NODE
- 
DGM_CLASSNODE
- 
CURRENT_SIGNATURE_PROTOCOL_VERSIONprotected static final int CURRENT_SIGNATURE_PROTOCOL_VERSION- See Also:
 
- 
CURRENT_SIGNATURE_PROTOCOL
- 
GET_DELEGATE
- 
GET_OWNER
- 
GET_THISOBJECT
- 
DELEGATES_TO
- 
DELEGATES_TO_TARGET
- 
CLOSUREPARAMS_CLASSNODE
- 
NAMED_PARAMS_CLASSNODE
- 
NAMED_PARAM_CLASSNODE
- 
LINKEDHASHMAP_CLASSNODE@Deprecated(forRemoval=true, since="4.0.0") protected static final ClassNode LINKEDHASHMAP_CLASSNODEDeprecated, for removal: This API element is subject to removal in a future version.
- 
ENUMERATION_TYPE
- 
MAP_ENTRY_TYPE
- 
ITERABLE_TYPE
- 
CLOSURE_CALL_NO_ARG
- 
CLOSURE_CALL_ONE_ARG
- 
CLOSURE_CALL_VARGS
- 
GENERATED_EMPTY_STATEMENT
- 
returnListener
- 
returnAdder
- 
currentField
- 
currentProperty
- 
extension
- 
typeCheckingContext
 
- 
- 
Constructor Details- 
StaticTypeCheckingVisitor
 
- 
- 
Method Details- 
setCompilationUnit
- 
getSourceUnit- Specified by:
- getSourceUnitin class- ClassCodeVisitorSupport
 
- 
initializepublic void initialize()
- 
getTypeCheckingAnnotationsReturns array of type checking annotations. Subclasses may override this method in order to provide additional types which must be looked up when checking if a method or a class node should be skipped.The default implementation returns TypeChecked.
- 
getTypeCheckingContextReturns the current type checking context. The context is used internally by the type checker during type checking to store various state data.- Returns:
- the type checking context
 
- 
addTypeCheckingExtension
- 
visitClassDescription copied from interface:GroovyClassVisitorVisit a ClassNode.- Specified by:
- visitClassin interface- GroovyClassVisitor
- Overrides:
- visitClassin class- ClassCodeVisitorSupport
 
- 
shouldSkipClassNode
- 
shouldSkipMethodNode
- 
isSkipMode
- 
isSkippedInnerClassTests if a node is an inner class node, and if it is, then checks if the enclosing method is skipped.- Returns:
- true if the inner class node should be skipped
 
- 
visitClassExpression- Specified by:
- visitClassExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitClassExpressionin class- CodeVisitorSupport
 
- 
visitVariableExpression- Specified by:
- visitVariableExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitVariableExpressionin class- CodeVisitorSupport
 
- 
visitPropertyExpression- Specified by:
- visitPropertyExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitPropertyExpressionin class- CodeVisitorSupport
 
- 
visitAttributeExpression- Specified by:
- visitAttributeExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitAttributeExpressionin class- CodeVisitorSupport
 
- 
visitRangeExpression- Specified by:
- visitRangeExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitRangeExpressionin class- CodeVisitorSupport
 
- 
visitNotExpression- Specified by:
- visitNotExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitNotExpressionin class- CodeVisitorSupport
 
- 
visitBinaryExpression- Specified by:
- visitBinaryExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitBinaryExpressionin class- CodeVisitorSupport
 
- 
getOriginalDeclarationType
- 
inferDiamondType
- 
typeCheckAssignmentprotected void typeCheckAssignment(BinaryExpression assignmentExpression, Expression leftExpression, ClassNode leftExpressionType, Expression rightExpression, ClassNode rightExpressionType) 
- 
checkGroovyConstructorMapprotected void checkGroovyConstructorMap(Expression receiver, ClassNode receiverType, MapExpression mapExpression) 
- 
hasRHSIncompleteGenericTypeInfo@Deprecated(forRemoval=true, since="4.0.0") protected static boolean hasRHSIncompleteGenericTypeInfo(ClassNode inferredRightExpressionType) Deprecated, for removal: This API element is subject to removal in a future version.
- 
checkGroovyStyleConstructorprotected MethodNode checkGroovyStyleConstructor(ClassNode node, ClassNode[] arguments, ASTNode origin) Checks that a constructor style expression is valid regarding the number of arguments and the argument types.- Parameters:
- node- the class node for which we will try to find a matching constructor
- arguments- the constructor arguments
 
- 
existsProperty
- 
existsPropertyprotected boolean existsProperty(PropertyExpression pexp, boolean readMode, ClassCodeVisitorSupport visitor) Checks whether a property exists on the receiver, or on any of the possible receiver classes (found in the temporary type information table)- Parameters:
- pexp- a property expression
- readMode- if true, look for property read, else for property set
- visitor- if not null, when the property node is found, visit it with the provided visitor
- Returns:
- true if the property is defined in any of the possible receiver classes
 
- 
visitPropertyDescription copied from interface:GroovyClassVisitorVisit a PropertyNode.- Specified by:
- visitPropertyin interface- GroovyClassVisitor
- Overrides:
- visitPropertyin class- ClassCodeVisitorSupport
 
- 
visitFieldDescription copied from interface:GroovyClassVisitorVisit a FieldNode.- Specified by:
- visitFieldin interface- GroovyClassVisitor
- Overrides:
- visitFieldin class- ClassCodeVisitorSupport
 
- 
visitForLoop- Specified by:
- visitForLoopin interface- GroovyCodeVisitor
- Overrides:
- visitForLoopin class- ClassCodeVisitorSupport
 
- 
inferLoopElementTypeReturns the inferred loop element type given a loop collection type. Used, for example, to infer the element type of afor (e in list)loop.- Parameters:
- collectionType- the type of the collection
- Returns:
- the inferred component type
- See Also:
 
- 
isSecondPassNeededForControlStructureprotected boolean isSecondPassNeededForControlStructure(Map<VariableExpression, ClassNode> startTypes, Map<VariableExpression, List<ClassNode>> oldTracker) 
- 
visitWhileLoop- Specified by:
- visitWhileLoopin interface- GroovyCodeVisitor
- Overrides:
- visitWhileLoopin class- ClassCodeVisitorSupport
 
- 
visitBitwiseNegationExpression- Specified by:
- visitBitwiseNegationExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitBitwiseNegationExpressionin class- CodeVisitorSupport
 
- 
visitUnaryPlusExpression- Specified by:
- visitUnaryPlusExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitUnaryPlusExpressionin class- CodeVisitorSupport
 
- 
visitUnaryMinusExpression- Specified by:
- visitUnaryMinusExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitUnaryMinusExpressionin class- CodeVisitorSupport
 
- 
visitPostfixExpression- Specified by:
- visitPostfixExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitPostfixExpressionin class- CodeVisitorSupport
 
- 
visitPrefixExpression- Specified by:
- visitPrefixExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitPrefixExpressionin class- CodeVisitorSupport
 
- 
visitExpressionStatement- Specified by:
- visitExpressionStatementin interface- GroovyCodeVisitor
- Overrides:
- visitExpressionStatementin class- ClassCodeVisitorSupport
 
- 
visitReturnStatement- Specified by:
- visitReturnStatementin interface- GroovyCodeVisitor
- Overrides:
- visitReturnStatementin class- ClassCodeVisitorSupport
 
- 
checkReturnType
- 
addClosureReturnType
- 
visitConstructorCallExpression- Specified by:
- visitConstructorCallExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitConstructorCallExpressionin class- CodeVisitorSupport
 
- 
typeCheckMapConstructorprotected MethodNode typeCheckMapConstructor(ConstructorCallExpression call, ClassNode receiver, Expression arguments) 
- 
getArgumentTypes
- 
visitClosureExpression- Specified by:
- visitClosureExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitClosureExpressionin class- ClassCodeVisitorSupport
 
- 
visitMethodPointerExpression- Specified by:
- visitMethodPointerExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitMethodPointerExpressionin class- CodeVisitorSupport
 
- 
getDelegationMetadataprotected org.codehaus.groovy.transform.stc.DelegationMetadata getDelegationMetadata(ClosureExpression expression) 
- 
restoreVariableExpressionMetadataprotected void restoreVariableExpressionMetadata(Map<VariableExpression, Map<StaticTypesMarker, Object>> typesBeforeVisit) 
- 
saveVariableExpressionMetadataprotected void saveVariableExpressionMetadata(Set<VariableExpression> closureSharedExpressions, Map<VariableExpression, Map<StaticTypesMarker, Object>> typesBeforeVisit) 
- 
visitConstructorDescription copied from interface:GroovyClassVisitorVisit a ConstructorNode.- Specified by:
- visitConstructorin interface- GroovyClassVisitor
- Overrides:
- visitConstructorin class- ClassCodeVisitorSupport
 
- 
visitMethodDescription copied from interface:GroovyClassVisitorVisit a MethodNode.- Specified by:
- visitMethodin interface- GroovyClassVisitor
- Overrides:
- visitMethodin class- ClassCodeVisitorSupport
 
- 
startMethodInference
- 
visitConstructorOrMethod- Overrides:
- visitConstructorOrMethodin class- ClassCodeVisitorSupport
 
- 
visitObjectInitializerStatements- Overrides:
- visitObjectInitializerStatementsin class- ClassCodeVisitorSupport
 
- 
addTypeCheckingInfoAnnotation
- 
visitStaticMethodCallExpression- Specified by:
- visitStaticMethodCallExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitStaticMethodCallExpressionin class- CodeVisitorSupport
 
- 
checkClosureParameters@Deprecated(forRemoval=true, since="2.5.0") protected void checkClosureParameters(Expression callArguments, ClassNode receiver) Deprecated, for removal: This API element is subject to removal in a future version.this method is unused, replaced withDelegatesToinference.
- 
silentlyVisitMethodNodeVisits a method call target, to infer the type. Don't report errors right away, that will be done by a later visitMethod call.
- 
visitMethodCallArgumentsprotected void visitMethodCallArguments(ClassNode receiver, ArgumentListExpression arguments, boolean visitFunctors, MethodNode selectedMethod) 
- 
inferClosureParameterTypesprotected void inferClosureParameterTypes(ClassNode receiver, Expression arguments, ClosureExpression expression, Parameter target, MethodNode method) Performs type inference on closure argument types whenever code like this is found:foo.collect { it.toUpperCase() }.In this case the type checker tries to find if the collectmethod has itsClosureargument annotated withClosureParams. If so, then additional type inference can be performed and the type ofitmay be inferred.- Parameters:
- receiver-
- arguments-
- expression- closure or lambda expression for which the argument types should be inferred
- target- parameter which may provide- ClosureParamsannotation or SAM type
- method- method that declares- target
 
- 
addReceivers
- 
visitMethodCallExpression- Specified by:
- visitMethodCallExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitMethodCallExpressionin class- CodeVisitorSupport
 
- 
getInferredReturnTypeFromWithClosureArgumentIn the case of a Object.with { ... } call, this method is supposed to retrieve the inferred closure return type.- Parameters:
- callArguments- the argument list from the Object#with(Closure) call, i.e. a single closure expression
- Returns:
- the inferred closure return type or null
 
- 
makeOwnerListGiven an object expression (a message receiver expression), generate list of possible types.- Parameters:
- objectExpression- the message receiver
- Returns:
- types and qualifiers of the receiver
 
- 
checkForbiddenSpreadArgument
- 
storeTargetMethod
- 
typeCheckClosureCallprotected void typeCheckClosureCall(Expression arguments, ClassNode[] argumentTypes, Parameter[] parameters) 
- 
visitIfElse- Specified by:
- visitIfElsein interface- GroovyCodeVisitor
- Overrides:
- visitIfElsein class- ClassCodeVisitorSupport
 
- 
visitSwitch- Specified by:
- visitSwitchin interface- GroovyCodeVisitor
- Overrides:
- visitSwitchin class- ClassCodeVisitorSupport
 
- 
afterSwitchConditionExpressionVisited- Overrides:
- afterSwitchConditionExpressionVisitedin class- CodeVisitorSupport
 
- 
afterSwitchCaseStatementsVisited- Overrides:
- afterSwitchCaseStatementsVisitedin class- CodeVisitorSupport
 
- 
visitCaseStatement- Specified by:
- visitCaseStatementin interface- GroovyCodeVisitor
- Overrides:
- visitCaseStatementin class- ClassCodeVisitorSupport
 
- 
pushAssignmentTracking
- 
popAssignmentTrackingprotected Map<VariableExpression,ClassNode> popAssignmentTracking(Map<VariableExpression, List<ClassNode>> oldTracker) 
- 
visitArrayExpression- Specified by:
- visitArrayExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitArrayExpressionin class- CodeVisitorSupport
 
- 
visitCastExpression- Specified by:
- visitCastExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitCastExpressionin class- CodeVisitorSupport
 
- 
checkCast
- 
visitTernaryExpression- Specified by:
- visitTernaryExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitTernaryExpressionin class- CodeVisitorSupport
 
- 
visitTryCatchFinally- Specified by:
- visitTryCatchFinallyin interface- GroovyCodeVisitor
- Overrides:
- visitTryCatchFinallyin class- ClassCodeVisitorSupport
 
- 
storeType
- 
getResultType
- 
getGroupOperationResultType
- 
inferComponentType
- 
findMethodOrFailprotected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode... args) 
- 
prettyPrintMethodList
- 
areCategoryMethodCallsprotected boolean areCategoryMethodCalls(List<MethodNode> foundMethods, String name, ClassNode[] args) 
- 
findMethodsWithGeneratedReturns methods defined for the specified receiver and adds "non-existing" methods that will be generated afterwards by the compiler; for example if a method is using default values and the class node is not compiled yet.- Parameters:
- receiver- the type to search for methods
- name- the name of the methods to return
- Returns:
- the methods that are defined on the receiver completed with stubs for future methods
 
- 
findMethod
- 
extractPropertyNameFromMethodNameGiven a method name and a prefix, returns the name of the property that should be looked up, following the java beans rules. For example, "getName" would return "name", while "getFullName" would return "fullName". If the prefix is not found, returns null.- Parameters:
- prefix- the method name prefix ("get", "is", "set", ...)
- methodName- the method name
- Returns:
- a property name if the prefix is found and the method matches the java beans rules, null otherwise
 
- 
getType
- 
storeInferredReturnTypeStores the inferred return type of a closure or method. We are using a separate key to store inferred return type because the inferred type of a closure isClosure, which is different from the inferred type of the code of the closure.- Parameters:
- node- a- ClosureExpressionor- MethodNode
- type- the inferred return type of the code
- Returns:
- The old value of the inferred type.
 
- 
getInferredReturnTypeReturns the inferred return type of a closure or method, if stored on the AST node. This method doesn't perform any type inference by itself.- Parameters:
- node- a- ClosureExpressionor- MethodNode
- Returns:
- The expected return type.
 
- 
isNullConstant
- 
isThisExpression
- 
isSuperExpression
- 
inferListExpressionType
- 
inferMapExpressionType
- 
inferReturnTypeGenericsprotected ClassNode inferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments) If a method call returns a parameterized type, then perform additional inference on the return type, so that the type gets actual type arguments. For example, the methodArrays.asList(T...)is parameterized withT, which can be deduced type arguments or call arguments.- Parameters:
- method- the method node
- arguments- the method call arguments
- receiver- the object expression type
 
- 
inferReturnTypeGenericsprotected ClassNode inferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments, GenericsType[] explicitTypeHints) If a method call returns a parameterized type, then perform additional inference on the return type, so that the type gets actual type arguments. For example, the methodArrays.asList(T...)is parameterized withT, which can be deduced type arguments or call arguments.- Parameters:
- method- the method node
- arguments- the method call arguments
- receiver- the object expression type
- explicitTypeHints- type arguments (optional), for example- Collections.<String>emptyList()
 
- 
typeCheckMethodsWithGenericsOrFailprotected boolean typeCheckMethodsWithGenericsOrFail(ClassNode receiver, ClassNode[] arguments, MethodNode candidateMethod, Expression location) 
- 
formatArgumentList
- 
addError- Specified by:
- addErrorin interface- ErrorCollecting
- Overrides:
- addErrorin class- ClassCodeVisitorSupport
 
- 
addStaticTypeError
- 
addNoMatchingMethodErrorprotected void addNoMatchingMethodError(ClassNode receiver, String name, ClassNode[] args, Expression exp) 
- 
addNoMatchingMethodError
- 
addAmbiguousErrorMessageprotected void addAmbiguousErrorMessage(List<MethodNode> foundMethods, String name, ClassNode[] args, Expression expr) 
- 
addCategoryMethodCallError
- 
addAssignmentError
- 
addUnsupportedPreOrPostfixExpressionError
- 
setMethodsToBeVisited
- 
performSecondPasspublic void performSecondPass()
- 
extractTypesFromParameters
- 
wrapTypeIfNecessaryReturns a wrapped type if, and only if, the provided class node is a primitive type. This method differs fromClassHelper.getWrapper(org.codehaus.groovy.ast.ClassNode)as it will return the same instance if the provided type is not a generic type.- Returns:
- the wrapped type
 
- 
isClassInnerClassOrEqualTo
- 
pushInstanceOfTypeInfoStores information about types when [objectOfInstanceof instanceof typeExpression] is visited.- Parameters:
- objectOfInstanceOf- the expression to be checked against instanceof
- typeExpression- the expression which represents the target type
 
- 
extractTemporaryTypeInfoKeyComputes the key to use forTypeCheckingContext.temporaryIfBranchTypeInformation.
- 
findCurrentInstanceOfClassA helper method which determines which receiver class should be used in error messages when a field or attribute is not found. The returned type class depends on whether we have temporary type information available (due to instanceof checks) and whether there is a single candidate in that case.- Parameters:
- expression- the expression for which an unknown field has been found
- type- the type of the expression (used as fallback type)
- Returns:
- if temporary information is available and there's only one type, returns the temporary type class otherwise falls back to the provided type class.
 
- 
getTemporaryTypesForExpression
 
- 
DelegatesToinference.