Class: Solargraph::Pin::LocalVariable

Inherits:
BaseVariable show all
Defined in:
lib/solargraph/pin/local_variable.rb

Direct Known Subclasses

Parameter

Constant Summary

Constants included from Logging

Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS

Instance Attribute Summary

Attributes inherited from BaseVariable

#assignments, #mass_assignment, #presence

Attributes inherited from Base

#code_object, #combine_priority, #directives, #docstring, #location, #name, #path, #return_type, #source, #type_location

Attributes included from Common

#context, #location

Instance Method Summary collapse

Methods inherited from BaseVariable

#==, #assignment, #combine_assignments, #combine_closure, #combine_mass_assignment, #combine_presence, #completion_item_kind, #downcast, #initialize, #inner_desc, #nil_assignment?, #presence_certain?, #reset_generated!, #return_type, #return_types_from_node, #starts_at?, #symbol_kind, #type_desc, #typify, #variable?, #visible_at?

Methods inherited from Base

#==, #all_location_text, #all_rooted?, #assert_location_provided, #assert_same, #assert_same_array_content, #assert_same_count, #assert_same_macros, #assert_source_provided, #best_location, #choose, #choose_longer, #choose_node, #choose_pin_attr, #choose_pin_attr_with_same_name, #choose_priority, #closure, #combine_closure, #combine_directives, #combine_name, #combine_return_type, #comments, #completion_item_kind, #deprecated?, #desc, #dodgy_return_type_source?, #erase_generics, #filename, #gates, #identity, #infer, #initialize, #inner_desc, #inspect, #macros, #maybe_directives?, #nearly?, #needs_consistent_name?, #prefer_rbs_location, #presence_certain?, #probed?, #proxied?, #proxy, #rbs_location?, #realize, #reset_generated!, #resolve_generics, #resolve_generics_from_context, #symbol_kind, #to_s, #transform_types, #type_desc, #typify, #variable?

Methods included from Logging

log_level, logger

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, #closure, #closure=, #comments, #name, #namespace, #path, #reset_generated!, #return_type, #source

Constructor Details

This class inherits a constructor from Solargraph::Pin::BaseVariable

Instance Method Details

#combine_with(other, attrs = {}) ⇒ Object



19
20
21
22
23
24
# File 'lib/solargraph/pin/local_variable.rb', line 19

def combine_with other, attrs = {}
  # keep this as a parameter
  return other.combine_with(self, attrs) if other.is_a?(Parameter) && !is_a?(Parameter)

  super
end

#probe(api_map) ⇒ ComplexType, ComplexType::UniqueType

Parameters:

Returns:



8
9
10
11
12
13
14
15
16
17
# File 'lib/solargraph/pin/local_variable.rb', line 8

def probe api_map
  if presence_certain? && return_type&.defined?
    # flow sensitive typing has already figured out this type
    # has been downcast - use the type it figured out
    # @sg-ignore flow sensitive typing should support ivars
    return adjust_type api_map, return_type.qualify(api_map, *gates)
  end

  super
end

#to_rbsObject



26
27
28
# File 'lib/solargraph/pin/local_variable.rb', line 26

def to_rbs
  "#{name || '(anon)'} #{return_type&.to_rbs || 'untyped'}"
end