Top Description Fields Constructors Methods
org.jruby.ast

public abstract Class Node

extends Object
Class Inheritance
Known Direct Subclasses
org.jruby.ast.NthRefNode, org.jruby.ast.NumericNode, org.jruby.ast.OpAsgnAndNode, org.jruby.ast.OpAsgnConstDeclNode, org.jruby.ast.OpAsgnNode, org.jruby.ast.OpAsgnOrNode, org.jruby.ast.OpElementAsgnNode, org.jruby.ast.OptArgNode, org.jruby.ast.OrNode, org.jruby.ast.RedoNode, org.jruby.ast.RegexpNode, org.jruby.ast.RequiredKeywordArgumentValueNode, org.jruby.ast.RescueBodyNode, org.jruby.ast.RescueNode, org.jruby.ast.RetryNode, org.jruby.ast.ReturnNode, org.jruby.ast.RootNode, org.jruby.ast.SClassNode, org.jruby.ast.SelfNode, org.jruby.ast.StarNode, org.jruby.ast.StrNode, org.jruby.ast.SuperNode, org.jruby.ast.SValueNode, org.jruby.ast.SymbolNode, org.jruby.ast.TrueNode, org.jruby.ast.UndefNode, org.jruby.ast.UntilNode, org.jruby.ast.VAliasNode, org.jruby.ast.VCallNode, org.jruby.ast.WhenNode, org.jruby.ast.WhileNode, org.jruby.ast.XStrNode, org.jruby.ast.YieldNode, org.jruby.ast.ZSuperNode, org.jruby.ast.AliasNode, org.jruby.ast.AndNode, org.jruby.ast.ArgsCatNode, org.jruby.ast.ArgsNode, org.jruby.ast.ArgsPushNode, org.jruby.ast.ArgumentNode, org.jruby.ast.ArrayPatternNode, org.jruby.ast.AssignableNode, org.jruby.ast.AttrAssignNode, org.jruby.ast.BackRefNode, org.jruby.ast.BeginNode, org.jruby.ast.BlockArgNode, org.jruby.ast.BreakNode, org.jruby.ast.CallNode, org.jruby.ast.CaseNode, org.jruby.ast.ClassNode, org.jruby.ast.ClassVarNode, org.jruby.ast.Colon3Node, org.jruby.ast.ConstNode, org.jruby.ast.DotNode, org.jruby.ast.DVarNode, org.jruby.ast.EncodingNode, org.jruby.ast.EnsureNode, org.jruby.ast.ErrorNode, org.jruby.ast.EvStrNode, org.jruby.ast.FalseNode, org.jruby.ast.FCallNode, org.jruby.ast.FindPatternNode, org.jruby.ast.FlipNode, org.jruby.ast.GlobalVarNode, org.jruby.ast.HashNode, org.jruby.ast.HashPatternNode, org.jruby.ast.IfNode, org.jruby.ast.InNode, org.jruby.ast.InstVarNode, org.jruby.ast.BlockPassNode, org.jruby.ast.DefinedNode, org.jruby.ast.PatternCaseNode, org.jruby.ast.SplatNode, org.jruby.ast.IterNode, org.jruby.ast.KeywordArgNode, org.jruby.ast.ListNode, org.jruby.ast.LiteralNode, org.jruby.ast.LocalVarNode, org.jruby.ast.Match2Node, org.jruby.ast.Match3Node, org.jruby.ast.MatchNode, org.jruby.ast.MethodDefNode, org.jruby.ast.ModuleNode, org.jruby.ast.NewlineNode, org.jruby.ast.NextNode, org.jruby.ast.NilNode, org.jruby.ast.NilRestArgNode
Imports
java.util.ArrayList, .Collections, .List, org.jruby.ast.types.INameNode, org.jruby.ast.visitor.NodeVisitor

Base class for all Nodes in the AST

Field Summary

Modifier and TypeField and Description
protected boolean
pack-priv static final List<Node>
private int
protected boolean

Constructor Summary

