class
Ameba::AST::ElseIfAwareNodeVisitor
- Ameba::AST::ElseIfAwareNodeVisitor
- Ameba::AST::NodeVisitor
- Ameba::AST::BaseVisitor
- Crystal::Visitor
- Reference
- Object
Overview
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
Defined in:
ameba/ast/visitors/elseif_aware_node_visitor.crInstance Method Summary
-
#visit(node : Crystal::If)
A visit callback for
Crystal::Ifnode.
Instance methods inherited from class Ameba::AST::NodeVisitor
visit(node : Crystal::VisibilityModifier)visit(node : Crystal::Alias)
visit(node : Crystal::ArrayLiteral)
visit(node : Crystal::Assign)
visit(node : Crystal::Block)
visit(node : Crystal::Call)
visit(node : Crystal::Case)
visit(node : Crystal::ClassDef)
visit(node : Crystal::ClassVar)
visit(node : Crystal::ControlExpression)
visit(node : Crystal::Def)
visit(node : Crystal::EnumDef)
visit(node : Crystal::ExceptionHandler)
visit(node : Crystal::Expressions)
visit(node : Crystal::HashLiteral)
visit(node : Crystal::If)
visit(node : Crystal::InstanceVar)
visit(node : Crystal::IsA)
visit(node : Crystal::LibDef)
visit(node : Crystal::MacroExpression)
visit(node : Crystal::ModuleDef)
visit(node : Crystal::MultiAssign)
visit(node : Crystal::NilLiteral)
visit(node : Crystal::ProcLiteral)
visit(node : Crystal::Select)
visit(node : Crystal::StringInterpolation)
visit(node : Crystal::StringLiteral)
visit(node : Crystal::Unless)
visit(node : Crystal::Until)
visit(node : Crystal::Var)
visit(node : Crystal::When)
visit(node : Crystal::While)
visit(node) visit
Constructor methods inherited from class Ameba::AST::NodeVisitor
new(rule, source, *, skip : Category)new(rule, source, *, skip : Array | Nil = nil) new
Class methods inherited from class Ameba::AST::NodeVisitor
category_to_node_classes(category : Category)
category_to_node_classes
Instance methods inherited from class Ameba::AST::BaseVisitor
visit(node : Crystal::ASTNode)
visit
Constructor methods inherited from class Ameba::AST::BaseVisitor
new(rule : Ameba::Rule::Base, source : Ameba::Source)
new
Instance Method Detail
def visit(node : Crystal::If)
#
Description copied from class Ameba::AST::NodeVisitor
A visit callback for Crystal::If node.
Returns true if the child nodes should be traversed as well,
false otherwise.