class Unparser::AST

Namespace for AST processing tools

def self.from_node(node:)

mutant:disable
def self.from_node(node:)
  new(
    comments:               EMPTY_ARRAY,
    explicit_encoding:      nil,
    node:,
    static_local_variables: Set.new
  )
end

def self.local_variable_assignments(node)

Other tags:
    Api: - private

Returns:
  • (Set) -

Parameters:
  • node (Parser::AST::Node) --
def self.local_variable_assignments(node)
  Enumerator.new(
    node,
    method(:not_reset_scope?)
  ).types(ASSIGN_NODES)
end

def self.local_variable_reads(node)

Other tags:
    Api: - private

Returns:
  • (Set) -

Parameters:
  • node (Parser::AST::Node) --
def self.local_variable_reads(node)
  Enumerator.new(
    node,
    method(:not_close_scope?)
  ).type(:lvar).map(&FIRST_CHILD).to_set
end

def self.not_close_scope?(node)

Other tags:
    Api: - private

Returns:
  • (Boolean) -

Parameters:
  • node (Parser::AST::Node) --
def self.not_close_scope?(node)
  !CLOSE_NODES.include?(node.type)
end

def self.not_reset_scope?(node)

Other tags:
    Api: - private

Returns:
  • (Boolean) -

Parameters:
  • node (Parser::AST::Node) --
def self.not_reset_scope?(node)
  !RESET_NODES.include?(node.type)
end