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 9 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 15 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_loc [Location]
# File lib/solargraph/pin/local_variable.rb, line 35 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
visible_from?(other, position)
click to toggle source
@param other [Pin::Base] The caller's block @param position [Position, Array(Integer, Integer)] The caller's position @return [Boolean]
# File lib/solargraph/pin/local_variable.rb, line 24 def visible_from?(other, position) position = Position.normalize(position) other.filename == filename && match_tags(other.full_context.tag, full_context.tag) && (other == closure || (closure.location.range.contain?(other.location.range.start) && closure.location.range.contain?(other.location.range.ending)) ) && presence.contain?(position) end
Private Instance Methods
match_named_closure(needle, haystack)
click to toggle source
# File lib/solargraph/pin/local_variable.rb, line 55 def match_named_closure needle, haystack return true if needle == haystack 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