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 Details

    • tree

      protected final 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 a ClassNameNode, while a generic typeToInstantiate node will refer to a ParameterizedTypeNode.
    • arguments

      protected final List<Node> arguments
      The arguments of the object creation.
    • classbody

      protected final @Nullable ClassDeclarationNode classbody
      Class body for anonymous classes, otherwise null.
  • Constructor Details

    • ObjectCreationNode

      public ObjectCreationNode(NewClassTree tree, @Nullable Node enclosingExpr, Node typeToInstantiate, List<Node> arguments, @Nullable ClassDeclarationNode classbody)
      Constructs a ObjectCreationNode.
      Parameters:
      tree - the NewClassTree
      enclosingExpr - the enclosing expression Node if it exists, or null
      typeToInstantiate - the typeToInstantiate node
      arguments - the passed arguments
      classbody - the ClassDeclarationNode
  • Method Details

    • getConstructor

      @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 a ClassNameNode, while a generic typeToInstantiate node can refer to a ParameterizedTypeNode.
      Returns:
      the typeToInstantiate node
    • getArguments

      @Pure public 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 NewClassTree getTree()
      Description copied from class: Node
      Returns the Tree in the abstract syntax tree, or null if no corresponding tree exists. For instance, this is the case for an ImplicitThisNode.
      Specified by:
      getTree in class Node
      Returns:
      the corresponding Tree or null
    • accept

      public <R, P> R accept(NodeVisitor<R,P> visitor, P p)
      Description copied from class: Node
      Accept method of the visitor pattern.
      Specified by:
      accept in class Node
      Type Parameters:
      R - result type of the operation
      P - parameter type
      Parameters:
      visitor - the visitor to be applied to this node
      p - the parameter for this operation
    • toString

      @SideEffectFree public String toString()
      Overrides:
      toString in class Object
    • equals

      @Pure public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      @SideEffectFree public int hashCode()
      Overrides:
      hashCode in class Object
    • getOperands

      @SideEffectFree public Collection<Node> getOperands()
      Description copied from class: Node
      Returns a collection containing all of the operand Nodes of this Node.
      Specified by:
      getOperands in class Node
      Returns:
      a collection containing all of the operand Nodes of this Node