Class: Solargraph::Pin::Signature

Inherits:
Callable show all
Defined in:
lib/solargraph/pin/signature.rb

Constant Summary

Constants included from Logging

Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS

Instance Attribute Summary collapse

Attributes inherited from Callable

#block, #parameters, #return_type

Attributes inherited from Closure

#scope

Attributes inherited from CompoundStatement

#node

Attributes inherited from Base

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

Attributes included from Common

#context

Instance Method Summary collapse

Methods inherited from Callable

#arity, #arity_matches?, #block?, #blockless_parameters, #choose_parameters, #combine_blocks, #combine_with, #full_type_arity, #initialize, #mandatory_positional_param_count, #method_name, #method_namespace, #parameter_names, #parameters_to_rbs, #reset_generated!, #resolve_generics_from_context, #resolve_generics_from_context_until_complete, #to_rbs, #transform_types, #type_arity

Methods inherited from Closure

#combine_with, #context, #generic_defaults, #initialize, #rbs_generics, #rebind, #to_rbs

Methods inherited from CompoundStatement

#initialize

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, #combine_with, #comments, #completion_item_kind, #deprecated?, #desc, #erase_generics, #filename, #gates, #infer, #initialize, #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

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

Constructor Details

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

Instance Attribute Details

#closure=(value) ⇒ Object (writeonly)

allow signature to be created before method pin, then set this to the method pin



8
9
10
# File 'lib/solargraph/pin/signature.rb', line 8

def closure=(value)
  @closure = value
end

Instance Method Details

#dodgy_return_type_source?Boolean

@ sg-ignore need boolish support for ? methods

Returns:

  • (Boolean)


20
21
22
# File 'lib/solargraph/pin/signature.rb', line 20

def dodgy_return_type_source?
  super || closure&.dodgy_return_type_source?
end

#genericsObject



10
11
12
13
# File 'lib/solargraph/pin/signature.rb', line 10

def generics
  # @type [Array<::String, nil>]
  @generics ||= [].freeze
end

#identityObject



15
16
17
# File 'lib/solargraph/pin/signature.rb', line 15

def identity
  @identity ||= "signature#{object_id}"
end

#locationObject



28
29
30
# File 'lib/solargraph/pin/signature.rb', line 28

def location
  super || closure&.location
end

#type_locationObject



24
25
26
# File 'lib/solargraph/pin/signature.rb', line 24

def type_location
  super || closure&.type_location
end

#typify(api_map) ⇒ Object



32
33
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
59
60
61
# File 'lib/solargraph/pin/signature.rb', line 32

def typify api_map
  # @sg-ignore Need to add nil check here
  if return_type.defined?
    # @sg-ignore Need to add nil check here
    qualified = return_type.qualify(api_map, closure.namespace)
    # @sg-ignore Need to add nil check here
    logger.debug { "Signature#typify(self=#{self}) => #{qualified.rooted_tags.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 == arity }
    next unless sig
    # @sg-ignore Need to add nil check here
    next if sig.return_type.undefined?
    # @sg-ignore Need to add nil check here
    qualified = sig.return_type.qualify(api_map, closure.namespace)
    # @sg-ignore Need to add nil check here
    logger.debug { "Signature#typify(self=#{self}) => #{qualified.rooted_tags.inspect}" }
    return qualified
  end
  out = super
  logger.debug { "Signature#typify(self=#{self}) => #{out}" }
  out
end