module Orbacle::AstUtils

Public Class Methods

const_prename_and_name_to_string(prename_ast, name_ast) click to toggle source
# File lib/orbacle/ast_utils.rb, line 9
def self.const_prename_and_name_to_string(prename_ast, name_ast)
  (prename(prename_ast) + [name_ast.to_s]).compact.join("::")
end
const_to_string(const_ast) click to toggle source
# File lib/orbacle/ast_utils.rb, line 5
def self.const_to_string(const_ast)
  get_nesting(const_ast).flatten.join("::")
end
get_nesting(ast_const) click to toggle source
# File lib/orbacle/ast_utils.rb, line 13
def self.get_nesting(ast_const)
  [prename(ast_const.children[0]), ast_const.children[1].to_s]
end
prename(ast_const) click to toggle source
# File lib/orbacle/ast_utils.rb, line 17
def self.prename(ast_const)
  if ast_const.nil?
    []
  else
    prename(ast_const.children[0]) + [ast_const.children[1].to_s]
  end
end

Public Instance Methods

build_position_range_from_ast(ast) click to toggle source
# File lib/orbacle/ast_utils.rb, line 25
def build_position_range_from_ast(ast)
  build_position_range_from_parser_range(ast.loc.expression)
end
build_position_range_from_parser_range(parser_range) click to toggle source
# File lib/orbacle/ast_utils.rb, line 29
def build_position_range_from_parser_range(parser_range)
  PositionRange.new(
    Position.new(parser_range.begin.line - 1, parser_range.begin.column),
    Position.new(parser_range.end.line - 1, parser_range.end.column - 1))
end