Class Nodes.IfNode
java.lang.Object
org.prism.Nodes.Node
org.prism.Nodes.IfNode
- Enclosing class:
Nodes
Represents the use of the `if` keyword, either in the block form or the modifier form, or a ternary expression.
bar if foo
^^^^^^^^^^
if foo then bar end
^^^^^^^^^^^^^^^^^^^
foo ? bar : baz
^^^^^^^^^^^^^^^
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Nodes.NodeThe node for the condition the `IfNode` is testing.final Nodes.StatementsNodeRepresents the body of statements that will be executed when the predicate is evaluated as truthy.final Nodes.NodeRepresents an `ElseNode` or an `IfNode` when there is an `else` or an `elsif` in the `if` statement.Fields inherited from class org.prism.Nodes.Node
EMPTY_ARRAY, length, startOffset -
Constructor Summary
ConstructorsConstructorDescriptionIfNode(int startOffset, int length, Nodes.Node predicate, Nodes.StatementsNode statements, Nodes.Node subsequent) -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(AbstractNodeVisitor<T> visitor) voidsetNewLineFlag(Nodes.Source source, boolean[] newlineMarked) protected String<T> voidvisitChildNodes(AbstractNodeVisitor<T> visitor) Methods inherited from class org.prism.Nodes.Node
endOffset, hasNewLineFlag, setNewLineFlag, toString
-
Field Details
-
predicate
The node for the condition the `IfNode` is testing. if foo ^^^ bar end bar if foo ^^^ foo ? bar : baz ^^^ -
statements
Represents the body of statements that will be executed when the predicate is evaluated as truthy. Will be `nil` when no body is provided. if foo bar ^^^ baz ^^^ end -
subsequent
Represents an `ElseNode` or an `IfNode` when there is an `else` or an `elsif` in the `if` statement. if foo bar elsif baz ^^^^^^^^^ qux ^^^ end ^^^ if foo then bar else baz end ^^^^^^^^^^^^
-
-
Constructor Details
-
IfNode
public IfNode(int startOffset, int length, Nodes.Node predicate, Nodes.StatementsNode statements, Nodes.Node subsequent)
-
-
Method Details
-
setNewLineFlag
- Overrides:
setNewLineFlagin classNodes.Node
-
visitChildNodes
- Specified by:
visitChildNodesin classNodes.Node
-
childNodes
- Specified by:
childNodesin classNodes.Node
-
accept
- Specified by:
acceptin classNodes.Node
-
toString
- Specified by:
toStringin classNodes.Node
-