AccessConstructor and Description
public
Node(int line, boolean containsAssignment)

Method Summary

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

public abstract List<Node>
public boolean
containsVariableAssignment()

Does this node or one of its children contain an assignment?

protected static List<Node>
protected static List<Node>
createList(Node node1, Node node2)

protected static List<Node>
createList(Node node1, Node node2, Node node3)

protected static List<Node>
createList(Node... nodes)

public boolean

Returns:

is it possible this node will execute only once.

Note

This is not comprehensive. It is used to look from root node down to class/module nodes to make sure that narrow case can execute once. It is possible much deeper down the tree some nodes can only execute once but it will be marked as false because that case is not what this is for.

executesOnce
()

public String
public int
protected String
public abstract NodeType

Returns:

the nodeId
getNodeType
()

private static void
indent(int indentation, StringBuilder builder)

public boolean
public boolean

Returns:

true if nil, false otherwise
isNil
()

Whether the node evaluates to nil and has no side effects.

public boolean

Returns:

Whether the type of node represents a possibly undefined construct
needsDefinitionCheck
()

Check whether the given node is considered always "defined" or whether it has some form of definition check.

public void
setLine(int line)

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public String
toString(boolean indent, int indentation)

public String

Returns:

null for no extra info or something otherwise.
toStringExtraInfo
()

Not all interesting info in the AST is from Node data.

protected String

Returns:

A string representing internal node state, or null if none.
toStringInternal
()

Overridden by nodes that have additional internal state to be displated in toString.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

containsVariableAssignmentback to summary
protected boolean containsVariableAssignment
EMPTY_LISTback to summary
pack-priv static final List<Node> EMPTY_LIST
lineback to summary
private int line
newlineback to summary
protected boolean newline

Constructor Detail

Nodeback to summary
public Node(int line, boolean containsAssignment)

Method Detail

acceptback to summary
public abstract <T> T accept(NodeVisitor<T> visitor)
childNodesback to summary
public abstract List<Node> childNodes()
containsVariableAssignmentback to summary
public boolean containsVariableAssignment()

Does this node or one of its children contain an assignment?

createListback to summary
protected static List<Node> createList(Node node)
createListback to summary
protected static List<Node> createList(Node node1, Node node2)
createListback to summary
protected static List<Node> createList(Node node1, Node node2, Node node3)
createListback to summary
protected static List<Node> createList(Node... nodes)
executesOnceback to summary
public boolean executesOnce()
Returns:boolean

is it possible this node will execute only once.

Note

This is not comprehensive. It is used to look from root node down to class/module nodes to make sure that narrow case can execute once. It is possible much deeper down the tree some nodes can only execute once but it will be marked as false because that case is not what this is for.

getFileback to summary
public String getFile()
getLineback to summary
public int getLine()
getNodeNameback to summary
protected String getNodeName()
getNodeTypeback to summary
public abstract NodeType getNodeType()
Returns:NodeType

the nodeId

indentback to summary
private static void indent(int indentation, StringBuilder builder)
isNewlineback to summary
public boolean isNewline()
isNilback to summary
public boolean isNil()

Whether the node evaluates to nil and has no side effects.

Returns:boolean

true if nil, false otherwise

needsDefinitionCheckback to summary
public boolean needsDefinitionCheck()

Check whether the given node is considered always "defined" or whether it has some form of definition check.

Returns:boolean

Whether the type of node represents a possibly undefined construct

setLineback to summary
public void setLine(int line)
setNewlineback to summary
public void setNewline()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
toStringback to summary
public String toString(boolean indent, int indentation)
toStringExtraInfoback to summary
public String toStringExtraInfo()

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).

Returns:String

null for no extra info or something otherwise.

toStringInternalback to summary
protected String toStringInternal()

Overridden by nodes that have additional internal state to be displated in toString.

For nodes that have it, name is handled separately, by implementing INameNode.

Child nodes are handled via iterating #childNodes.

Returns:String

A string representing internal node state, or null if none.

unsetNewlineback to summary
public void unsetNewline()