Class NodeUtils
java.lang.Object
org.checkerframework.dataflow.util.NodeUtils
A utility class to operate on a given
Node
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isArrayLengthFieldAccess
(Node node) Returns true iffnode
is aFieldAccessNode
that is an access to an array's length.static boolean
isBooleanTypeNode
(Node node) Returns true iffnode
corresponds to a boolean typed expression (either the primitive typeboolean
, or class typeBoolean
).static boolean
isConstantBoolean
(Node n, boolean value) Returns true if the given node statically evaluates tovalue
and has no side effects.static boolean
isMethodInvocation
(Node node, List<ExecutableElement> methods, ProcessingEnvironment env) Returns true iffnode
is an invocation of one of the given methods.static boolean
isMethodInvocation
(Node node, ExecutableElement method, ProcessingEnvironment env) Returns true ifnode
is an invocation of the given method.static Node
removeCasts
(Node node) Remove anyTypeCastNode
s wrapping a node, returning the operand nested within the type casts.
-
Constructor Details
-
NodeUtils
public NodeUtils()
-
-
Method Details
-
isBooleanTypeNode
Returns true iffnode
corresponds to a boolean typed expression (either the primitive typeboolean
, or class typeBoolean
).- Returns:
- true iff
node
corresponds to a boolean typed expression (either the primitive typeboolean
, or class typeBoolean
)
-
isArrayLengthFieldAccess
Returns true iffnode
is aFieldAccessNode
that is an access to an array's length.- Returns:
- true iff
node
is aFieldAccessNode
that is an access to an array's length
-
isMethodInvocation
public static boolean isMethodInvocation(Node node, ExecutableElement method, ProcessingEnvironment env) Returns true ifnode
is an invocation of the given method.- Parameters:
node
- a node, not necessarily a method invocationmethod
- a methodenv
- a processing environment- Returns:
- true if
node
is an invocation of one of the given methods
-
isMethodInvocation
public static boolean isMethodInvocation(Node node, List<ExecutableElement> methods, ProcessingEnvironment env) Returns true iffnode
is an invocation of one of the given methods.- Parameters:
node
- a node, not necessarily a method invocationmethods
- a list of methodsenv
- a processing environment- Returns:
- true if
node
is an invocation of one of the given methods
-
isConstantBoolean
Returns true if the given node statically evaluates tovalue
and has no side effects.- Parameters:
n
- a nodevalue
- the boolean value that the node is tested against- Returns:
- true if the node is equivalent to a literal with value
value
-
removeCasts
Remove anyTypeCastNode
s wrapping a node, returning the operand nested within the type casts.- Parameters:
node
- a node- Returns:
- node, but with any surrounding typecasts removed
-