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
 
 public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport 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 Classes Modifier and Type Class Description static classStaticTypeCheckingVisitor.SignatureCodecFactoryprotected classStaticTypeCheckingVisitor.VariableExpressionTypeMemoizer
 - 
Field Summary
 - 
Constructor SummaryConstructors Constructor Description StaticTypeCheckingVisitor(SourceUnit source, ClassNode classNode)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddAmbiguousErrorMessage(List<MethodNode> foundMethods, String name, ClassNode[] args, Expression expr)protected voidaddAssignmentError(ClassNode leftType, ClassNode rightType, Expression assignmentExpression)protected voidaddCategoryMethodCallError(Expression call)protected voidaddClosureReturnType(ClassNode returnType)voidaddError(String msg, ASTNode expr)protected voidaddNoMatchingMethodError(ClassNode receiver, String name, ClassNode[] args, Expression call)protected voidaddReceivers(List<Receiver<String>> receivers, Collection<Receiver<String>> owners, boolean implicitThis)protected voidaddStaticTypeError(String msg, ASTNode expr)voidaddTypeCheckingExtension(TypeCheckingExtension extension)protected voidaddTypeCheckingInfoAnnotation(MethodNode node)protected voidaddUnsupportedPreOrPostfixExpressionError(Expression expression)protected voidafterSwitchConditionExpressionVisited(SwitchStatement statement)protected booleanareCategoryMethodCalls(List<MethodNode> foundMethods, String name, ClassNode[] args)protected booleancheckCast(ClassNode targetType, Expression source)protected voidcheckClosureParameters(Expression callArguments, ClassNode receiver)Deprecated.this method is unused, replaced withDelegatesToinference.protected voidcheckForbiddenSpreadArgument(ArgumentListExpression argumentList)protected voidcheckGroovyConstructorMap(Expression receiver, ClassNode receiverType, MapExpression mapExpression)protected voidcheckGroovyStyleConstructor(ClassNode node, ClassNode[] arguments)protected MethodNodecheckGroovyStyleConstructor(ClassNode node, ClassNode[] arguments, ASTNode source)Checks that a constructor style expression is valid regarding the number of arguments and the argument types.protected ClassNodecheckReturnType(ReturnStatement statement)protected voidcollectAllInterfaceMethodsByName(ClassNode type, String name, List<MethodNode> methods)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)When instanceof checks are found in the code, we store temporary type information data in theTypeCheckingContext.temporaryIfBranchTypeInformationtable.protected static ClassNode[]extractTypesFromParameters(Parameter[] parameters)protected ClassNodefindCurrentInstanceOfClass(Expression expr, 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 BinaryExpressionfindInstanceOfNotReturnExpression(IfStatement ifElse)Check IfStatement matched pattern : Object var1; if (!(var1 instanceOf Runnable)) { return } // Here var1 instance of Runnableprotected 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 isn't compiled yet.protected BinaryExpressionfindNotInstanceOfReturnExpression(IfStatement ifElse)Check IfStatement matched pattern : Object var1; if (var1 !instanceOf Runnable) { return } // Here var1 instance of Runnableprotected static StringformatArgumentList(ClassNode[] nodes)protected ClassNode[]getArgumentTypes(ArgumentListExpression args)protected org.codehaus.groovy.transform.stc.DelegationMetadatagetDelegationMetadata(ClosureExpression expression)protected static ClassNodegetGroupOperationResultType(ClassNode a, ClassNode b)protected ClassNodegetInferredReturnType(ASTNode exp)Returns the inferred return type of a closure or a method, if stored on the AST node.protected ClassNodegetInferredReturnTypeFromWithClosureArgument(Expression callArguments)In the case of a Object.with { ...protected ClassNodegetOriginalDeclarationType(Expression lhs)protected ClassNodegetResultType(ClassNode left, int op, ClassNode right, BinaryExpression expr)protected SourceUnitgetSourceUnit()protected List<ClassNode>getTemporaryTypesForExpression(Expression objectExpression)protected ClassNodegetType(ASTNode exp)protected ClassNode[]getTypeCheckingAnnotations()Returns array of type checking annotations.TypeCheckingContextgetTypeCheckingContext()Returns the current type checking context.protected static booleanhasRHSIncompleteGenericTypeInfo(ClassNode inferredRightExpressionType)protected voidinferClosureParameterTypes(ClassNode receiver, Expression arguments, ClosureExpression expression, Parameter param, MethodNode selectedMethod)This method is responsible for performing type inference on closure argument types whenever code like this is found:foo.collect { it.toUpperCase() }.protected ClassNodeinferComponentType(ClassNode containerType, ClassNode indexType)protected voidinferDiamondType(ConstructorCallExpression cce, ClassNode lType)protected ClassNodeinferListExpressionType(ListExpression list)static ClassNodeinferLoopElementType(ClassNode collectionType)Given a loop collection type, returns the inferred type of the loop element.protected ClassNodeinferMapExpressionType(MapExpression map)protected ClassNodeinferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments)If a method call returns a parameterized type, then we can perform additional inference on the return type, so that the type gets actual type parameters.protected ClassNodeinferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments, GenericsType[] explicitTypeHints)If a method call returns a parameterized type, then we can perform additional inference on the return type, so that the type gets actual type parameters.voidinitialize()protected static booleanisClassInnerClassOrEqualTo(ClassNode toBeChecked, ClassNode start)protected booleanisClosureCall(String name, Expression objectExpression, Expression arguments)protected static booleanisNullConstant(Expression expression)protected booleanisSecondPassNeededForControlStructure(Map<VariableExpression,ClassNode> varOrigType, Map<VariableExpression,List<ClassNode>> oldTracker)booleanisSkipMode(AnnotatedNode node)protected booleanisSkippedInnerClass(AnnotatedNode node)Tests 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)protected List<Receiver<String>>makeOwnerList(Expression objectExpression)Given an object expression (a receiver expression), generate the list of potential receiver types.voidperformSecondPass()protected Map<VariableExpression,ClassNode>popAssignmentTracking(Map<VariableExpression,List<ClassNode>> oldTracker)protected static StringprettyPrintMethodList(List<MethodNode> nodes)protected Map<VariableExpression,List<ClassNode>>pushAssignmentTracking()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 booleanshouldSkipMethodNode(MethodNode node)protected 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 a method.protected voidstoreInferredTypeForPropertyExpression(PropertyExpression pexp, ClassNode flatInferredType)protected voidstoreTargetMethod(Expression call, MethodNode directMethodCallCandidate)protected voidstoreType(Expression exp, ClassNode cn)protected voidtypeCheckAssignment(BinaryExpression assignmentExpression, Expression leftExpression, ClassNode leftExpressionType, Expression rightExpression, ClassNode inferredRightExpressionTypeOrig)protected voidtypeCheckClosureCall(Expression callArguments, ClassNode[] args, 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)voidvisitBitwiseNegationExpression(BitwiseNegationExpression expression)voidvisitBlockStatement(BlockStatement block)voidvisitCaseStatement(CaseStatement statement)voidvisitCastExpression(CastExpression expression)voidvisitClass(ClassNode node)Visit a ClassNode.voidvisitClassExpression(ClassExpression expression)voidvisitClosingBlock(BlockStatement block)voidvisitClosureExpression(ClosureExpression expression)voidvisitConstructor(ConstructorNode node)Visit a ConstructorNode.voidvisitConstructorCallExpression(ConstructorCallExpression call)protected voidvisitConstructorOrMethod(MethodNode node, boolean isConstructor)voidvisitExpressionStatement(ExpressionStatement statement)voidvisitField(FieldNode node)Visit a FieldNode.voidvisitForLoop(ForStatement forLoop)voidvisitIfElse(IfStatement ifElse)protected voidvisitInstanceofNot(BinaryExpression be)voidvisitMethod(MethodNode node)Visit a MethodNode.protected voidvisitMethodCallArguments(ClassNode receiver, ArgumentListExpression arguments, boolean visitClosures, MethodNode selectedMethod)voidvisitMethodCallExpression(MethodCallExpression call)voidvisitMethodPointerExpression(MethodPointerExpression expression)voidvisitNotExpression(NotExpression expression)voidvisitPostfixExpression(PostfixExpression expression)voidvisitPrefixExpression(PrefixExpression expression)voidvisitProperty(PropertyNode node)Visit a PropertyNode.voidvisitPropertyExpression(PropertyExpression expression)voidvisitRangeExpression(RangeExpression expression)voidvisitReturnStatement(ReturnStatement statement)voidvisitStaticMethodCallExpression(StaticMethodCallExpression call)voidvisitSwitch(SwitchStatement statement)voidvisitTernaryExpression(TernaryExpression expression)voidvisitTryCatchFinally(TryCatchStatement statement)voidvisitUnaryMinusExpression(UnaryMinusExpression expression)voidvisitUnaryPlusExpression(UnaryPlusExpression expression)voidvisitVariableExpression(VariableExpression vexp)voidvisitWhileLoop(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, visitAssertStatement, visitBreakStatement, visitCatchStatement, visitClassCodeContainer, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitImports, visitObjectInitializerStatements, visitPackage, visitStatement, visitSynchronizedStatement, visitThrowStatement
 - 
Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupportvisitArgumentlistExpression, visitBooleanExpression, visitBytecodeExpression, visitClosureListExpression, visitConstantExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodReferenceExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitTupleExpression
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitorvisitEmptyExpression, visitListOfExpressions
 
- 
 
- 
- 
- 
Field Detail- 
ERROR_COLLECTORprotected static final Object ERROR_COLLECTOR 
 - 
ITERABLE_TYPEprotected static final ClassNode ITERABLE_TYPE 
 - 
EMPTY_METHODNODE_LISTprotected static final List<MethodNode> EMPTY_METHODNODE_LIST 
 - 
TYPECHECKED_CLASSNODEprotected static final ClassNode TYPECHECKED_CLASSNODE 
 - 
TYPECHECKING_ANNOTATIONSprotected static final ClassNode[] TYPECHECKING_ANNOTATIONS 
 - 
TYPECHECKING_INFO_NODEprotected static final ClassNode TYPECHECKING_INFO_NODE 
 - 
DGM_CLASSNODEprotected static final ClassNode DGM_CLASSNODE 
 - 
CURRENT_SIGNATURE_PROTOCOL_VERSIONprotected static final int CURRENT_SIGNATURE_PROTOCOL_VERSION - See Also:
- Constant Field Values
 
 - 
CURRENT_SIGNATURE_PROTOCOLprotected static final Expression CURRENT_SIGNATURE_PROTOCOL 
 - 
GET_DELEGATEprotected static final MethodNode GET_DELEGATE 
 - 
GET_OWNERprotected static final MethodNode GET_OWNER 
 - 
GET_THISOBJECTprotected static final MethodNode GET_THISOBJECT 
 - 
DELEGATES_TOprotected static final ClassNode DELEGATES_TO 
 - 
DELEGATES_TO_TARGETprotected static final ClassNode DELEGATES_TO_TARGET 
 - 
LINKEDHASHMAP_CLASSNODEprotected static final ClassNode LINKEDHASHMAP_CLASSNODE 
 - 
CLOSUREPARAMS_CLASSNODEprotected static final ClassNode CLOSUREPARAMS_CLASSNODE 
 - 
NAMED_PARAMS_CLASSNODEprotected static final ClassNode NAMED_PARAMS_CLASSNODE 
 - 
MAP_ENTRY_TYPEprotected static final ClassNode MAP_ENTRY_TYPE 
 - 
ENUMERATION_TYPEprotected static final ClassNode ENUMERATION_TYPE 
 - 
GENERATED_EMPTY_STATEMENTpublic static final Statement GENERATED_EMPTY_STATEMENT 
 - 
CLOSURE_CALL_NO_ARGpublic static final MethodNode CLOSURE_CALL_NO_ARG 
 - 
CLOSURE_CALL_ONE_ARGpublic static final MethodNode CLOSURE_CALL_ONE_ARG 
 - 
CLOSURE_CALL_VARGSpublic static final MethodNode CLOSURE_CALL_VARGS 
 - 
returnListenerprotected final ReturnAdder.ReturnStatementListener returnListener 
 - 
returnAdderprotected final ReturnAdder returnAdder 
 - 
currentFieldprotected FieldNode currentField 
 - 
currentPropertyprotected PropertyNode currentProperty 
 - 
extensionprotected DefaultTypeCheckingExtension extension 
 - 
typeCheckingContextprotected TypeCheckingContext typeCheckingContext 
 
- 
 - 
Constructor Detail- 
StaticTypeCheckingVisitorpublic StaticTypeCheckingVisitor(SourceUnit source, ClassNode classNode) 
 
- 
 - 
Method Detail- 
getSourceUnitprotected SourceUnit getSourceUnit() - Specified by:
- getSourceUnitin class- ClassCodeVisitorSupport
 
 - 
initializepublic void initialize() 
 - 
getTypeCheckingContextpublic TypeCheckingContext getTypeCheckingContext() Returns 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
 
 - 
addTypeCheckingExtensionpublic void addTypeCheckingExtension(TypeCheckingExtension extension) 
 - 
setCompilationUnitpublic void setCompilationUnit(CompilationUnit compilationUnit) 
 - 
visitClasspublic void visitClass(ClassNode node) Description copied from interface:GroovyClassVisitorVisit a ClassNode.- Specified by:
- visitClassin interface- GroovyClassVisitor
- Overrides:
- visitClassin class- ClassCodeVisitorSupport
 
 - 
getTypeCheckingAnnotationsprotected ClassNode[] getTypeCheckingAnnotations() Returns 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.
 - 
shouldSkipClassNodeprotected boolean shouldSkipClassNode(ClassNode node) 
 - 
isSkipModepublic boolean isSkipMode(AnnotatedNode node) 
 - 
isSkippedInnerClassprotected boolean isSkippedInnerClass(AnnotatedNode node) Tests 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
 
 - 
visitClassExpressionpublic void visitClassExpression(ClassExpression expression) - Specified by:
- visitClassExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitClassExpressionin class- CodeVisitorSupport
 
 - 
visitVariableExpressionpublic void visitVariableExpression(VariableExpression vexp) - Specified by:
- visitVariableExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitVariableExpressionin class- CodeVisitorSupport
 
 - 
visitPropertyExpressionpublic void visitPropertyExpression(PropertyExpression expression) - Specified by:
- visitPropertyExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitPropertyExpressionin class- CodeVisitorSupport
 
 - 
visitAttributeExpressionpublic void visitAttributeExpression(AttributeExpression expression) - Specified by:
- visitAttributeExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitAttributeExpressionin class- CodeVisitorSupport
 
 - 
visitRangeExpressionpublic void visitRangeExpression(RangeExpression expression) - Specified by:
- visitRangeExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitRangeExpressionin class- CodeVisitorSupport
 
 - 
visitNotExpressionpublic void visitNotExpression(NotExpression expression) - Specified by:
- visitNotExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitNotExpressionin class- CodeVisitorSupport
 
 - 
visitBinaryExpressionpublic void visitBinaryExpression(BinaryExpression expression) - Specified by:
- visitBinaryExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitBinaryExpressionin class- CodeVisitorSupport
 
 - 
getOriginalDeclarationTypeprotected ClassNode getOriginalDeclarationType(Expression lhs) 
 - 
inferDiamondTypeprotected void inferDiamondType(ConstructorCallExpression cce, ClassNode lType) 
 - 
pushInstanceOfTypeInfoprotected void pushInstanceOfTypeInfo(Expression objectOfInstanceOf, Expression typeExpression) Stores information about types when [objectOfInstanceof instanceof typeExpression] is visited.- Parameters:
- objectOfInstanceOf- the expression which must be checked against instanceof
- typeExpression- the expression which represents the target type
 
 - 
typeCheckAssignmentprotected void typeCheckAssignment(BinaryExpression assignmentExpression, Expression leftExpression, ClassNode leftExpressionType, Expression rightExpression, ClassNode inferredRightExpressionTypeOrig) 
 - 
checkGroovyConstructorMapprotected void checkGroovyConstructorMap(Expression receiver, ClassNode receiverType, MapExpression mapExpression) 
 - 
hasRHSIncompleteGenericTypeInfoprotected static boolean hasRHSIncompleteGenericTypeInfo(ClassNode inferredRightExpressionType) 
 - 
checkGroovyStyleConstructor@Deprecated protected void checkGroovyStyleConstructor(ClassNode node, ClassNode[] arguments) Deprecated.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
 
 - 
checkGroovyStyleConstructorprotected MethodNode checkGroovyStyleConstructor(ClassNode node, ClassNode[] arguments, ASTNode source) 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
 
 - 
extractTemporaryTypeInfoKeyprotected Object extractTemporaryTypeInfoKey(Expression expression) When instanceof checks are found in the code, we store temporary type information data in theTypeCheckingContext.temporaryIfBranchTypeInformationtable. This method computes the key which must be used to store this type info.- Parameters:
- expression- the expression for which to compute the key
- Returns:
- a key to be used for TypeCheckingContext.temporaryIfBranchTypeInformation
 
 - 
findCurrentInstanceOfClassprotected ClassNode findCurrentInstanceOfClass(Expression expr, ClassNode type) A 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:
- expr- 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.
 
 - 
existsPropertyprotected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly) 
 - 
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
 
 - 
