Class TypeCheckingContext
java.lang.Object
org.codehaus.groovy.transform.stc.TypeCheckingContext
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classRepresents the context of an enclosing closure.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Set<MethodNode>protected final IdentityHashMap<BlockStatement,Map<VariableExpression, List<ClassNode>>> Deprecated.protected final Map<VariableExpression,List<ClassNode>> A map used to store every type used in closure shared variable assignments.protected CompilationUnitprotected org.codehaus.groovy.transform.stc.DelegationMetadataWhenever a method using a closure as argument (typically, "with") is detected, this list is updated with the receiver type of the with method.protected final LinkedList<BinaryExpression>protected final LinkedList<BlockStatement>Deprecated.protected final LinkedList<ClassNode>protected final LinkedList<TypeCheckingContext.EnclosingClosure>protected final LinkedList<Expression>protected final LinkedList<MethodNode>protected final LinkedList<ErrorCollector>protected Map<VariableExpression,List<ClassNode>> This field is used to track assignments in if/else branches, for loops and while loops.protected booleanprotected ClassNodeThe type of the last encountered "it" implicit parameter.protected Set<MethodNode>protected final LinkedHashSet<org.codehaus.groovy.transform.stc.SecondPassExpression>Some expressions need to be visited twice, because type information may be insufficient at some point.protected SourceUnitprotected final LinkedList<SwitchStatement>Stores information which is only valid in the "if" branch of an if-then-else statement.protected final StaticTypeCheckingVisitor
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionReturns the binary expression which is on the top of the stack, or null if there's no such element.Returns the current stack of enclosing binary expressions.Returns the class node which is on the top of the stack, or null if there's no such element.Returns the current stack of enclosing classes.Returns the closure expression which is on the top of the stack, or null if there's no such element.Returns the current stack of enclosing closure expressions.Returns the method node which is on the top of the stack, or null if there's no such element.Returns the method call which is on the top of the stack, or null if there's no such element.Returns the current stack of enclosing method calls.Returns the current stack of enclosing methods.Returns the switch statement which is on the top of the stack, or null if there's no such element.Returns the current stack of enclosing switch statements.booleanisTargetOfEnclosingAssignment(Expression expression) Pops a binary expression from the binary expression stack.Pops a class from the enclosing classes stack.Pops a closure expression from the closure expression stack.Pops a method from the enclosing methods stack.Pops a method call from the enclosing method call stack.Pops a switch statement from the enclosing switch statements stack.voidvoidpushEnclosingBinaryExpression(BinaryExpression binaryExpression) Pushes a binary expression into the binary expression stack.voidpushEnclosingClassNode(ClassNode classNode) Pushes a class into the classes stack.voidpushEnclosingClosureExpression(ClosureExpression closureExpression) Pushes a closure expression into the closure expression stack.voidpushEnclosingMethod(MethodNode methodNode) Pushes a method into the method stack.voidPushes a method call into the method call stack.voidpushEnclosingSwitchStatement(SwitchStatement switchStatement) Pushes a switch statement into the switch statement stack.voidpushErrorCollector(ErrorCollector collector) voidvoidsetCompilationUnit(CompilationUnit compilationUnit) 
- 
Field Details- 
visitor
- 
source
- 
compilationUnit
- 
errorCollectors
- 
temporaryIfBranchTypeInformationStores information which is only valid in the "if" branch of an if-then-else statement. This is used when the if condition expression makes use of an instanceof check
- 
delegationMetadataprotected org.codehaus.groovy.transform.stc.DelegationMetadata delegationMetadataWhenever a method using a closure as argument (typically, "with") is detected, this list is updated with the receiver type of the with method.
- 
isInStaticContextprotected boolean isInStaticContext
- 
lastImplicitItTypeThe type of the last encountered "it" implicit parameter.
- 
methodsToBeVisited
- 
ifElseForWhileAssignmentTrackerThis field is used to track assignments in if/else branches, for loops and while loops. For example, in the following code:if (cond) { x = 1 } else { x = '123' }the inferred type of x after the if/else statement should be the LUB of int and String.
- 
blockStatements2Types@Deprecated protected final IdentityHashMap<BlockStatement,Map<VariableExpression, blockStatements2TypesList<ClassNode>>> Deprecated.This field used for type derivation Check IfStatement matched pattern: Object var1; if (!(var1 instanceOf Runnable)){ return } // Here var1 instance of Runnable
- 
alreadyVisitedMethods
- 
secondPassExpressionsprotected final LinkedHashSet<org.codehaus.groovy.transform.stc.SecondPassExpression> secondPassExpressionsSome expressions need to be visited twice, because type information may be insufficient at some point. For example, for closure shared variables, we need a first pass to collect every type which is assigned to a closure shared variable, then a second pass to ensure that every method call on such a variable is made on a LUB.
- 
controlStructureVariables
- 
reportedErrors
- 
enclosingClassNodes
- 
enclosingMethods
- 
enclosingMethodCalls
- 
enclosingBlocksDeprecated.
- 
switchStatements
- 
enclosingClosures
- 
enclosingBinaryExpressions
 
