solargraph 0.32.5 → 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +2 -11
  4. data/lib/solargraph.rb +1 -2
  5. data/lib/solargraph/api_map.rb +93 -63
  6. data/lib/solargraph/api_map/cache.rb +16 -1
  7. data/lib/solargraph/api_map/source_to_yard.rb +16 -7
  8. data/lib/solargraph/api_map/store.rb +55 -12
  9. data/lib/solargraph/complex_type.rb +58 -14
  10. data/lib/solargraph/complex_type/type_methods.rb +2 -2
  11. data/lib/solargraph/complex_type/unique_type.rb +33 -4
  12. data/lib/solargraph/core_fills.rb +40 -12
  13. data/lib/solargraph/diagnostics.rb +4 -3
  14. data/lib/solargraph/diagnostics/base.rb +6 -0
  15. data/lib/solargraph/diagnostics/require_not_found.rb +17 -10
  16. data/lib/solargraph/diagnostics/rubocop_helpers.rb +2 -0
  17. data/lib/solargraph/diagnostics/type_check.rb +51 -0
  18. data/lib/solargraph/diagnostics/update_errors.rb +1 -0
  19. data/lib/solargraph/language_server/host.rb +55 -25
  20. data/lib/solargraph/language_server/host/diagnoser.rb +1 -2
  21. data/lib/solargraph/language_server/host/dispatch.rb +4 -8
  22. data/lib/solargraph/language_server/host/sources.rb +1 -1
  23. data/lib/solargraph/language_server/message.rb +1 -0
  24. data/lib/solargraph/language_server/message/completion_item/resolve.rb +4 -2
  25. data/lib/solargraph/language_server/message/initialize.rb +9 -0
  26. data/lib/solargraph/language_server/message/initialized.rb +1 -0
  27. data/lib/solargraph/language_server/message/text_document.rb +1 -0
  28. data/lib/solargraph/language_server/message/text_document/code_action.rb +15 -0
  29. data/lib/solargraph/language_server/message/text_document/completion.rb +1 -1
  30. data/lib/solargraph/language_server/message/text_document/definition.rb +25 -5
  31. data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
  32. data/lib/solargraph/language_server/message/text_document/signature_help.rb +4 -0
  33. data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +8 -4
  34. data/lib/solargraph/language_server/transport/adapter.rb +12 -15
  35. data/lib/solargraph/library.rb +23 -6
  36. data/lib/solargraph/location.rb +4 -0
  37. data/lib/solargraph/pin.rb +7 -3
  38. data/lib/solargraph/pin/attribute.rb +14 -13
  39. data/lib/solargraph/pin/base.rb +56 -43
  40. data/lib/solargraph/pin/base_method.rb +41 -18
  41. data/lib/solargraph/pin/base_variable.rb +17 -15
  42. data/lib/solargraph/pin/block.rb +22 -4
  43. data/lib/solargraph/pin/closure.rb +28 -0
  44. data/lib/solargraph/pin/common.rb +59 -0
  45. data/lib/solargraph/pin/constant.rb +4 -4
  46. data/lib/solargraph/pin/conversions.rb +8 -8
  47. data/lib/solargraph/pin/duck_method.rb +3 -3
  48. data/lib/solargraph/pin/instance_variable.rb +30 -0
  49. data/lib/solargraph/pin/keyword.rb +1 -1
  50. data/lib/solargraph/pin/local_variable.rb +3 -3
  51. data/lib/solargraph/pin/localized.rb +9 -5
  52. data/lib/solargraph/pin/method.rb +26 -40
  53. data/lib/solargraph/pin/method_alias.rb +9 -6
  54. data/lib/solargraph/pin/namespace.rb +33 -10
  55. data/lib/solargraph/pin/parameter.rb +150 -0
  56. data/lib/solargraph/pin/proxy_type.rb +8 -8
  57. data/lib/solargraph/pin/reference.rb +1 -12
  58. data/lib/solargraph/pin/reference/override.rb +18 -0
  59. data/lib/solargraph/pin/reference/require.rb +2 -1
  60. data/lib/solargraph/pin/singleton.rb +9 -0
  61. data/lib/solargraph/pin/symbol.rb +9 -4
  62. data/lib/solargraph/pin/yard_pin/constant.rb +12 -3
  63. data/lib/solargraph/pin/yard_pin/method.rb +18 -6
  64. data/lib/solargraph/pin/yard_pin/namespace.rb +13 -1
  65. data/lib/solargraph/position.rb +1 -1
  66. data/lib/solargraph/range.rb +4 -0
  67. data/lib/solargraph/shell.rb +83 -4
  68. data/lib/solargraph/source.rb +32 -12
  69. data/lib/solargraph/source/chain.rb +48 -28
  70. data/lib/solargraph/source/chain/call.rb +37 -38
  71. data/lib/solargraph/source/chain/constant.rb +1 -1
  72. data/lib/solargraph/source/chain/head.rb +2 -8
  73. data/lib/solargraph/source/chain/instance_variable.rb +1 -1
  74. data/lib/solargraph/source/chain/link.rb +2 -0
  75. data/lib/solargraph/source/cursor.rb +59 -24
  76. data/lib/solargraph/source/node_chainer.rb +0 -2
  77. data/lib/solargraph/source/node_methods.rb +12 -6
  78. data/lib/solargraph/source/source_chainer.rb +38 -44
  79. data/lib/solargraph/source_map.rb +11 -18
  80. data/lib/solargraph/source_map/clip.rb +13 -15
  81. data/lib/solargraph/source_map/mapper.rb +37 -26
  82. data/lib/solargraph/source_map/node_processor.rb +13 -8
  83. data/lib/solargraph/source_map/node_processor/alias_node.rb +8 -8
  84. data/lib/solargraph/source_map/node_processor/args_node.rb +10 -16
  85. data/lib/solargraph/source_map/node_processor/base.rb +47 -4
  86. data/lib/solargraph/source_map/node_processor/block_node.rb +9 -4
  87. data/lib/solargraph/source_map/node_processor/casgn_node.rb +7 -2
  88. data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +8 -3
  89. data/lib/solargraph/source_map/node_processor/def_node.rb +45 -38
  90. data/lib/solargraph/source_map/node_processor/defs_node.rb +16 -6
  91. data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +8 -1
  92. data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +20 -6
  93. data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +10 -4
  94. data/lib/solargraph/source_map/node_processor/namespace_node.rb +18 -12
  95. data/lib/solargraph/source_map/node_processor/orasgn_node.rb +1 -1
  96. data/lib/solargraph/source_map/node_processor/resbody_node.rb +30 -0
  97. data/lib/solargraph/source_map/node_processor/sclass_node.rb +7 -1
  98. data/lib/solargraph/source_map/node_processor/send_node.rb +102 -52
  99. data/lib/solargraph/source_map/node_processor/sym_node.rb +4 -1
  100. data/lib/solargraph/source_map/region.rb +9 -8
  101. data/lib/solargraph/type_checker.rb +282 -0
  102. data/lib/solargraph/type_checker/param_def.rb +47 -0
  103. data/lib/solargraph/type_checker/problem.rb +25 -0
  104. data/lib/solargraph/version.rb +1 -1
  105. data/lib/solargraph/views/environment.erb +1 -1
  106. data/lib/solargraph/workspace.rb +2 -2
  107. data/lib/solargraph/workspace/config.rb +0 -8
  108. data/lib/solargraph/yard_map.rb +25 -69
  109. data/lib/solargraph/yard_map/core_docs.rb +8 -3
  110. data/lib/solargraph/yard_map/core_gen.rb +1 -3
  111. data/lib/solargraph/yard_map/mapper.rb +85 -0
  112. data/lib/yard-solargraph.rb +2 -0
  113. metadata +14 -14
  114. data/lib/solargraph/diagnostics/type_not_defined.rb +0 -108
  115. data/lib/solargraph/live_map.rb +0 -126
  116. data/lib/solargraph/live_map/cache.rb +0 -38
  117. data/lib/solargraph/pin/block_parameter.rb +0 -103
  118. data/lib/solargraph/pin/method_parameter.rb +0 -40
  119. data/lib/solargraph/pin/plugin/method.rb +0 -25
  120. data/lib/solargraph/plugin.rb +0 -8
  121. data/lib/solargraph/plugin/base.rb +0 -41
  122. data/lib/solargraph/plugin/canceler.rb +0 -11
  123. data/lib/solargraph/plugin/process.rb +0 -172
  124. data/lib/solargraph/plugin/runtime.rb +0 -134
  125. data/lib/yard-coregen.rb +0 -16
