Class TypeCheckingContext
java.lang.Object
org.codehaus.groovy.transform.stc.TypeCheckingContext
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents the context of an enclosing closure. -
Field Summary
Modifier and TypeFieldDescriptionprotected Set<MethodNode>
protected final Map<VariableExpression,
List<ClassNode>> A map used to store every type used in closure shared variable assignments.protected CompilationUnit
protected org.codehaus.groovy.transform.stc.DelegationMetadata
protected final LinkedList<BinaryExpression>
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 boolean
protected ClassNode
The type of the last encountered "it" implicit parameterprotected 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 SourceUnit
Stores information which is only valid in the "if" branch of an if-then-else statement.protected final StaticTypeCheckingVisitor
-
Constructor Summary
-
Method Summary
Modifier 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 classes.Returns the current stack of enclosing methods.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.void
void
pushEnclosingBinaryExpression
(BinaryExpression binaryExpression) Pushes a binary expression into the binary expression stack.void
pushEnclosingClassNode
(ClassNode classNode) Pushes a class into the classes stack.void
pushEnclosingClosureExpression
(ClosureExpression closureExpression) Pushes a closure expression into the closure expression stack.void
pushEnclosingMethod
(MethodNode methodNode) Pushes a method into the method stack.void
Pushes a method call into the method call stack.void
pushErrorCollector
(ErrorCollector collector) void
void
setCompilationUnit
(CompilationUnit compilationUnit)
-
Field Details
-
source
-
methodsToBeVisited
-
isInStaticContext
protected boolean isInStaticContext -
errorCollectors
-
enclosingClassNodes
-
enclosingMethods
-
enclosingMethodCalls
-
enclosingClosures
-
delegationMetadata
protected org.codehaus.groovy.transform.stc.DelegationMetadata delegationMetadata -
lastImplicitItType
The type of the last encountered "it" implicit parameter -
ifElseForWhileAssignmentTracker
This 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, String) -
temporaryIfBranchTypeInformation
Stores 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 -
alreadyVisitedMethods
-
secondPassExpressions
protected 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
-
enclosingBinaryExpressions
-
visitor
-
compilationUnit
-
-
Constructor Details
-
TypeCheckingContext
-
-
Method Details
-
pushEnclosingBinaryExpression
Pushes a binary expression into the binary expression stack.- Parameters:
binaryExpression
- the binary expression to be pushed
-
popEnclosingBinaryExpression
Pops a binary expression from the binary expression stack.- Returns:
- the popped binary expression
-
getEnclosingBinaryExpression
Returns the binary expression which is on the top of the stack, or null if there's no such element.- Returns:
- the binary expression on top of the stack, or null if no such element.
-
getEnclosingBinaryExpressionStack
Returns the current stack of enclosing binary expressions. The first element is the top of the stack.- Returns:
- an immutable list of binary expressions.
-
pushEnclosingClosureExpression
Pushes a closure expression into the closure expression stack.- Parameters:
closureExpression
- the closure expression to be pushed
-
popEnclosingClosure
Pops a closure expression from the closure expression stack.- Returns:
- the popped closure expression
-
getEnclosingClosure
Returns the closure expression which is on the top of the stack, or null if there's no such element.- Returns:
- the closure expression on top of the stack, or null if no such element.
-
getEnclosingClosureStack
Returns the current stack of enclosing closure expressions. The first element is the top of the stack.- Returns:
- an immutable list of closure expressions.
-
pushEnclosingMethod
Pushes a method into the method stack.- Parameters:
methodNode
- the method to be pushed
-
popEnclosingMethod
Pops a method from the enclosing methods stack.- Returns:
- the popped method
-
getEnclosingMethod
Returns the method node which is on the top of the stack, or null if there's no such element.- Returns:
- the enclosing method on top of the stack, or null if no such element.
-
getEnclosingMethods
Returns the current stack of enclosing methods. The first element is the top of the stack, that is to say the last visited method.- Returns:
- an immutable list of method nodes.
-
pushEnclosingClassNode
Pushes a class into the classes stack.- Parameters:
classNode
- the class to be pushed
-
popEnclosingClassNode
Pops a class from the enclosing classes stack.- Returns:
- the popped class
-
getEnclosingClassNode
Returns the class node which is on the top of the stack, or null if there's no such element.- Returns:
- the enclosing class on top of the stack, or null if no such element.
-
getEnclosingClassNodes
Returns the current stack of enclosing classes. The first element is the top of the stack, that is to say the currently visited class.- Returns:
- an immutable list of class nodes.
-
pushTemporaryTypeInfo
public void pushTemporaryTypeInfo() -
popTemporaryTypeInfo
public void popTemporaryTypeInfo() -
pushEnclosingMethodCall
Pushes a method call into the method call stack.- Parameters:
call
- the call expression to be pushed, either aMethodCallExpression
or aStaticMethodCallExpression
-
popEnclosingMethodCall
Pops a method call from the enclosing method call stack.- Returns:
- the popped call
-
getEnclosingMethodCall
Returns the method call which is on the top of the stack, or null if there's no such element.- Returns:
- the enclosing method call on top of the stack, or null if no such element.
-
getEnclosingMethodCalls
Returns the current stack of enclosing classes. The first element is the top of the stack, that is to say the currently visited class.- Returns:
- an immutable list of class nodes.
-
getErrorCollectors
-
getErrorCollector
-
pushErrorCollector
-
pushErrorCollector
-
popErrorCollector
-
getCompilationUnit
-
setCompilationUnit
-
getSource
-