class Solargraph::Pin::LocalVariable
Attributes
presence[R]
@return [Range]
Public Class Methods
new(assignment: nil, presence: nil, **splat)
click to toggle source
Calls superclass method
Solargraph::Pin::BaseVariable.new
# File lib/solargraph/pin/local_variable.rb, line 8 def initialize assignment: nil, presence: nil, **splat super(**splat) @assignment = assignment @presence = presence end
Public Instance Methods
try_merge!(pin)
click to toggle source
Calls superclass method
Solargraph::Pin::BaseVariable#try_merge!
# File lib/solargraph/pin/local_variable.rb, line 14 def try_merge! pin return false unless super @presence = pin.presence true end
visible_at?(other_closure, other_loc)
click to toggle source
@param other_closure [Pin::Closure] @param other_loc [Location]
# File lib/solargraph/pin/local_variable.rb, line 22 def visible_at?(other_closure, other_loc) return true if location.filename == other_loc.filename && presence.include?(other_loc.range.start) && match_named_closure(other_closure, closure) end
Private Instance Methods
match_named_closure(needle, haystack)
click to toggle source
# File lib/solargraph/pin/local_variable.rb, line 42 def match_named_closure needle, haystack return true if needle == haystack || haystack.is_a?(Pin::Block) cursor = haystack until cursor.nil? return true if needle.path == cursor.path return false if cursor.path && !cursor.path.empty? cursor = cursor.closure end false end