@@ -19,6 +19,7 @@ module Solargraph
19
19
  autoload :Rename, 'solargraph/language_server/message/text_document/rename'
20
20
  autoload :PrepareRename, 'solargraph/language_server/message/text_document/prepare_rename'
21
21
  autoload :FoldingRange, 'solargraph/language_server/message/text_document/folding_range'
22
+ autoload :CodeAction, 'solargraph/language_server/message/text_document/code_action'
22
23
  end
23
24
  end
24
25
  end
@@ -0,0 +1,15 @@
1
+ require 'open3'
2
+
3
+ module Solargraph
4
+ module LanguageServer
5
+ module Message
6
+ module TextDocument
7
+ class CodeAction < Base
8
+ def process
9
+ # @todo Find code actions
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -36,7 +36,7 @@ module Solargraph
36
36
  end
37
37
  rescue FileNotFoundError => e
38
38
  Logging.logger.warn "[#{e.class}] #{e.message}"
39
- Logging.logger.warn e.backtrace
39
+ Logging.logger.warn e.backtrace.join("\n")
40
40
  set_result empty_result
41
41
  end
42
42
 
@@ -3,16 +3,36 @@ require 'uri'
3
3
  module Solargraph::LanguageServer::Message::TextDocument
4
4
  class Definition < Base
