Package org.jruby.ast

Class HashNode

java.lang.Object
org.jruby.ast.Node
org.jruby.ast.HashNode
All Implemented Interfaces:
ILiteralNode

public class HashNode extends Node implements ILiteralNode
A Literal Hash that can represent either a {a=&b, c=&d} type expression or the list of default values or kwarg in a method call.
  • Constructor Details

    • HashNode

      public HashNode(int line)
    • HashNode

      public HashNode(int line, KeyValuePair<Node,Node> pair)
  • Method Details

    • setIsLiteral

      public void setIsLiteral()
    • isLiteral

      public boolean isLiteral()
    • hasRestKwarg

      public boolean hasRestKwarg()
      Detect presence of a rest kwarg (**kw).
      Returns:
      true if it contains at least one rest kwarg.
    • hasOnlyRestKwargs

      public boolean hasOnlyRestKwargs()
      Detect whether only rest kwargs make up this hash. Common case is **a which is HashNode{[(null, a)]}. Less common is **a, **b which is HashNode{[(null, a), (null, b)].}
      Returns:
      true is only rest kwargs
    • getNodeType

      public NodeType getNodeType()
      Specified by:
      getNodeType in class Node
      Returns:
      the nodeId
    • add

      public HashNode add(KeyValuePair<Node,Node> pair)
    • removeAll

      public boolean removeAll(Collection<KeyValuePair<Node,Node>> pairsToRemove)
    • accept

      public <T> T accept(NodeVisitor<T> iVisitor)
      Accept for the visitor pattern.
      Specified by:
      accept in class Node
      Parameters:
      iVisitor - the visitor
    • isEmpty

      public boolean isEmpty()
    • getPairs

      public List<KeyValuePair<Node,Node>> getPairs()
    • childNodes

      public List<Node> childNodes()
      Specified by:
      childNodes in class Node
    • toStringExtraInfo

      public String toStringExtraInfo()
      Description copied from class: Node
      Not all interesting info in the AST is from Node data. This method will print out anything else of note (e.g. FixnumNode's long value).
      Overrides:
      toStringExtraInfo in class Node
      Returns:
      null for no extra info or something otherwise.
    • hasOnlySymbolKeys

      public boolean hasOnlySymbolKeys()
    • isMaybeKwargs

      @Deprecated public boolean isMaybeKwargs()
      Deprecated.
    • getKeys

      public Node[] getKeys()