Class: Solargraph::Pin::LocalVariable
- Inherits:
-
BaseVariable
- Object
- Base
- BaseVariable
- Solargraph::Pin::LocalVariable
- Defined in:
- lib/solargraph/pin/local_variable.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- #presence ⇒ Range readonly
Attributes inherited from BaseVariable
Attributes inherited from Base
#code_object, #location, #name, #path, #return_type, #source
Attributes included from Common
Instance Method Summary collapse
-
#initialize(assignment: nil, presence: nil, **splat) ⇒ LocalVariable
constructor
A new instance of LocalVariable.
- #try_merge!(pin) ⇒ Object
- #visible_at?(other_closure, other_loc) ⇒ Boolean
Methods inherited from BaseVariable
#==, #completion_item_kind, #nil_assignment?, #probe, #return_type, #symbol_kind, #variable?
Methods inherited from Base
#==, #comments, #completion_item_kind, #deprecated?, #directives, #docstring, #filename, #identity, #infer, #inspect, #macros, #maybe_directives?, #nearly?, #probe, #probed?, #proxied?, #proxy, #realize, #symbol_kind, #to_s, #typify, #variable?
Methods included from Documenting
Methods included from Conversions
#completion_item, #detail, #link_documentation, #reset_conversions, #resolve_completion_item, #signature_help, #text_documentation
Methods included from Common
#binder, #comments, #context, #name, #namespace, #path, #return_type
Constructor Details
#initialize(assignment: nil, presence: nil, **splat) ⇒ LocalVariable
Returns a new instance of LocalVariable.
9 10 11 12 13 |
# File 'lib/solargraph/pin/local_variable.rb', line 9 def initialize assignment: nil, presence: nil, **splat super(**splat) @assignment = assignment @presence = presence end |
Instance Attribute Details
#presence ⇒ Range (readonly)
7 8 9 |
# File 'lib/solargraph/pin/local_variable.rb', line 7 def presence @presence end |
Instance Method Details
#try_merge!(pin) ⇒ Object
15 16 17 18 19 |
# 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) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/solargraph/pin/local_variable.rb', line 23 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 |