storeInferredTypeForPropertyExpressionprotected void storeInferredTypeForPropertyExpression(PropertyExpression pexp, ClassNode flatInferredType) 
 - 
visitPropertypublic void visitProperty(PropertyNode node) Description copied from interface:GroovyClassVisitorVisit a PropertyNode.- Specified by:
- visitPropertyin interface- GroovyClassVisitor
- Overrides:
- visitPropertyin class- ClassCodeVisitorSupport
 
 - 
visitFieldpublic void visitField(FieldNode node) Description copied from interface:GroovyClassVisitorVisit a FieldNode.- Specified by:
- visitFieldin interface- GroovyClassVisitor
- Overrides:
- visitFieldin class- ClassCodeVisitorSupport
 
 - 
visitForLooppublic void visitForLoop(ForStatement forLoop) - Specified by:
- visitForLoopin interface- GroovyCodeVisitor
- Overrides:
- visitForLoopin class- ClassCodeVisitorSupport
 
 - 
inferLoopElementTypepublic static ClassNode inferLoopElementType(ClassNode collectionType) Given a loop collection type, returns the inferred type of the loop element. Used, for example, to infer the element type of a (for e in list) loop.- Parameters:
- collectionType- the type of the collection
- Returns:
- the inferred component type
 
 - 
