Class CaseNode

  • All Implemented Interfaces:
    org.plumelib.util.UniqueId

    public class CaseNode
    extends Node
    A node for a case in a switch statement. Although a case has no abstract value, it can imply facts about the abstract values of its operands.
       case constant:
     
    • Field Detail

      • tree

        protected final com.sun.source.tree.CaseTree tree
        The tree for this node.
      • selectorExprAssignment

        protected final AssignmentNode selectorExprAssignment
        The Node for the assignment of the switch selector expression to a synthetic local variable.
      • caseExprs

        protected final java.util.List<Node> caseExprs
        The case expressions to match the switch expression against: the operands of (possibly multiple) case labels.
      • guard

        protected final @Nullable Node guard
        The guard (the expression in the when clause) for this case.
    • Constructor Detail

      • CaseNode

        public CaseNode​(com.sun.source.tree.CaseTree tree,
                        AssignmentNode selectorExprAssignment,
                        java.util.List<Node> caseExprs,
                        @Nullable Node guard,
                        javax.lang.model.util.Types types)
        Create a new CaseNode.
        Parameters:
        tree - the tree for this node
        selectorExprAssignment - the Node for the assignment of the switch selector expression to a synthetic local variable
        caseExprs - the case expression(s) to match the switch expression against
        guard - the guard expression or null
        types - a factory of utility methods for operating on types
    • Method Detail

      • getSwitchOperand

        public AssignmentNode getSwitchOperand()
        The Node for the assignment of the switch selector expression to a synthetic local variable. This is used to refine the type of the switch selector expression in a case block.
        Returns:
        the assignment of the switch selector expression to a synthetic local variable
      • getCaseOperands

        public java.util.List<Node> getCaseOperands()
        Gets the nodes corresponding to the case expressions. There can be multiple expressions since Java 12.
        Returns:
        the nodes corresponding to the (potentially multiple) case expressions
      • getGuard

        public @Nullable Node getGuard()
        Gets the node for the guard (the expression in the when clause).
        Returns:
        the node for the guard
      • getTree

        public com.sun.source.tree.CaseTree 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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(@Nullable java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getOperands

        @SideEffectFree
        public java.util.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