- 
- 
Constructor Details- 
TypeCheckingContext
 
- 
- 
Method Details- 
getSource
- 
getCompilationUnit
- 
setCompilationUnit
- 
pushErrorCollector
- 
pushErrorCollector
- 
popErrorCollector
- 
getErrorCollector
- 
getErrorCollectors
- 
pushTemporaryTypeInfopublic void pushTemporaryTypeInfo()
- 
popTemporaryTypeInfopublic void popTemporaryTypeInfo()
- 
pushEnclosingBinaryExpressionPushes a binary expression into the binary expression stack.
- 
popEnclosingBinaryExpressionPops a binary expression from the binary expression stack.
- 
getEnclosingBinaryExpressionReturns the binary expression which is on the top of the stack, or null if there's no such element.
- 
getEnclosingBinaryExpressionStackReturns the current stack of enclosing binary expressions. The first element is the top of the stack.
- 
isTargetOfEnclosingAssignment
- 
pushEnclosingClosureExpressionPushes a closure expression into the closure expression stack.
- 
popEnclosingClosurePops a closure expression from the closure expression stack.
- 
getEnclosingClosureReturns the closure expression which is on the top of the stack, or null if there's no such element.
- 
getEnclosingClosureStackReturns the current stack of enclosing closure expressions. The first element is the top of the stack.
- 
pushEnclosingClassNodePushes a class into the classes stack.
- 
popEnclosingClassNodePops a class from the enclosing classes stack.
- 
getEnclosingClassNodeReturns the class node which is on the top of the stack, or null if there's no such element.
- 
getEnclosingClassNodesReturns the current stack of enclosing classes. The first element is the top of the stack, that is to say the currently visited class.
- 
pushEnclosingMethodPushes a method into the method stack.
- 
popEnclosingMethodPops a method from the enclosing methods stack.
- 
getEnclosingMethodReturns the method node which is on the top of the stack, or null if there's no such element.
- 
getEnclosingMethodsReturns the current stack of enclosing methods. The first element is the top of the stack, that is to say the last visited method.
- 
pushEnclosingMethodCallPushes a method call into the method call stack.- Parameters:
- call- the call expression to be pushed, either a- MethodCallExpressionor a- StaticMethodCallExpression
 
- 
popEnclosingMethodCallPops a method call from the enclosing method call stack.
- 
getEnclosingMethodCallReturns the method call which is on the top of the stack, or null if there's no such element.
- 
getEnclosingMethodCallsReturns the current stack of enclosing method calls. The first element is the top of the stack, that is to say the currently visited method call.
- 
pushEnclosingSwitchStatementPushes a switch statement into the switch statement stack.
- 
popEnclosingSwitchStatementPops a switch statement from the enclosing switch statements stack.
- 
getEnclosingSwitchStatementReturns the switch statement which is on the top of the stack, or null if there's no such element.
- 
getEnclosingSwitchStatementsReturns the current stack of enclosing switch statements. The first element is the top of the stack, that is to say the last visited switch statement.
 
-