isSecondPassNeededForControlStructureprotected boolean isSecondPassNeededForControlStructure(Map<VariableExpression,ClassNode> varOrigType, Map<VariableExpression,List<ClassNode>> oldTracker) 
 - 
visitWhileLooppublic void visitWhileLoop(WhileStatement loop) - Specified by:
- visitWhileLoopin interface- GroovyCodeVisitor
- Overrides:
- visitWhileLoopin class- ClassCodeVisitorSupport
 
 - 
visitBitwiseNegationExpressionpublic void visitBitwiseNegationExpression(BitwiseNegationExpression expression) - Specified by:
- visitBitwiseNegationExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitBitwiseNegationExpressionin class- CodeVisitorSupport
 
 - 
visitUnaryPlusExpressionpublic void visitUnaryPlusExpression(UnaryPlusExpression expression) - Specified by:
- visitUnaryPlusExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitUnaryPlusExpressionin class- CodeVisitorSupport
 
 - 
visitUnaryMinusExpressionpublic void visitUnaryMinusExpression(UnaryMinusExpression expression) - Specified by:
- visitUnaryMinusExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitUnaryMinusExpressionin class- CodeVisitorSupport
 
 - 
visitPostfixExpressionpublic void visitPostfixExpression(PostfixExpression expression) - Specified by:
- visitPostfixExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitPostfixExpressionin class- CodeVisitorSupport
 
 - 