5
5
  def process
6
- line = params['position']['line']
7
- col = params['position']['character']
8
- suggestions = host.definitions_at(params['textDocument']['uri'], line, col)
9
- locations = suggestions.reject{|pin| pin.location.nil?}.map do |pin|
6
+ @line = params['position']['line']
7
+ @column = params['position']['character']
8
+ set_result(code_location || require_location || [])
9
+ end
10
+
11
+ private
12
+
13
+ def code_location
14
+ suggestions = host.definitions_at(params['textDocument']['uri'], @line, @column)
15
+ return nil if suggestions.empty?
16
+ suggestions.reject{|pin| pin.location.nil?}.map do |pin|
10
17
  {
11
18
  uri: file_to_uri(pin.location.filename),
12
19
  range: pin.location.range.to_hash
13
20
  }
14
21
  end
15
- set_result locations
22
+ end
23
+
24
+ def require_location
25
+ # @todo Terrible hack
26
+ lib = host.library_for(params['textDocument']['uri'])
27
+ rloc = Solargraph::Location.new(uri_to_file(params['textDocument']['uri']), Solargraph::Range.from_to(@line, @column, @line, @column))
28
+ dloc = lib.locate_ref(rloc)
29
+ return nil if dloc.nil?
30
+ [
31
+ {
32
+ uri: file_to_uri(dloc.filename),
33
+ range: dloc.range.to_hash
34
+ }
35
+ ]
16
36
  end
17
37
  end
18
38
  end
@@ -31,7 +31,7 @@ module Solargraph
31
31
  )
32
32
  rescue FileNotFoundError => e
33
33
  Logging.logger.warn "[#{e.class}] #{e.message}"
34
- Logging.logger.warn e.backtrace
34
+ Logging.logger.warn e.backtrace.join("\n")
35
35
  set_result nil
36
36
  end
37
37
  end
@@ -11,6 +11,10 @@ module Solargraph
11
11
  set_result({
12
12
  signatures: info
13
13
  })
14
+ rescue FileNotFoundError => e
15
+ Logging.logger.warn "[#{e.class}] #{e.message}"
16
+ Logging.logger.warn e.backtrace.join("\n")
17
+ set_result nil
14
18
  end
15
19
  end
16
20
  end
@@ -9,21 +9,25 @@ module Solargraph::LanguageServer::Message::Workspace
9
9
  include Solargraph::LanguageServer::UriHelpers
10
10
 
11
11
  def process
12
+ need_catalog = false
12
13
  # @param change [Hash]
