class Solargraph::Pin::LocalVariable
Attributes
@return [Range]
Public Class Methods
Source
# File lib/solargraph/pin/local_variable.rb, line 17 def initialize assignment: nil, presence: nil, presence_certain: false, **splat super(**splat) @assignment = assignment @presence = presence @presence_certain = presence_certain end
@param assignment [AST::Node, nil] @param presence [Range, nil] @param presence_certain [Boolean] @param splat [Hash]
Calls superclass method
Solargraph::Pin::BaseVariable::new
Public Instance Methods
Source
# File lib/solargraph/pin/local_variable.rb, line 24 def combine_with(other, attrs={}) new_attrs = { assignment: assert_same(other, :assignment), presence_certain: assert_same(other, :presence_certain?), }.merge(attrs) new_attrs[:presence] = assert_same(other, :presence) unless attrs.key?(:presence) super(other, new_attrs) end
Calls superclass method
Solargraph::Pin::BaseVariable#combine_with
Source
# File lib/solargraph/pin/local_variable.rb, line 9 def presence_certain? @presence_certain end
Source
# File lib/solargraph/pin/local_variable.rb, line 42 def to_rbs (name || '(anon)') + ' ' + (return_type&.to_rbs || 'untyped') end
Source
# File lib/solargraph/pin/local_variable.rb, line 36 def visible_at?(other_closure, other_loc) location.filename == other_loc.filename && presence.include?(other_loc.range.start) && match_named_closure(other_closure, closure) end
@param other_closure [Pin::Closure] @param other_loc [Location]
Private Instance Methods
Source
# File lib/solargraph/pin/local_variable.rb, line 63 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
@param needle [Pin::Base] @param haystack [Pin::Base] @return [Boolean]