visitPrefixExpressionpublic void visitPrefixExpression(PrefixExpression expression) - Specified by:
- visitPrefixExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitPrefixExpressionin class- CodeVisitorSupport
 
 - 
visitConstructorOrMethodprotected void visitConstructorOrMethod(MethodNode node, boolean isConstructor) - Overrides:
- visitConstructorOrMethodin class- ClassCodeVisitorSupport
 
 - 
visitExpressionStatementpublic void visitExpressionStatement(ExpressionStatement statement) - Specified by:
- visitExpressionStatementin interface- GroovyCodeVisitor
- Overrides:
- visitExpressionStatementin class- ClassCodeVisitorSupport
 
 - 
visitReturnStatementpublic void visitReturnStatement(ReturnStatement statement) - Specified by:
- visitReturnStatementin interface- GroovyCodeVisitor
- Overrides:
- visitReturnStatementin class- ClassCodeVisitorSupport
 
 - 
checkReturnTypeprotected ClassNode checkReturnType(ReturnStatement statement) 
 - 
addClosureReturnTypeprotected void addClosureReturnType(ClassNode returnType) 
 - 
visitConstructorCallExpressionpublic void visitConstructorCallExpression(ConstructorCallExpression call) - Specified by:
- visitConstructorCallExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitConstructorCallExpressionin class- CodeVisitorSupport
 
 - 
