Class: Solargraph::Pin::Signature
- Defined in:
- lib/solargraph/pin/signature.rb
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary collapse
-
#closure ⇒ Object
writeonly
allow signature to be created before method pin, then set this to the method pin.
Attributes inherited from Callable
#block, #parameters, #return_type
Attributes inherited from Closure
Attributes inherited from Base
#code_object, #combine_priority, #directives, #docstring, #name, #path, #return_type, #source
Attributes included from Common
Instance Method Summary collapse
- #dodgy_return_type_source? ⇒ Boolean
- #generics ⇒ Object
- #identity ⇒ Object
-
#initialize(**splat) ⇒ Signature
constructor
A new instance of Signature.
- #location ⇒ Object
- #type_location ⇒ Object
- #typify(api_map) ⇒ Object
Methods inherited from Callable
#arity, #arity_matches?, #block?, #blockless_parameters, #choose_parameters, #combine_blocks, #combine_with, #mandatory_positional_param_count, #method_name, #method_namespace, #parameter_names, #resolve_generics_from_context, #resolve_generics_from_context_until_complete, #to_rbs, #transform_types
Methods inherited from Closure
#binder, #combine_with, #context, #gates, #generic_defaults, #rbs_generics, #to_rbs
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_directives, #combine_name, #combine_return_type, #combine_with, #comments, #completion_item_kind, #deprecated?, #desc, #erase_generics, #filename, #infer, #inner_desc, #inspect, #macros, #maybe_directives?, #nearly?, #needs_consistent_name?, #prefer_rbs_location, #presence_certain?, #probe, #probed?, #proxied?, #proxy, #rbs_location?, #realize, #reset_generated!, #resolve_generics, #resolve_generics_from_context, #symbol_kind, #to_rbs, #to_s, #transform_types, #type_desc, #variable?
Methods included from Logging
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, #comments, #name, #namespace, #path, #return_type, #source
Constructor Details
#initialize(**splat) ⇒ Signature
Returns a new instance of Signature.
8 9 10 |
# File 'lib/solargraph/pin/signature.rb', line 8 def initialize **splat super(**splat) end |
Instance Attribute Details
#closure=(value) ⇒ Object (writeonly)
allow signature to be created before method pin, then set this to the method pin
6 7 8 |
# File 'lib/solargraph/pin/signature.rb', line 6 def closure=(value) @closure = value end |
Instance Method Details
#dodgy_return_type_source? ⇒ Boolean
22 23 24 |
# File 'lib/solargraph/pin/signature.rb', line 22 def dodgy_return_type_source? super || closure&.dodgy_return_type_source? end |
#generics ⇒ Object
12 13 14 |
# File 'lib/solargraph/pin/signature.rb', line 12 def generics @generics ||= [].freeze end |
#identity ⇒ Object
16 17 18 |
# File 'lib/solargraph/pin/signature.rb', line 16 def identity @identity ||= "signature#{object_id}" end |
#location ⇒ Object
30 31 32 |
# File 'lib/solargraph/pin/signature.rb', line 30 def location super || closure&.location end |
#type_location ⇒ Object
26 27 28 |
# File 'lib/solargraph/pin/signature.rb', line 26 def type_location super || closure&.type_location end |
#typify(api_map) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/solargraph/pin/signature.rb', line 34 def typify api_map if return_type.defined? qualified = return_type.qualify(api_map, closure.namespace) logger.debug { "Signature#typify(self=#{self}) => #{qualified..inspect}" } return qualified end return ComplexType::UNDEFINED if closure.nil? return ComplexType::UNDEFINED unless closure.is_a?(Pin::Method) # @sg-ignore need is_a? support # @type [Array<Pin::Method>] method_stack = closure.rest_of_stack api_map logger.debug { "Signature#typify(self=#{self}) - method_stack: #{method_stack}" } method_stack.each do |pin| sig = pin.signatures.find { |s| s.arity == self.arity } next unless sig unless sig.return_type.undefined? qualified = sig.return_type.qualify(api_map, closure.namespace) logger.debug { "Signature#typify(self=#{self}) => #{qualified..inspect}" } return qualified end end out = super logger.debug { "Signature#typify(self=#{self}) => #{out}" } out end |