Class ObjectCreationNode
- java.lang.Object
-
- org.checkerframework.dataflow.cfg.node.Node
-
- org.checkerframework.dataflow.cfg.node.ObjectCreationNode
-
- All Implemented Interfaces:
org.plumelib.util.UniqueId
public class ObjectCreationNode extends Node
A node for a new object creation.new typeToInstantiate(arg1, arg2, ...) enclosingExpression.new typeToInstantiate(arg1, arg2, ...) enclosingExpression.new <Ts>typeToInstantiate(arg1, arg2, ...)
We use the term "typeToInstantiate" to represent what is called the "identifier" in
NewClassTree
and what is called "ClassOrInterfaceTypeToInstantiate" in the "ClassInstanceCreationExpression" in the JLS. The former term "identifier" is misleading, as this can be a type with type arguments. The latter term "ClassOrInterfaceTypeToInstantiate" is rather long and we shortened it to "typeToInstantiate".Class type arguments can be accessed through the "typeToInstantiate" node. To access constructor type arguments one needs to use the
NewClassTree
.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Node>
arguments
The arguments of the object creation.protected @Nullable ClassDeclarationNode
classbody
Class body for anonymous classes, otherwise null.protected @Nullable Node
enclosingExpression
The enclosing expression of the object creation or null.protected com.sun.source.tree.NewClassTree
tree
The tree for the object creation.protected Node
typeToInstantiate
The type to instantiate node of the object creation.
-
Constructor Summary
Constructors Constructor Description ObjectCreationNode(com.sun.source.tree.NewClassTree tree, @Nullable Node enclosingExpr, Node typeToInstantiate, java.util.List<Node> arguments, @Nullable ClassDeclarationNode classbody)
Constructs aObjectCreationNode
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <R,P>
Raccept(NodeVisitor<R,P> visitor, P p)
Accept method of the visitor pattern.boolean
equals(@Nullable java.lang.Object obj)
Node
getArgument(int i)
Returns the i-th explicit argument to the object creation.java.util.List<Node>
getArguments()
Returns the explicit arguments to the object creation.@Nullable Node
getClassBody()
Returns the classbody.Node
getConstructor()
Deprecated.@Nullable Node
getEnclosingExpression()
Returns the enclosing expression node, which only exists if it is an inner class instantiation.java.util.Collection<Node>
getOperands()
com.sun.source.tree.NewClassTree
getTree()
Returns theTree
in the abstract syntax tree, ornull
if no corresponding tree exists.Node
getTypeToInstantiate()
Returns the typeToInstantiate node.int
hashCode()
java.lang.String
toString()
-
Methods inherited from class org.checkerframework.dataflow.cfg.node.Node
getBlock, getInSource, getTransitiveOperands, getType, getUid, isLValue, nodeCollectionToString, setBlock, setInSource, setLValue, toStringDebug
-
-
-
-
Field Detail
-
tree
protected final com.sun.source.tree.NewClassTree tree
The tree for the object creation.
-
enclosingExpression
protected final @Nullable Node enclosingExpression
The enclosing expression of the object creation or null.
-
typeToInstantiate
protected final Node typeToInstantiate
The type to instantiate node of the object creation. A non-generic typeToInstantiate node will refer to aClassNameNode
, while a generic typeToInstantiate node will refer to aParameterizedTypeNode
.
-
arguments
protected final java.util.List<Node> arguments
The arguments of the object creation.
-
classbody
protected final @Nullable ClassDeclarationNode classbody
Class body for anonymous classes, otherwise null.
-
-
Constructor Detail
-
ObjectCreationNode
public ObjectCreationNode(com.sun.source.tree.NewClassTree tree, @Nullable Node enclosingExpr, Node typeToInstantiate, java.util.List<Node> arguments, @Nullable ClassDeclarationNode classbody)
Constructs aObjectCreationNode
.- Parameters:
tree
- the NewClassTreeenclosingExpr
- the enclosing expression Node if it exists, or nulltypeToInstantiate
- the typeToInstantiate nodearguments
- the passed argumentsclassbody
- the ClassDeclarationNode
-
-
Method Detail
-
getConstructor
@Pure @Deprecated public Node getConstructor()
Deprecated.Returns the constructor node.- Returns:
- the constructor node
-
getTypeToInstantiate
@Pure public Node getTypeToInstantiate()
Returns the typeToInstantiate node. A non-generic typeToInstantiate node can refer to aClassNameNode
, while a generic typeToInstantiate node can refer to aParameterizedTypeNode
.- Returns:
- the typeToInstantiate node
-
getArguments
@Pure public java.util.List<Node> getArguments()
Returns the explicit arguments to the object creation.- Returns:
- the arguments
-
getArgument
@Pure public Node getArgument(int i)
Returns the i-th explicit argument to the object creation.- Parameters:
i
- the index of the argument- Returns:
- the argument
-
getEnclosingExpression
@Pure public @Nullable Node getEnclosingExpression()
Returns the enclosing expression node, which only exists if it is an inner class instantiation.- Returns:
- the enclosing type expression node
-
getClassBody
@Pure public @Nullable Node getClassBody()
Returns the classbody.- Returns:
- the classbody
-
getTree
@Pure public com.sun.source.tree.NewClassTree getTree()
Description copied from class:Node
Returns theTree
in the abstract syntax tree, ornull
if no corresponding tree exists. For instance, this is the case for anImplicitThisNode
.
-
accept
public <R,P> R accept(NodeVisitor<R,P> visitor, P p)
Description copied from class:Node
Accept method of the visitor pattern.
-
toString
@SideEffectFree public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
@Pure public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
@SideEffectFree public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getOperands
@SideEffectFree public java.util.Collection<Node> getOperands()
Description copied from class:Node
- Specified by:
getOperands
in classNode
- Returns:
- a collection containing all of the operand
Node
s of thisNode
-
-