Ameba::AST::ElseIfAwareNodeVisitor
Inherits Ameba::AST::Util < Ameba::AST::NodeVisitor < Ameba::AST::BaseVisitor < Crystal::Visitor < Reference < Object
A class that utilizes a logic inherited from NodeVisitor to traverse AST
nodes and fire a source test callback with the Crystal::If node and an array
containing all elsif branches (first branch is an if node) in case
at least one elsif branch is reached, and nil otherwise.
In Crystal, consecutive elsif branches are transformed into if branches
attached to the else branch of an adjacent if branch.
For example:
if foo
do_foo
elsif bar
do_bar
elsif baz
do_baz
else
do_something_else
end
is transformed into:
if foo
do_foo
else
if bar
do_bar
else
if baz
do_baz
else
do_something_else
end
end
end
Constructors
Instance methods
exclude_suffix?
Sourceexclude_ternary?
Sourcevisit(node : Crystal::If)
A visit callback for Crystal::If node.
Returns true if the child nodes should be traversed as well,
false otherwise.