13
14
  params['changes'].each do |change|
14
- # @todo Changes might need to be handled here even if the file is open
15
15
  if change['type'] == CREATED
16
- host.create change['uri'] #unless host.open?(change['uri'])
16
+ host.create change['uri']
17
+ need_catalog = true
17
18
  elsif change['type'] == CHANGED
18
- host.create change['uri'] #unless host.open?(change['uri'])
19
+ next if host.open?(change['uri'])
20
+ host.create change['uri']
21
+ need_catalog = true
19
22
  elsif change['type'] == DELETED
20
23
  host.delete change['uri']
24
+ need_catalog = true
21
25
  else
22
26
  set_error Solargraph::LanguageServer::ErrorCodes::INVALID_PARAMS, "Unknown change type ##{change['type']} for #{uri_to_file(change['uri'])}"
23
27
  end
24
28
  end
25
29
  # Force host to catalog libraries after file changes (see castwide/solargraph#139)
26
- host.catalog
30
+ host.catalog if need_catalog
27
31
  end
28
32
  end
29
33
  end
@@ -8,12 +8,12 @@ module Solargraph
8
8
  module Adapter
9
9
  def opening
10
10
  @host = Solargraph::LanguageServer::Host.new
11
+ @host.add_observer self
11
12
  @host.start
12
13
  @data_reader = Solargraph::LanguageServer::Transport::DataReader.new
13
14
  @data_reader.set_message_handler do |message|
14
15
  process message
15
16
  end
16
- start_timer
17
17
  end
18
18
 
19
19
  def closing
@@ -28,6 +28,15 @@ module Solargraph
28
28
  # the Backport API
29
29
  alias sending receiving
30
30
 
31
+ def update
32
+ if @host.stopped?
33
+ shutdown
34
+ else
35
+ tmp = @host.flush
36
+ write tmp unless tmp.empty?
37
+ end
38
+ end
39
+
31
40
  private
32
41
 
33
42
  # @param request [String]
@@ -35,20 +44,8 @@ module Solargraph
35
44
  def process request
36
45
  message = @host.receive(request)
37
46
  message.send_response
38
- tmp = @host.flush
39
- write tmp unless tmp.empty?
40
- end
41
-
42
- def start_timer
43
- Backport.prepare_interval 0.1 do |server|
44
- if @host.stopped?
45
- server.stop
46
- shutdown
47
- else
48
- tmp = @host.flush
49
- write tmp unless tmp.empty?
50
- end
51
- end
47
+ # tmp = @host.flush
48
+ # write tmp unless tmp.empty?
52
49
  end
53
50
 
54
51
  def shutdown
@@ -174,7 +174,7 @@ module Solargraph
174
174
  def definitions_at filename, line, column
175
175
  position = Position.new(line, column)
176
176
  cursor = Source::Cursor.new(checkout(filename), position)
177
- api_map.clip(cursor).define
177
+ api_map.clip(cursor).define.map { |pin| pin.realize(api_map) }
178
178
  end
179
179
 
180
180
  # Get signature suggestions for the method at the specified file and
@@ -232,7 +232,11 @@ module Solargraph
232
232
  # @param location [Location]
233
233
  # @return [Solargraph::Pin::Base]
234
234
  def locate_pins location
235
- api_map.locate_pins location
235
+ api_map.locate_pins(location).map { |pin| pin.realize(api_map) }
236
+ end
237
+
238
+ def locate_ref location
239
+ api_map.require_reference_at location
236
240
  end
237
241
 
238
242
  # Get an array of pins that match a path.
@@ -329,10 +333,23 @@ module Solargraph
329
333
  catalog
330
334
  result = []
331
335
  source = read(filename)
