class Ameba::AST::FlowExpression
- Ameba::AST::FlowExpression
- Reference
- Object
Overview
Represents a flow expression in Crystal code. For example,
def foobar
a = 3
return 42 # => flow expression
a + 1
end
Flow expression contains an actual node of a control expression and a parent node, which allows easily search through the related statement (i.e. find unreachable code)
Included Modules
Defined in:
ameba/ast/flow_expression.crConstructors
-
.new(node : Crystal::ASTNode, in_loop : Bool)
Creates a new flow expression.
Instance Method Summary
- #end_location(*args, **options)
- #end_location(*args, **options, &)
-
#in_loop? : Bool
Is true only if some of the nodes parents is a loop.
- #location(*args, **options)
- #location(*args, **options, &)
-
#node : Crystal::ASTNode
The actual node of the flow expression.
- #to_s(*args, **options)
- #to_s(*args, **options, &)
-
#unreachable_nodes
Returns nodes which can't be reached because of a flow command inside.
Instance methods inherited from module Ameba::AST::Util
abort?(node)
abort?,
control_exp_code(node : Crystal::ControlExpression, code_lines)
control_exp_code,
dynamic_literal?(node) : Bool
dynamic_literal?,
exit?(node)
exit?,
flow_command?(node, in_loop)
flow_command?,
flow_expression?(node, in_loop = false)
flow_expression?,
literal?(node) : Bool
literal?,
loop?(node)
loop?,
name_end_location(node)
name_end_location,
name_location(node)
name_location,
name_size(node)
name_size,
node_source(node, code_lines)
node_source,
path_named?(node, name) : Bool
path_named?,
raise?(node)
raise?,
source_between(loc, end_loc, code_lines) : String | Nil
source_between,
static_literal?(node) : Bool
static_literal?
Constructor Detail
def self.new(node : Crystal::ASTNode, in_loop : Bool)
#
Creates a new flow expression.
FlowExpression.new(node, parent_node)
Instance Method Detail
def unreachable_nodes
#
Returns nodes which can't be reached because of a flow command inside. For example:
def foobar
a = 1
return 42
a + 2 # => unreachable assign node
end