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, #type_location
Attributes included from Common
Instance Method Summary collapse
-
#initialize(assignment: nil, presence: nil, presence_certain: false, **splat) ⇒ LocalVariable
constructor
A new instance of LocalVariable.
- #presence_certain? ⇒ Boolean
- #to_rbs ⇒ String
- #try_merge!(pin) ⇒ Object
- #visible_at?(other_closure, other_loc) ⇒ Boolean
Methods inherited from BaseVariable
#==, #completion_item_kind, #nil_assignment?, #probe, #return_type, #return_types_from_node, #symbol_kind, #type_desc, #variable?
Methods inherited from Base
#==, #all_rooted?, #best_location, #comments, #completion_item_kind, #deprecated?, #desc, #directives, #docstring, #erase_generics, #filename, #identity, #infer, #inspect, #macros, #maybe_directives?, #nearly?, #probe, #probed?, #proxied?, #proxy, #realize, #resolve_generics, #resolve_generics_from_context, #symbol_kind, #to_s, #transform_types, #type_desc, #typify, #variable?
Methods included from Documenting
#documentation, normalize_indentation, strip_html_comments
Methods included from Conversions
#completion_item, #completion_item_kind, #deprecated?, #detail, #link_documentation, #probed?, #proxied?, #reset_conversions, #resolve_completion_item, #signature_help, #text_documentation
Methods included from Common
#binder, #comments, #name, #namespace, #path, #return_type
Constructor Details
#initialize(assignment: nil, presence: nil, presence_certain: false, **splat) ⇒ LocalVariable
Returns a new instance of LocalVariable.
17 18 19 20 21 22 |
# 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 |
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
#presence_certain? ⇒ Boolean
9 10 11 |
# File 'lib/solargraph/pin/local_variable.rb', line 9 def presence_certain? @presence_certain end |
#to_rbs ⇒ String
40 41 42 |
# File 'lib/solargraph/pin/local_variable.rb', line 40 def to_rbs (name || '(anon)') + ' ' + (return_type&.to_rbs || 'untyped') end |
#try_merge!(pin) ⇒ Object
25 26 27 28 29 |
# File 'lib/solargraph/pin/local_variable.rb', line 25 def try_merge! pin return false unless super @presence = pin.presence true end |
#visible_at?(other_closure, other_loc) ⇒ Boolean
33 34 35 36 37 |
# File 'lib/solargraph/pin/local_variable.rb', line 33 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 |