Class IteratedCollectionElement
o in for (Object o: list) { }.
An IteratedCollectionElement is identified by its tree, compared by reference. Each
loop has its own tree, so two loops have different elements even if their code is identical.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal NodeThe CFG node for this collection element, such as theLocalVariableNodeforoinfor (Object o : list), or theMethodInvocationNodeforlist.get(i)infor (int i = 0; i < list.size(); i++) { list.get(i).close(); }.final JavaExpressionThe expression that refers to this collection element in the loop body, such as the local variableoor the method calllist.get(i).final TreeThe AST tree for this collection element: the tree ofnode, such as the declarationObject oinfor (Object o : list), or the invocationlist.get(i)in an indexed loop.Fields inherited from class org.checkerframework.dataflow.expression.JavaExpression
type -
Constructor Summary
ConstructorsConstructorDescriptionIteratedCollectionElement(Node node, Tree tree) Creates a new IteratedCollectionElement. -
Method Summary
Modifier and TypeMethodDescription<R,P> R accept(JavaExpressionVisitor<R, P> visitor, P p) Accept method of the visitor pattern.<T extends JavaExpression>
@Nullable TcontainedOfClass(Class<T> clazz) Returns the first subexpression whose class is the given class, or null.booleanReturns true if and only if this contains a JavaExpression that is syntactically equal toother.booleaninthashCode()booleanReturns true if some subexpression of this can be assigned to from outside the current method body.booleanisDenotedBy(Node n) Returns true if the given node denotes this collection element: its tree is this element's tree, or its expression equals this element'sreference.booleanisDeterministic(AnnotationProvider provider) Returns true if the expression is deterministic.booleanReturns true if the abstract value of this expression can be changed by a method call; equivalently, if the abstract value can be changed by a side effect from outside the containing method.booleanReturns true if and only if the two Java expressions are syntactically identical.toString()Methods inherited from class org.checkerframework.dataflow.expression.JavaExpression
atConstructorInvocation, atFieldAccess, atMethodBody, atMethodInvocation, atMethodInvocation, containedUnknown, containsAsReceiver, containsModifiableAliasOf, containsOfClass, containsUnknown, fromArrayAccess, fromNode, fromNodeFieldAccess, fromTree, fromVariableTree, getFormalParameters, getImplicitReceiver, getParametersAsLocalVariables, getPseudoReceiver, getReceiver, getType, listContainsSyntacticEqualJavaExpression, listIsDeterministic, superToThis, syntacticEqualsList, toStringAsPostfixOperand, toStringDebug
-
Field Details
-
node
The CFG node for this collection element, such as theLocalVariableNodeforoinfor (Object o : list), or theMethodInvocationNodeforlist.get(i)infor (int i = 0; i < list.size(); i++) { list.get(i).close(); }. -
tree
The AST tree for this collection element: the tree ofnode, such as the declarationObject oinfor (Object o : list), or the invocationlist.get(i)in an indexed loop. -
reference
The expression that refers to this collection element in the loop body, such as the local variableoor the method calllist.get(i).
-
-
Constructor Details
-
IteratedCollectionElement
Creates a new IteratedCollectionElement.- Parameters:
node- the CFG node for a collection element, such as theLocalVariableNodeforoinfor (Object o : list)tree- the tree ofnode, such as the declarationObject o
-
-
Method Details
-
isDenotedBy
Returns true if the given node denotes this collection element: its tree is this element's tree, or its expression equals this element'sreference. That reference is the local variable that this element's tree declares, such asoino.close()in the body offor (Object o : list), or a method call such aslist.get(i)inlist.get(i).close()in the body offor (int i = 0; i < list.size(); i++).This method is unsound for a reference that is a nondeterministic method call, such as
it.next()in a while loop over an iteratorit. It returns true for every callit.next()in the loop body, but each such call yields a different collection element.- Parameters:
n- a CFG node- Returns:
- true if
ndenotes this collection element
-
equals
-
hashCode
public int hashCode() -
containedOfClass
Description copied from class:JavaExpressionReturns the first subexpression whose class is the given class, or null.This is intended as a diagnostic aid; most clients will use
JavaExpression.containsOfClass(java.lang.Class<? extends org.checkerframework.dataflow.expression.JavaExpression>).- Specified by:
containedOfClassin classJavaExpression- Type Parameters:
T- the type corresponding toclazz- Parameters:
clazz- the JavaExpression subclass to search for- Returns:
- the first subexpression whose class is the given class, or null
-
toString
-
isDeterministic
Description copied from class:JavaExpressionReturns true if the expression is deterministic.- Specified by:
isDeterministicin classJavaExpression- Parameters:
provider- an annotation provider (a type factory)- Returns:
- true if this expression is deterministic
-
syntacticEquals
Description copied from class:JavaExpressionReturns true if and only if the two Java expressions are syntactically identical.This is a stricter test than
Object.equals(java.lang.Object), which accommodates commutativity of operations.- Specified by:
syntacticEqualsin classJavaExpression- Parameters:
je- the other Java expression to compare to this one- Returns:
- true if and only if the two Java expressions are syntactically identical
-
containsSyntacticEqualJavaExpression
Description copied from class:JavaExpressionReturns true if and only if this contains a JavaExpression that is syntactically equal toother.- Specified by:
containsSyntacticEqualJavaExpressionin classJavaExpression- Parameters:
other- the JavaExpression to search for- Returns:
- true if and only if this contains a JavaExpression that is syntactically equal to
other
-
isAssignableByOtherCode
public boolean isAssignableByOtherCode()Description copied from class:JavaExpressionReturns true if some subexpression of this can be assigned to from outside the current method body.This is false for local variables, the self reference, final field accesses whose receiver is not
JavaExpression.isAssignableByOtherCode(), and operations whose operands are all notJavaExpression.isModifiableByOtherCode().- Specified by:
isAssignableByOtherCodein classJavaExpression- Returns:
- true if some subexpression of this can be assigned to from outside the current method body
- See Also:
-
isModifiableByOtherCode
public boolean isModifiableByOtherCode()Description copied from class:JavaExpressionReturns true if the abstract value of this expression can be changed by a method call; equivalently, if the abstract value can be changed by a side effect from outside the containing method.Approximately, this returns true if the expression is
JavaExpression.isAssignableByOtherCode()or its type is mutable. (Stringis an immutable type.)- Specified by:
isModifiableByOtherCodein classJavaExpression- Returns:
- true if the value of this expression can be changed from outside the current method body
- See Also:
-
accept
Description copied from class:JavaExpressionAccept method of the visitor pattern.- Specified by:
acceptin classJavaExpression- Type Parameters:
R- result type of the operationP- parameter type- Parameters:
visitor- the visitor to be applied to this JavaExpressionp- the parameter for this operation- Returns:
- the result of visiting this
-