Package org.jruby.ast
Class HashNode
java.lang.Object
org.jruby.ast.Node
org.jruby.ast.HashNode
- All Implemented Interfaces:
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate final List<KeyValuePair<Node,Node>> Fields inherited from class org.jruby.ast.Node
containsVariableAssignment, EMPTY_LIST, newline -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(NodeVisitor<T> iVisitor) Accept for the visitor pattern.add(KeyValuePair<Node, Node> pair) getPairs()booleanDetect whether only rest kwargs make up this hash.booleanbooleanDetect presence of a rest kwarg (**kw).booleanisEmpty()booleanIs this hash looking like a keyword argument hash? Technically we do not know at the callsiteMethods inherited from class org.jruby.ast.Node
containsVariableAssignment, createList, createList, createList, createList, executesOnce, findFirstChild, getFile, getLine, getNodeName, isNewline, isNil, needsDefinitionCheck, setLine, setNewline, toString, toString, toStringExtraInfo, toStringInternal, unsetNewline
-
Field Details
-
pairs
-
hasOnlySymbolKeys
private boolean hasOnlySymbolKeys -
hasRestKwarg
private boolean hasRestKwarg
-
-
Constructor Details
-
HashNode
public HashNode(int line) -
HashNode
-
-
Method Details
-
hasOnlySymbolKeys
public boolean hasOnlySymbolKeys()- Returns:
- true if all elements of this hash uses symbol keys (might end up representing a kwarg).
-
isMaybeKwargs
public boolean isMaybeKwargs()Is this hash looking like a keyword argument hash? Technically we do not know at the callsite- Returns:
- true is it looks like one.
-
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
- Specified by:
getNodeTypein classNode- Returns:
- the nodeId
-
add
-
accept
Accept for the visitor pattern. -
isEmpty
public boolean isEmpty() -
getPairs
-
childNodes
- Specified by:
childNodesin classNode
-