Ameba::AST::FlowExpression - ameba 1.7.0

# 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

- Ameba::AST::Util

##
Defined in:

ameba/ast/flow_expression.cr

##
Constructors

- .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?, each_inline_directive(source, &block : Crystal::Token, String, Array(String) -> _) each_inline_directive, exit?(node) exit?, flow_command?(node, in_loop) flow_command?, flow_expression?(node, in_loop = false) flow_expression?, has_arguments?(node) : Bool has_arguments?, has_block?(node) : Bool has_block?, has_short_block?(node, code_lines) has_short_block?, heredoc?(node : Crystal::ASTNode, source : Source) heredoc?, literal?(node) : Bool literal?, loop?(node) loop?, name_end_location(node) name_end_location, name_location(node) name_location, name_location_or(token : Crystal::Token, name, *, adjust_location_column_number = nil)
name_location_or(node : Crystal::ASTNode, *, adjust_location_column_number = nil) name_location_or, name_size(node) name_size, node_source(node, code_lines) node_source, nodoc?(node) nodoc?, operator_method?(node) operator_method?, operator_method_name?(name : String) operator_method_name?, path_name(node : Crystal::Path, *, include_global = true) : String path_name, path_named?(node, *names : String) : Bool path_named?, raise?(node) raise?, setter_method?(node) setter_method?, setter_method_name?(name : String) setter_method_name?, short_block?(node, code_lines) short_block?, source_between(loc, end_loc, code_lines) : String | Nil source_between, static_literal?(node) : Bool static_literal?, suffix?(node) suffix?, takes_arguments?(node) : Bool takes_arguments?

##
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 end_location(*args, **options) #
def end_location(*args, **options, &) #
def in_loop? : Bool #

Is true only if some of the nodes parents is a loop.

def location(*args, **options) #
def location(*args, **options, &) #
def node : Crystal::ASTNode #

The actual node of the flow expression.

def to_s(*args, **options) #
def to_s(*args, **options, &) #
def unreachable_nodes #

Returns nodes which can't be reached because of a flow command inside. For example:

    def foobar
      a = 3
      return 42
      a + 1 # => unreachable node
    end