class TurboTest::StaticAnalysis::Constants::Node
Attributes
children[R]
definition[RW]
end_pos[RW]
name[R]
parent[R]
singleton[R]
start_pos[R]
top_level[RW]
Public Class Methods
new(name:, start_pos:, end_pos:, singleton: false, definition: false)
click to toggle source
# File lib/turbo_test_static_analysis/constants/node.rb, line 10 def initialize(name:, start_pos:, end_pos:, singleton: false, definition: false) @name = name @children = [] @start_pos = start_pos @end_pos = end_pos @parent = nil @singleton = singleton @definition = definition @top_level = false end
Public Instance Methods
add_child(child)
click to toggle source
# File lib/turbo_test_static_analysis/constants/node.rb, line 21 def add_child(child) return if child.start_pos == start_pos && child.name == name return unless contains?(child) @children << child child.instance_variable_set(:@parent, self) child.instance_variable_set(:@definition, definition) child end
contains?(node)
click to toggle source
# File lib/turbo_test_static_analysis/constants/node.rb, line 31 def contains?(node) ((@start_pos <=> node.start_pos) == -1 && (@end_pos <=> node.end_pos) == 1) || ((@start_pos <=> node.start_pos).zero? && ((@end_pos <=> node.end_pos).zero? || (@end_pos <=> node.end_pos) == 1)) end
full_name()
click to toggle source
# File lib/turbo_test_static_analysis/constants/node.rb, line 37 def full_name return @name unless @parent [@parent.full_name, @name].compact.join("::") end
named_singleton_with_parent?()
click to toggle source
# File lib/turbo_test_static_analysis/constants/node.rb, line 55 def named_singleton_with_parent? return false unless parent singleton && name != "singleton_class" end
parent_is_named_singleton?()
click to toggle source
# File lib/turbo_test_static_analysis/constants/node.rb, line 49 def parent_is_named_singleton? return false unless parent parent.singleton && parent.name != "singleton_class" end
root()
click to toggle source
# File lib/turbo_test_static_analysis/constants/node.rb, line 43 def root return self if parent.nil? parent.root end