332
- workspace.config.reporters.each do |name|
333
- reporter = Diagnostics.reporter(name)
334
- raise DiagnosticsError, "Diagnostics reporter #{name} does not exist" if reporter.nil?
335
- result.concat reporter.new.diagnose(source, api_map)
336
+ repargs = {}
337
+ workspace.config.reporters.each do |line|
338
+ if line == 'all!'
339
+ Diagnostics.reporters.each do |reporter|
340
+ repargs[reporter] ||= []
341
+ end
342
+ else
343
+ args = line.split(':').map(&:strip)
344
+ name = args.shift
345
+ reporter = Diagnostics.reporter(name)
346
+ raise DiagnosticsError, "Diagnostics reporter #{name} does not exist" if reporter.nil?
347
+ repargs[reporter] ||= []
348
+ repargs[reporter].concat args
349
+ end
350
+ end
351
+ repargs.each_pair do |reporter, args|
352
+ result.concat reporter.new(*args.uniq).diagnose(source, api_map)
336
353
  end
337
354
  result
338
355
  end
@@ -27,5 +27,9 @@ module Solargraph
27
27
  return false unless other.is_a?(Location)
28
28
  filename == other.filename and range == other.range
29
29
  end
30
+
31
+ def inspect
32
+ "#<#{self.class} #{filename}, #{range.inspect}>"
33
+ end
30
34
  end
31
35
  end
@@ -2,6 +2,7 @@ module Solargraph
2
2
  # The namespace for pins used in maps.
3
3
  #
4
4
  module Pin
5
+ autoload :Common, 'solargraph/pin/common'
5
6
  autoload :Conversions, 'solargraph/pin/conversions'
6
7
  autoload :Base, 'solargraph/pin/base'
7
8
  autoload :BaseMethod, 'solargraph/pin/base_method'
@@ -15,10 +16,10 @@ module Solargraph
15
16
  autoload :GlobalVariable, 'solargraph/pin/global_variable'
16
17
  autoload :Constant, 'solargraph/pin/constant'
17
18
  autoload :Symbol, 'solargraph/pin/symbol'
19
+ autoload :Closure, 'solargraph/pin/closure'
18
20
  autoload :Namespace, 'solargraph/pin/namespace'
19
21
  autoload :Keyword, 'solargraph/pin/keyword'
20
- autoload :MethodParameter, 'solargraph/pin/method_parameter'
21
- autoload :BlockParameter, 'solargraph/pin/block_parameter'
22
+ autoload :Parameter, 'solargraph/pin/parameter'
22
23
  autoload :Reference, 'solargraph/pin/reference'
23
24
  autoload :Documenting, 'solargraph/pin/documenting'
24
25
  autoload :Block, 'solargraph/pin/block'
@@ -26,6 +27,7 @@ module Solargraph
26
27
  autoload :ProxyType, 'solargraph/pin/proxy_type'
27
28
  autoload :DuckMethod, 'solargraph/pin/duck_method'
28
29
  autoload :YardPin, 'solargraph/pin/yard_pin'
30
+ autoload :Singleton, 'solargraph/pin/singleton'
29
31
 
30
32
  ATTRIBUTE = 1
31
33
  CLASS_VARIABLE = 2
@@ -44,7 +46,9 @@ module Solargraph
44
46
  INCLUDE_REFERENCE = 15
45
47
  EXTEND_REFERENCE = 16
46
48
  METHOD_ALIAS = 17
49
+ OVERRIDE_REFERENCE = 18
47
50
 
48
- ROOT_PIN = Pin::Namespace.new(nil, '', '', '', :class, :public)
51
+ # ROOT_PIN = Pin::Namespace.new(nil, '', '', '', :class, :public)
52
+ ROOT_PIN = Pin::Namespace.new(type: :class, name: '', closure: nil)
49
53
  end
50
54
  end
@@ -1,14 +1,12 @@
1
1
  module Solargraph
2
2
  module Pin
3
3
  class Attribute < BaseMethod
4
- # @return [Symbol] :reader or :writer
4
+ # @return [::Symbol] :reader or :writer
5
5
  attr_reader :access
6
6
 
7
- def initialize location, namespace, name, comments, access, scope, visibility
8
- super(location, namespace, name, comments)
7
+ def initialize access: :reader, **splat
8
+ super(splat)
9
9
  @access = access
10
- @scope = scope
11
- @visibility = visibility
12
10
  end
13
11
 
14
12
  def kind
@@ -27,14 +25,17 @@ module Solargraph
27
25
  @path ||= namespace + (scope == :instance ? '#' : '.') + name
28
26
  end
29
27
 