typeCheckMapConstructorprotected MethodNode typeCheckMapConstructor(ConstructorCallExpression call, ClassNode receiver, Expression arguments) 
 - 
getArgumentTypesprotected ClassNode[] getArgumentTypes(ArgumentListExpression args) 
 - 
visitClosureExpressionpublic void visitClosureExpression(ClosureExpression expression) - Specified by:
- visitClosureExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitClosureExpressionin class- CodeVisitorSupport
 
 - 
visitMethodPointerExpressionpublic void visitMethodPointerExpression(MethodPointerExpression expression) - 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) 
 - 
shouldSkipMethodNodeprotected boolean shouldSkipMethodNode(MethodNode node) 
 - 
visitMethodpublic void visitMethod(MethodNode node) Description copied from interface:GroovyClassVisitorVisit a MethodNode.- Specified by:
- visitMethodin interface- GroovyClassVisitor
- Overrides:
- visitMethodin class- ClassCodeVisitorSupport
 
 - 
visitConstructorpublic void visitConstructor(ConstructorNode node) Description copied from interface:GroovyClassVisitorVisit a ConstructorNode.- Specified by:
- visitConstructorin interface- GroovyClassVisitor
- Overrides:
- visitConstructorin class- ClassCodeVisitorSupport
 
 - 
