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
NewClassTreeand 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>argumentsThe arguments of the object creation.protected @Nullable ClassDeclarationNodeclassbodyClass body for anonymous classes, otherwise null.protected @Nullable NodeenclosingExpressionThe enclosing expression of the object creation or null.protected com.sun.source.tree.NewClassTreetreeThe tree for the object creation.protected NodetypeToInstantiateThe 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.booleanequals(@Nullable java.lang.Object obj)NodegetArgument(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 NodegetClassBody()Returns the classbody.NodegetConstructor()Deprecated.@Nullable NodegetEnclosingExpression()Returns the enclosing expression node, which only exists if it is an inner class instantiation.java.util.Collection<Node>getOperands()com.sun.source.tree.NewClassTreegetTree()Returns theTreein the abstract syntax tree, ornullif no corresponding tree exists.NodegetTypeToInstantiate()Returns the typeToInstantiate node.inthashCode()java.lang.StringtoString()-
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:NodeReturns theTreein the abstract syntax tree, ornullif 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:NodeAccept method of the visitor pattern.
-
toString
@SideEffectFree public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
@Pure public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
@SideEffectFree public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getOperands
@SideEffectFree public java.util.Collection<Node> getOperands()
Description copied from class:Node- Specified by:
getOperandsin classNode- Returns:
- a collection containing all of the operand
Nodes of thisNode
-
-