class Unparser::AST::LocalVariableScope
Calculated local variable scope for a given node
def first_assignment?(node)
- Api: - private
Returns:
-
(Boolean)
-
Parameters:
-
node
(Parser::AST::Node
) --
def first_assignment?(node) name = node.children.first match(node) do |current, before| current.include?(name) && !before.include?(name) end end
def first_assignment_in?(left, right)
- Api: - private
Parameters:
-
condition
(Parser::AST::Node
) -- -
body
(Parser::AST::Node
) --
def first_assignment_in?(left, right) condition_reads = AST.local_variable_reads(right) candidates = AST.local_variable_assignments(left).select do |node| condition_reads.include?(node.children.first) end candidates.any?(&public_method(:first_assignment?)) end
def initialize(*arguments)
-
(undefined)
-
Parameters:
-
node
(Parser::AST::Node
) --
def initialize(*arguments) super items = [] LocalVariableScopeEnumerator.each( node: node, stack: static_local_variables.dup ) { |*scope| items << scope } @items = items end
def local_variable_defined_for_node?(node, name)
- Api: - private
Returns:
-
(Boolean)
-
Parameters:
-
name
(Symbol
) -- -
node
(Parser::AST::Node
) --
def local_variable_defined_for_node?(node, name) match(node) do |current| current.include?(name) end end
def local_variables_for_node(needle)
def local_variables_for_node(needle) @items.each do |node, current| return current if node.equal?(needle) end Set.new end
def match(needle)
def match(needle) @items.each do |node, current, before| return yield(current, before) if node.equal?(needle) end end