class Ameba::AST::Branchable


A generic entity to represent a branchable Crystal node. For example, Crystal::If, Crystal::Unless, Crystal::While are branchables.

while a > 100 # Branchable A
  if b > 2    # Branchable B
    a += 1

Included Modules

Defined in:



Instance Method Summary

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 : Crystal::ASTNode, parent : Nil | Ameba::AST::Branchable = nil) #

Creates a new branchable, parent_branchable)

[View source]

Instance Method Detail

def branches : Array(Crystal::ASTNode) #

Array of branches

[View source]
def end_location(*args, **options) #

[View source]
def end_location(*args, **options, &) #

[View source]
def location(*args, **options) #

[View source]
def location(*args, **options, &) #

[View source]
def loop? #

Returns true if this node or one of the parent branchables is a loop, false otherwise.

[View source]
def node : Crystal::ASTNode #

The actual Crystal node

[View source]
def parent : Branchable | Nil #

Parent branchable (if any)

[View source]
def to_s(*args, **options) #

[View source]
def to_s(*args, **options, &) #

[View source]