startMethodInferenceprotected void startMethodInference(MethodNode node, ErrorCollector collector) 
 - 
addTypeCheckingInfoAnnotationprotected void addTypeCheckingInfoAnnotation(MethodNode node) 
 - 
visitStaticMethodCallExpressionpublic void visitStaticMethodCallExpression(StaticMethodCallExpression call) - Specified by:
- visitStaticMethodCallExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitStaticMethodCallExpressionin class- CodeVisitorSupport
 
 - 
checkClosureParameters@Deprecated protected void checkClosureParameters(Expression callArguments, ClassNode receiver) Deprecated.this method is unused, replaced withDelegatesToinference.
 - 
silentlyVisitMethodNodeprotected void silentlyVisitMethodNode(MethodNode directMethodCallCandidate) Visits 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 visitClosures, MethodNode selectedMethod) 
 - 
inferClosureParameterTypesprotected void inferClosureParameterTypes(ClassNode receiver, Expression arguments, ClosureExpression expression, Parameter param, MethodNode selectedMethod) This method is responsible for performing 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 thecollectmethod has itsClosureargument annotated withClosureParams. If yes, then additional type inference can be performed and the type ofitmay be inferred.- Parameters:
- receiver-
- arguments-
- expression- a closure expression for which the argument types should be inferred
- param- the parameter where to look for a- ClosureParamsannotation.
- selectedMethod- the method accepting a closure
 
 - 
addReceiversprotected void addReceivers(List<Receiver<String>> receivers, Collection<Receiver<String>> owners, boolean implicitThis) 
 - 
visitMethodCallExpressionpublic void visitMethodCallExpression(MethodCallExpression call) - Specified by:
- visitMethodCallExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitMethodCallExpressionin class- CodeVisitorSupport
 
 - 
getInferredReturnTypeFromWithClosureArgumentprotected ClassNode getInferredReturnTypeFromWithClosureArgument(Expression callArguments) In 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, ie. a single closure expression
- Returns:
- the inferred closure return type or null
 
 - 
makeOwnerListprotected List<Receiver<String>> makeOwnerList(Expression objectExpression) Given an object expression (a receiver expression), generate the list of potential receiver types.- Parameters:
- objectExpression- the receiver expression
- Returns:
- the list of types the receiver may be
 
 - 
checkForbiddenSpreadArgumentprotected void checkForbiddenSpreadArgument(ArgumentListExpression argumentList) 
 - 
getTemporaryTypesForExpressionprotected List<ClassNode> getTemporaryTypesForExpression(Expression objectExpression) 
 - 
storeTargetMethodprotected void storeTargetMethod(Expression call, MethodNode directMethodCallCandidate) 
 - 
isClosureCallprotected boolean isClosureCall(String name, Expression objectExpression, Expression arguments) 
 - 