30
- def parameters
31
- # Since attributes are generally equivalent to methods, treat
32
- # them as methods without parameters
33
- []
34
- end
35
-
36
- def parameter_names
37
- []
28
+ def probe api_map
29
+ types = []
30
+ varname = "@#{name.gsub(/=$/, '')}"
31
+ pins = api_map.get_instance_variable_pins(binder.namespace, binder.scope).select { |iv| iv.name == varname }
32
+ pins.each do |pin|
33
+ type = pin.typify(api_map)
34
+ type = pin.probe(api_map) if type.undefined?
35
+ types.push type if type.defined?
36
+ end
37
+ return ComplexType::UNDEFINED if types.empty?
38
+ ComplexType.try_parse(*types.map(&:tag).uniq)
38
39
  end
39
40
  end
40
41
  end
@@ -3,18 +3,16 @@ module Solargraph
3
3
  # The base class for map pins.
4
4
  #
5
5
  class Base
6
+ include Common
6
7
  include Conversions
7
8
  include Documenting
8
9
 
10
+ # @return [YARD::CodeObjects::Base]
11
+ attr_reader :code_object
12
+
9
13
  # @return [Solargraph::Location]
10
14
  attr_reader :location
11
15
 
12
- # The namespace in which this pin is defined.
13
- # The root namespace is an empty string.
14
- #
15
- # @return [String]
16
- attr_reader :namespace
17
-
18
16
  # @return [String]
19
17
  attr_reader :name
20
18
 
@@ -25,12 +23,14 @@ module Solargraph
25
23
  attr_reader :path
26
24
 
27
25
  # @param location [Solargraph::Location]
28
- # @param namespace [String]
26
+ # @param kind [Integer]
27
+ # @param closure [String]
29
28
  # @param name [String]
30
29
  # @param comments [String]
31
- def initialize location, namespace, name, comments
30
+ def initialize location: nil, kind: KEYWORD, closure: nil, name: '', comments: ''
32
31
  @location = location
33
- @namespace = namespace
32
+ @kind = kind
33
+ @closure = closure
34
34
  @name = name
35
35
  @comments = comments
36
36
  end
@@ -65,11 +65,6 @@ module Solargraph
65
65
  false
66
66
  end
67
67
 
68
- # @return [ComplexType]
69
- def context
70
- @context ||= ComplexType.try_parse(namespace || '')
71
- end
72
-
73
68
  # Pin equality is determined using the #nearly? method and also
74
69
  # requiring both pins to have the same location.
75
70
  #
@@ -86,26 +81,19 @@ module Solargraph
86
81
  # @return [Boolean]
87
82
  def nearly? other
88
83
  self.class == other.class &&
89
- namespace == other.namespace &&
90
84
  name == other.name &&
85
+ (closure == other.closure || (closure && closure.nearly?(other.closure))) &&
91
86
  (comments == other.comments ||
92
87
  (((maybe_directives? == false && other.maybe_directives? == false) || compare_directives(directives, other.directives)) &&
93
88
  compare_docstring_tags(docstring, other.docstring))
94
89
  )
95
90
  end
96
91
 
97
- # An alias for return_complex_type.
92
+ # The pin's return type.
98
93
  #
99
94
  # @return [ComplexType]
100
95
  def return_type
101
- return_complex_type
102
- end
103
-
104
- # All of the pin's return types as an array of ComplexTypes.
105
- #
106
- # @return [ComplexType]
107
- def return_complex_type
108
- @return_complex_type ||= ComplexType::UNDEFINED
96
+ @return_type ||= ComplexType::UNDEFINED
109
97
  end
110
98
 
111
99
  # @return [YARD::Docstring]
@@ -152,7 +140,7 @@ module Solargraph
152
140
  # @param api_map [ApiMap]
153
141
  # @return [ComplexType]
154
142
  def typify api_map
155
- return_complex_type.qualify(api_map, namespace)
143
+ return_type.qualify(api_map, namespace)
156
144
  end
157
145
 
158
146
  # Infer the pin's return type via static code analysis.
@@ -182,10 +170,11 @@ module Solargraph
182
170
  def try_merge! pin
183
171
  return false unless nearly?(pin)
