Top Description Fields Constructors Methods
org.jruby.ast

public Class ListNode

extends Node
implements Iterable<Node>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Known Direct Subclasses
org.jruby.ast.ZArrayNode, org.jruby.ast.ArrayNode, org.jruby.ast.BlockNode, org.jruby.ast.DNode
Imports
java.util.Arrays, .Collections, .Iterator, .List, org.jruby.ast.visitor.NodeVisitor

All Nodes which have a list representation inherit this. This is also used as generic container for additional information that is not directly evaluated. In particular, f_arg production rule uses this to capture arg information for the editor projects who want position info saved.

Field Summary

Modifier and TypeField and Description
private static final Node[]
private static final int
private Node[]
private Node
single

This is used to reduce the need to allocate an array for the many single-element ListNode instances in a typical Ruby app.

private int
Inherited from org.jruby.ast.Node:
containsVariableAssignmentEMPTY_LISTnewline

Constructor Summary

AccessConstructor and Description
public
ListNode(int
where list is
line
,
Node
first element of the list
firstNode
)

Create a new ListNode.

public
ListNode(int line)

Method Summary

Modifier and TypeMethod and Description
public <T> T
accept(NodeVisitor<T> visitor)

Implements abstract org.jruby.ast.Node.accept.

public ListNode
add(Node node)

public ListNode

Returns:

this instance for method chaining
addAll
(ListNode
list which has elements
other
)

Add all elements in other list to this list node.

public ListNode
addAll(Node[] other, int index, int length)

public ListNode

Returns:

this instance for method chaining
addAll
(Node
list which has elements
other
)

Add other element to this list

protected void
protected void
private void
addToSingle(Node single, Node node)

private Node[]
public List<Node>
childNodes()

Implements abstract org.jruby.ast.Node.childNodes.

Deprecated

public Node[]
public Node
get(int idx)

public Node
public NodeType
private Node[]
growList(int mustBeDelta)

public boolean
public Iterator<Node>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public int
size()

Inherited from org.jruby.ast.Node:
containsVariableAssignmentcreateListcreateListcreateListcreateListexecutesOncegetFilegetLinegetNodeNameisNewlineisNilneedsDefinitionChecksetLinesetNewlinetoStringtoStringtoStringExtraInfotoStringInternalunsetNewline

Field Detail

EMPTYback to summary
private static final Node[] EMPTY
INITIAL_SIZEback to summary
private static final int INITIAL_SIZE
listback to summary
private Node[] list
singleback to summary
private Node single

This is used to reduce the need to allocate an array for the many single-element ListNode instances in a typical Ruby app. The methods below detect if single has been set and act accordingly, expanding it to an array lazily only when needed.

sizeback to summary
private int size

Constructor Detail

ListNodeback to summary
public ListNode(int line, Node firstNode)

Create a new ListNode.

Parameters
line:int

where list is

firstNode:Node

first element of the list

ListNodeback to summary
public ListNode(int line)

Method Detail

acceptback to summary
public <T> T accept(NodeVisitor<T> visitor)

Implements abstract org.jruby.ast.Node.accept.

addback to summary
public ListNode add(Node node)
addAllback to summary
public ListNode addAll(ListNode other)

Add all elements in other list to this list node.

Parameters
other:ListNode

list which has elements

Returns:ListNode

this instance for method chaining

addAllback to summary
public ListNode addAll(Node[] other, int index, int length)
addAllback to summary
public ListNode addAll(Node other)

Add other element to this list

Parameters
other:Node

list which has elements

Returns:ListNode

this instance for method chaining

addAllInternalback to summary
protected void addAllInternal(ListNode other)
addInternalback to summary
protected void addInternal(Node node)
addToSingleback to summary
private void addToSingle(Node single, Node node)
arrayifySingleback to summary
private Node[] arrayifySingle(Node single)
childNodesback to summary
public List<Node> childNodes()

Implements abstract org.jruby.ast.Node.childNodes.

Deprecated

Annotations
@Deprecated
childrenback to summary
public Node[] children()
getback to summary
public Node get(int idx)
getLastback to summary
public Node getLast()
getNodeTypeback to summary
public NodeType getNodeType()

Implements abstract org.jruby.ast.Node.getNodeType.

Returns:NodeType

Doc from org.jruby.ast.Node.getNodeType.

the nodeId

growListback to summary
private Node[] growList(int mustBeDelta)
isEmptyback to summary
public boolean isEmpty()
iteratorback to summary
public Iterator<Node> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<Node>

an Iterator.

Annotations
@Override
sizeback to summary
public int size()