typeCheckClosureCallprotected void typeCheckClosureCall(Expression callArguments, ClassNode[] args, Parameter[] parameters) 
 - 
visitIfElsepublic void visitIfElse(IfStatement ifElse) - Specified by:
- visitIfElsein interface- GroovyCodeVisitor
- Overrides:
- visitIfElsein class- ClassCodeVisitorSupport
 
 - 
visitInstanceofNotprotected void visitInstanceofNot(BinaryExpression be) 
 - 
visitBlockStatementpublic void visitBlockStatement(BlockStatement block) - Specified by:
- visitBlockStatementin interface- GroovyCodeVisitor
- Overrides:
- visitBlockStatementin class- ClassCodeVisitorSupport
 
 - 
visitClosingBlockpublic void visitClosingBlock(BlockStatement block) 
 - 
findInstanceOfNotReturnExpressionprotected BinaryExpression findInstanceOfNotReturnExpression(IfStatement ifElse) Check IfStatement matched pattern : Object var1; if (!(var1 instanceOf Runnable)) { return } // Here var1 instance of RunnableReturn expression , which contains instanceOf (without not) Return null, if not found 
 - 
findNotInstanceOfReturnExpressionprotected BinaryExpression findNotInstanceOfReturnExpression(IfStatement ifElse) Check IfStatement matched pattern : Object var1; if (var1 !instanceOf Runnable) { return } // Here var1 instance of RunnableReturn expression , which contains instanceOf (without not) Return null, if not found 
 - 
visitSwitchpublic void visitSwitch(SwitchStatement statement) - Specified by:
- visitSwitchin interface- GroovyCodeVisitor
- Overrides:
- visitSwitchin class- ClassCodeVisitorSupport
 
 - 
afterSwitchConditionExpressionVisitedprotected void afterSwitchConditionExpressionVisited(SwitchStatement statement) - Overrides:
- afterSwitchConditionExpressionVisitedin class- CodeVisitorSupport
 
 - 
visitCaseStatementpublic void visitCaseStatement(CaseStatement statement) - Specified by:
- visitCaseStatementin interface- GroovyCodeVisitor
- Overrides:
- visitCaseStatementin class- ClassCodeVisitorSupport
 
 - 
popAssignmentTrackingprotected Map<VariableExpression,ClassNode> popAssignmentTracking(Map<VariableExpression,List<ClassNode>> oldTracker) 
 - 
pushAssignmentTrackingprotected Map<VariableExpression,List<ClassNode>> pushAssignmentTracking() 
 - 
visitArrayExpressionpublic void visitArrayExpression(ArrayExpression expression) - Specified by:
- visitArrayExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitArrayExpressionin class- CodeVisitorSupport
 
 - 
visitCastExpressionpublic void visitCastExpression(CastExpression expression) - Specified by:
- visitCastExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitCastExpressionin class- CodeVisitorSupport
 
 - 
checkCastprotected boolean checkCast(ClassNode targetType, Expression source) 
 - 
visitTernaryExpressionpublic void visitTernaryExpression(TernaryExpression expression) - Specified by:
- visitTernaryExpressionin interface- GroovyCodeVisitor
- Overrides:
- visitTernaryExpressionin class- CodeVisitorSupport
 
 - 
visitTryCatchFinallypublic void visitTryCatchFinally(TryCatchStatement statement) - Specified by:
- visitTryCatchFinallyin interface- GroovyCodeVisitor
- Overrides:
- visitTryCatchFinallyin class- ClassCodeVisitorSupport
 
 - 
storeTypeprotected void storeType(Expression exp, ClassNode cn) 
 - 
getResultTypeprotected ClassNode getResultType(ClassNode left, int op, ClassNode right, BinaryExpression expr) 
 - 
getGroupOperationResultTypeprotected static ClassNode getGroupOperationResultType(ClassNode a, ClassNode b) 
 - 
inferComponentTypeprotected ClassNode inferComponentType(ClassNode containerType, ClassNode indexType) 
 - 
findMethodOrFailprotected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode... args) 
 - 
prettyPrintMethodListprotected static String prettyPrintMethodList(List<MethodNode> nodes) 
 - 
areCategoryMethodCallsprotected boolean areCategoryMethodCalls(List<MethodNode> foundMethods, String name, ClassNode[] args) 
 - 