184
172
  @location = pin.location
173
+ @closure = pin.closure
185
174
  return true if comments == pin.comments
186
175
  @comments = pin.comments
187
176
  @docstring = pin.docstring
188
- @return_complex_type = pin.return_complex_type
177
+ @return_type = pin.return_type
189
178
  @documentation = nil
190
179
  @deprecated = nil
191
180
  reset_conversions
@@ -196,6 +185,23 @@ module Solargraph
196
185
  @proxied ||= false
197
186
  end
198
187
 
188
+ def probed?
189
+ @probed ||= false
190
+ end
191
+
192
+ # @param api_map [ApiMap]
193
+ # @return [self]
194
+ def realize api_map
195
+ return self if return_type.defined?
196
+ type = typify(api_map)
197
+ return proxy(type) if type.defined?
198
+ type = probe(api_map)
199
+ return self if type.undefined?
200
+ result = proxy(type)
201
+ result.probed = true
202
+ result
203
+ end
204
+
199
205
  # Return a proxy for this pin with the specified return type. Other than
200
206
  # the return type and the #proxied? setting, the proxy should be a clone
201
207
  # of the original.
@@ -204,18 +210,25 @@ module Solargraph
204
210
  # @return [self]
205
211
  def proxy return_type
206
212
  result = dup
207
- result.return_complex_type = return_type
213
+ result.return_type = return_type
208
214
  result.proxied = true
209
215
  result
210
216
  end
211
217
 
218
+ def inspect
219
+ "#<#{self.class} at #{self.location.inspect}>"
220
+ end
221
+
212
222
  protected
213
223
 
224
+ # @return [Boolean]
225
+ attr_writer :probed
226
+
214
227
  # @return [Boolean]
215
228
  attr_writer :proxied
216
229
 
217
230
  # @return [ComplexType]
218
- attr_writer :return_complex_type
231
+ attr_writer :return_type
219
232
 
220
233
  private
221
234
 
@@ -238,7 +251,7 @@ module Solargraph
238
251
  #
239
252
  # @param d1 [YARD::Docstring]
240
253
  # @param d2 [YARD::Docstring]
241
- # @return [boolean]
254
+ # @return [Boolean]
242
255
  def compare_docstring_tags d1, d2
243
256
  return false if d1.tags.length != d2.tags.length
244
257
  d1.tags.each_index do |i|
@@ -247,26 +260,26 @@ module Solargraph
247
260
  true
248
261
  end
249
262
 
250
- # @param d1 [Array<YARD::Tags::Directive>]
251
- # @param d2 [Array<YARD::Tags::Directive>]
263
+ # @param dir1 [Array<YARD::Tags::Directive>]
264
+ # @param dir2 [Array<YARD::Tags::Directive>]
252
265
  # @return [Boolean]
253
- def compare_directives d1, d2
254
- return false if d1.length != d2.length
255
- d1.each_index do |i|
256
- return false unless compare_tags(d1[i].tag, d2[i].tag)
266
+ def compare_directives dir1, dir2
267
+ return false if dir1.length != dir2.length
268
+ dir1.each_index do |i|
269
+ return false unless compare_tags(dir1[i].tag, dir2[i].tag)
257
270
  end
258
271
  true
259
272
  end
260
273
 
261
- # @param t1 [YARD::Tags::Tag]
262
- # @param t2 [YARD::Tags::Tag]
274
+ # @param tag1 [YARD::Tags::Tag]
275
+ # @param tag2 [YARD::Tags::Tag]
263
276
  # @return [Boolean]
264
- def compare_tags t1, t2
265
- t1.class == t2.class &&
266
- t1.tag_name == t2.tag_name &&
267
- t1.text == t2.text &&
268
- t1.name == t2.name &&
269
- t1.types == t2.types
277
+ def compare_tags tag1, tag2
278
+ tag1.class == tag2.class &&
279
+ tag1.tag_name == tag2.tag_name &&
280
+ tag1.text == tag2.text &&
281
+ tag1.name == tag2.name &&
282
+ tag1.types == tag2.types
270
283
  end
271
284
 
272
285
  # @return [Array<YARD::Tags::Handlers::Directive>]