NIfStatement

NodeAstNodeloreline.NIfStatement (Class)

Represents an if statement in the AST, with optional else branch.

Instance Members

condition: NExpr

The condition to evaluate.


conditionStyle: ConditionStyle

The style of the condition (plain or parentheses).


thenBranch: NBlock

Array of nodes to execute if condition is true.


elseBranch: Null<NBlock>

Optional array of nodes to execute if condition is false.


elseLeadingComments: Null<Array<Comment>>

Comments that appear before the else keyword.


elseTrailingComments: Null<Array<Comment>>

Comments that appear after the else keyword.


type(): String
Returns
String

each(handleNode: Function): Void
Name Type
handleNode Function

toJson(): Dynamic

Converts the if statement to a JSON representation.

Returns Description
Dynamic Dynamic object containing if statement data

new(id: NodeId, pos: Position, condition: NExpr, conditionStyle: ConditionStyle, thenBranch: NBlock, elseBranch: Null<NBlock>, ?leadingComments: Array<Comment>, ?trailingComments: Array<Comment>, ?elseLeadingComments: Array<Comment>, ?elseTrailingComments: Array<Comment>): Void

Creates a new if statement node.

Name Type Default Description
id NodeId
pos Position Position in source where this if statement appears
condition NExpr Expression to evaluate
conditionStyle ConditionStyle The style of the condition (plain or parentheses)
thenBranch NBlock Nodes to execute if condition is true
elseBranch Null<NBlock> Optional nodes to execute if condition is false
leadingComments Array<Comment> (optional) Optional comments before the if
trailingComments Array<Comment> (optional) Optional comments after the if
elseLeadingComments Array<Comment> (optional) Optional comments before the else
elseTrailingComments Array<Comment> (optional) Optional comments after the else

Metadata

Name Parameters
:hxGen -