findMethodsWithGeneratedprotected 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 isn't compiled yet.- Parameters:
- receiver- the receiver where to find methods
- name- the name of the methods to return
- Returns:
- the methods that are defined on the receiver completed with stubs for future methods
 
 - 
findMethodprotected List<MethodNode> findMethod(ClassNode receiver, String name, ClassNode... args) 
 - 
extractPropertyNameFromMethodNamepublic static String extractPropertyNameFromMethodName(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. 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
 
 - 
collectAllInterfaceMethodsByNameprotected void collectAllInterfaceMethodsByName(ClassNode type, String name, List<MethodNode> methods) 
 - 
storeInferredReturnTypeprotected ClassNode storeInferredReturnType(ASTNode node, ClassNode type) Stores the inferred return type of a closure or a 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 a- MethodNode
- type- the inferred return type of the code
- Returns:
- the old value of the inferred type
 
 - 
getInferredReturnTypeprotected ClassNode getInferredReturnType(ASTNode exp) Returns the inferred return type of a closure or a method, if stored on the AST node. This method doesn't perform any type inference by itself.- Parameters:
- exp- a- ClosureExpressionor- MethodNode
- Returns:
- the inferred type, as stored on node metadata.
 
 - 
inferListExpressionTypeprotected ClassNode inferListExpressionType(ListExpression list) 
 - 
isNullConstantprotected static boolean isNullConstant(Expression expression) 
 - 
isThisExpressionprotected static boolean isThisExpression(Expression expression) 
 - 
isSuperExpressionprotected static boolean isSuperExpression(Expression expression) 
 - 
inferMapExpressionTypeprotected ClassNode inferMapExpressionType(MapExpression map) 
 - 
inferReturnTypeGenericsprotected ClassNode inferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments) If a method call returns a parameterized type, then we can perform additional inference on the return type, so that the type gets actual type parameters. For example, the method Arrays.asList(T...) is generified with type T which can be deduced from actual type arguments.- Parameters:
- method- the method node
- arguments- the method call arguments
- Returns:
- parameterized, infered, class node
 
 - 
inferReturnTypeGenericsprotected ClassNode inferReturnTypeGenerics(ClassNode receiver, MethodNode method, Expression arguments, GenericsType[] explicitTypeHints) If a method call returns a parameterized type, then we can perform additional inference on the return type, so that the type gets actual type parameters. For example, the method Arrays.asList(T...) is generified with type T which can be deduced from actual type arguments.- Parameters:
- method- the method node
- arguments- the method call arguments
- explicitTypeHints- explicit type hints as found for example in Collections.<String>emptyList()
- Returns:
- parameterized, infered, class node
 
 - 
typeCheckMethodsWithGenericsOrFailprotected boolean typeCheckMethodsWithGenericsOrFail(ClassNode receiver, ClassNode[] arguments, MethodNode candidateMethod, Expression location) 
 - 
addErrorpublic void addError(String msg, ASTNode expr) - Specified by:
- addErrorin interface- ErrorCollecting
- Overrides:
- addErrorin class- ClassCodeVisitorSupport
 
 - 
addNoMatchingMethodErrorprotected void addNoMatchingMethodError(ClassNode receiver, String name, ClassNode[] args, Expression call) 
 - 
addAmbiguousErrorMessageprotected void addAmbiguousErrorMessage(List<MethodNode> foundMethods, String name, ClassNode[] args, Expression expr) 
 - 
addCategoryMethodCallErrorprotected void addCategoryMethodCallError(Expression call) 
 - 
addAssignmentErrorprotected void addAssignmentError(ClassNode leftType, ClassNode rightType, Expression assignmentExpression) 
 - 
addUnsupportedPreOrPostfixExpressionErrorprotected void addUnsupportedPreOrPostfixExpressionError(Expression expression) 
 - 
setMethodsToBeVisitedpublic void setMethodsToBeVisited(Set<MethodNode> methodsToBeVisited) 
 - 
performSecondPasspublic void performSecondPass() 
 - 
extractTypesFromParametersprotected static ClassNode[] extractTypesFromParameters(Parameter[] parameters) 
 - 
wrapTypeIfNecessaryprotected static ClassNode wrapTypeIfNecessary(ClassNode type) Returns 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
 
 
- 
 
-