solargraph 0.47.2 → 0.53.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/plugins.yml +40 -0
  4. data/.github/workflows/rspec.yml +4 -8
  5. data/.github/workflows/typecheck.yml +34 -0
  6. data/.yardopts +2 -2
  7. data/CHANGELOG.md +137 -3
  8. data/LICENSE +1 -1
  9. data/README.md +19 -16
  10. data/SPONSORS.md +2 -9
  11. data/lib/solargraph/api_map/cache.rb +60 -20
  12. data/lib/solargraph/api_map/source_to_yard.rb +17 -10
  13. data/lib/solargraph/api_map/store.rb +60 -12
  14. data/lib/solargraph/api_map.rb +171 -99
  15. data/lib/solargraph/bench.rb +3 -2
  16. data/lib/solargraph/cache.rb +77 -0
  17. data/lib/solargraph/complex_type/type_methods.rb +61 -12
  18. data/lib/solargraph/complex_type/unique_type.rb +193 -16
  19. data/lib/solargraph/complex_type.rb +113 -10
  20. data/lib/solargraph/convention/rakefile.rb +17 -0
  21. data/lib/solargraph/convention.rb +2 -3
  22. data/lib/solargraph/converters/dd.rb +5 -0
  23. data/lib/solargraph/converters/dl.rb +3 -0
  24. data/lib/solargraph/converters/dt.rb +3 -0
  25. data/lib/solargraph/diagnostics/rubocop.rb +23 -8
  26. data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -1
  27. data/lib/solargraph/diagnostics/type_check.rb +1 -0
  28. data/lib/solargraph/diagnostics.rb +2 -2
  29. data/lib/solargraph/doc_map.rb +171 -0
  30. data/lib/solargraph/gem_pins.rb +64 -0
  31. data/lib/solargraph/language_server/host/cataloger.rb +2 -1
  32. data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
  33. data/lib/solargraph/language_server/host/dispatch.rb +15 -5
  34. data/lib/solargraph/language_server/host/message_worker.rb +4 -0
  35. data/lib/solargraph/language_server/host/sources.rb +7 -4
  36. data/lib/solargraph/language_server/host.rb +50 -26
  37. data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
  38. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
  39. data/lib/solargraph/language_server/message/extended/download_core.rb +1 -5
  40. data/lib/solargraph/language_server/message/initialize.rb +13 -0
  41. data/lib/solargraph/language_server/message/initialized.rb +1 -0
  42. data/lib/solargraph/language_server/message/text_document/document_symbol.rb +4 -1
  43. data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -4
  44. data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
  45. data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -6
  46. data/lib/solargraph/language_server/message/text_document/type_definition.rb +24 -0
  47. data/lib/solargraph/language_server/message/text_document.rb +1 -1
  48. data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
  49. data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +10 -3
  50. data/lib/solargraph/language_server/message.rb +1 -0
  51. data/lib/solargraph/language_server/transport/adapter.rb +16 -1
  52. data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
  53. data/lib/solargraph/library.rb +124 -37
  54. data/lib/solargraph/location.rb +1 -0
  55. data/lib/solargraph/page.rb +6 -0
  56. data/lib/solargraph/parser/comment_ripper.rb +4 -0
  57. data/lib/solargraph/parser/node_methods.rb +47 -7
  58. data/lib/solargraph/parser/node_processor/base.rb +9 -0
  59. data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -5
  60. data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
  61. data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +57 -41
  62. data/lib/solargraph/parser/parser_gem/node_methods.rb +499 -0
  63. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
  64. data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +53 -0
  65. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
  66. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
  67. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +14 -4
  68. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
  69. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/def_node.rb +7 -20
  70. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
  71. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
  72. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
  73. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
  74. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
  75. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
  76. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
  77. data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +42 -0
  78. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
  79. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sym_node.rb +1 -1
  80. data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
  81. data/lib/solargraph/parser/parser_gem.rb +12 -0
  82. data/lib/solargraph/parser/region.rb +1 -1
  83. data/lib/solargraph/parser/snippet.rb +2 -0
  84. data/lib/solargraph/parser.rb +9 -10
  85. data/lib/solargraph/pin/base.rb +69 -11
  86. data/lib/solargraph/pin/base_variable.rb +8 -4
  87. data/lib/solargraph/pin/block.rb +21 -28
  88. data/lib/solargraph/pin/closure.rb +17 -2
  89. data/lib/solargraph/pin/common.rb +7 -3
  90. data/lib/solargraph/pin/conversions.rb +34 -8
  91. data/lib/solargraph/pin/delegated_method.rb +97 -0
  92. data/lib/solargraph/pin/documenting.rb +25 -34
  93. data/lib/solargraph/pin/instance_variable.rb +4 -0
  94. data/lib/solargraph/pin/local_variable.rb +13 -1
  95. data/lib/solargraph/pin/method.rb +270 -16
  96. data/lib/solargraph/pin/namespace.rb +17 -1
  97. data/lib/solargraph/pin/parameter.rb +52 -17
  98. data/lib/solargraph/pin/reference/override.rb +2 -2
  99. data/lib/solargraph/pin/reference.rb +8 -0
  100. data/lib/solargraph/pin/search.rb +4 -4
  101. data/lib/solargraph/pin/signature.rb +143 -0
  102. data/lib/solargraph/pin.rb +2 -1
  103. data/lib/solargraph/range.rb +4 -6
  104. data/lib/solargraph/rbs_map/conversions.rb +601 -0
  105. data/lib/solargraph/rbs_map/core_fills.rb +47 -0
  106. data/lib/solargraph/rbs_map/core_map.rb +28 -0
  107. data/lib/solargraph/rbs_map/stdlib_map.rb +33 -0
  108. data/lib/solargraph/rbs_map.rb +84 -0
  109. data/lib/solargraph/shell.rb +69 -48
  110. data/lib/solargraph/source/chain/array.rb +32 -0
  111. data/lib/solargraph/source/chain/block_symbol.rb +13 -0
  112. data/lib/solargraph/source/chain/call.rb +125 -61
  113. data/lib/solargraph/source/chain/constant.rb +15 -1
  114. data/lib/solargraph/source/chain/if.rb +23 -0
  115. data/lib/solargraph/source/chain/link.rb +8 -2
  116. data/lib/solargraph/source/chain/or.rb +1 -1
  117. data/lib/solargraph/source/chain/z_super.rb +3 -3
  118. data/lib/solargraph/source/chain.rb +44 -14
  119. data/lib/solargraph/source/change.rb +3 -0
  120. data/lib/solargraph/source/cursor.rb +2 -0
  121. data/lib/solargraph/source/source_chainer.rb +8 -5
  122. data/lib/solargraph/source.rb +18 -19
  123. data/lib/solargraph/source_map/clip.rb +30 -23
  124. data/lib/solargraph/source_map/mapper.rb +20 -5
  125. data/lib/solargraph/source_map.rb +28 -13
  126. data/lib/solargraph/type_checker/checks.rb +10 -2
  127. data/lib/solargraph/type_checker.rb +201 -98
  128. data/lib/solargraph/version.rb +1 -1
  129. data/lib/solargraph/views/environment.erb +2 -2
  130. data/lib/solargraph/workspace/config.rb +14 -11
  131. data/lib/solargraph/workspace.rb +28 -17
  132. data/lib/solargraph/yard_map/cache.rb +6 -0
  133. data/lib/solargraph/yard_map/helpers.rb +1 -1
  134. data/lib/solargraph/yard_map/mapper/to_method.rb +18 -5
  135. data/lib/solargraph/yard_map/mapper.rb +1 -1
  136. data/lib/solargraph/yard_map/to_method.rb +11 -4
  137. data/lib/solargraph/yard_map.rb +1 -443
  138. data/lib/solargraph/yard_tags.rb +20 -0
  139. data/lib/solargraph/yardoc.rb +52 -0
  140. data/lib/solargraph.rb +8 -6
  141. data/solargraph.gemspec +19 -8
  142. metadata +162 -98
  143. data/.travis.yml +0 -19
  144. data/lib/solargraph/api_map/bundler_methods.rb +0 -22
  145. data/lib/solargraph/compat.rb +0 -37
  146. data/lib/solargraph/convention/rspec.rb +0 -30
  147. data/lib/solargraph/documentor.rb +0 -76
  148. data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
  149. data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
  150. data/lib/solargraph/parser/legacy/node_processors/args_node.rb +0 -35
  151. data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
  152. data/lib/solargraph/parser/legacy/node_processors/def_node.rb +0 -63
  153. data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +0 -21
  154. data/lib/solargraph/parser/legacy/node_processors.rb +0 -54
  155. data/lib/solargraph/parser/legacy.rb +0 -12
  156. data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -144
  157. data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
  158. data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -315
  159. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
  160. data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
  161. data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -22
  162. data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
  163. data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -57
  164. data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
  165. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
  166. data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
  167. data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
  168. data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
  169. data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
  170. data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
  171. data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
  172. data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -45
  173. data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -21
  174. data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
  175. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -277
  176. data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +0 -18
  177. data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -63
  178. data/lib/solargraph/parser/rubyvm.rb +0 -40
  179. data/lib/solargraph/yard_map/core_docs.rb +0 -170
  180. data/lib/solargraph/yard_map/core_fills.rb +0 -208
  181. data/lib/solargraph/yard_map/core_gen.rb +0 -76
  182. data/lib/solargraph/yard_map/rdoc_to_yard.rb +0 -140
  183. data/lib/solargraph/yard_map/stdlib_fills.rb +0 -43
  184. data/lib/yard-solargraph.rb +0 -33
  185. data/yardoc/2.2.2.tar.gz +0 -0
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
3
 
5
4
  module Solargraph
6
5
  class ApiMap
7
6
  class Store
8
- # @return [Enumerable<Solargraph::Pin::Base>]
7
+ # @return [Array<Solargraph::Pin::Base>]
9
8
  attr_reader :pins
10
9
 
11
10
  # @param pins [Enumerable<Solargraph::Pin::Base>]
@@ -26,7 +25,7 @@ module Solargraph
26
25
  # @param fqns [String]
27
26
  # @param scope [Symbol]
28
27
  # @param visibility [Array<Symbol>]
29
- # @return [Enumerable<Solargraph::Pin::Base>]
28
+ # @return [Enumerable<Solargraph::Pin::Method>]
30
29
  def get_methods fqns, scope: :instance, visibility: [:public]
31
30
  namespace_children(fqns).select do |pin|
32
31
  pin.is_a?(Pin::Method) && pin.scope == scope && visibility.include?(pin.visibility)
@@ -61,7 +60,7 @@ module Solargraph
61
60
  end
62
61
 
63
62
  # @param path [String]
64
- # @return [Enumerable<Solargraph::Pin::Base>]
63
+ # @return [Array<Solargraph::Pin::Base>]
65
64
  def get_path_pins path
66
65
  path_pin_hash[path] || []
67
66
  end
@@ -117,7 +116,7 @@ module Solargraph
117
116
  result
118
117
  end
119
118
 
120
- # @return [Hash]
119
+ # @return [Hash{String => YARD::Tags::MacroDirective}]
121
120
  def named_macros
122
121
  @named_macros ||= begin
123
122
  result = {}
@@ -144,11 +143,11 @@ module Solargraph
144
143
  # @param klass [Class]
145
144
  # @return [Enumerable<Solargraph::Pin::Base>]
146
145
  def pins_by_class klass
147
- @pin_select_cache[klass] ||= @pin_class_hash.each_with_object(Set.new) { |(key, o), n| n.merge(o) if key <= klass }
146
+ # @type [Set<Solargraph::Pin::Base>]
147
+ s = Set.new
148
+ @pin_select_cache[klass] ||= @pin_class_hash.each_with_object(s) { |(key, o), n| n.merge(o) if key <= klass }
148
149
  end
149
150
 
150
- private
151
-
152
151
  # @param fqns [String]
153
152
  # @return [Array<Solargraph::Pin::Namespace>]
154
153
  def fqns_pins fqns
@@ -164,6 +163,9 @@ module Solargraph
164
163
  fqns_pins_map[[base, name]]
165
164
  end
166
165
 
166
+ private
167
+
168
+ # @return [Hash{Array(String, String) => Array<Pin::Namespace>}]
167
169
  def fqns_pins_map
168
170
  @fqns_pins_map ||= Hash.new do |h, (base, name)|
169
171
  value = namespace_children(base).select { |pin| pin.name == name && pin.is_a?(Pin::Namespace) }
@@ -176,18 +178,22 @@ module Solargraph
176
178
  pins_by_class(Pin::Symbol)
177
179
  end
178
180
 
181
+ # @return [Hash{String => Enumerable<String>}]
179
182
  def superclass_references
180
183
  @superclass_references ||= {}
181
184
  end
182
185
 
186
+ # @return [Hash{String => Array<String>}]
183
187
  def include_references
184
188
  @include_references ||= {}
185
189
  end
186
190
 
191
+ # @return [Hash{String => Array<String>}]
187
192
  def prepend_references
188
193
  @prepend_references ||= {}
189
194
  end
190
195
 
196
+ # @return [Hash{String => Array<String>}]
191
197
  def extend_references
192
198
  @extend_references ||= {}
193
199
  end
@@ -198,31 +204,58 @@ module Solargraph
198
204
  namespace_map[name] || []
199
205
  end
200
206
 
201
- # @return [Hash]
207
+ # @return [Hash{String => Enumerable<Pin::Base>}
202
208
  def namespace_map
203
209
  @namespace_map ||= {}
204
210
  end
205
211
 
212
+ # @return [Enumerable<Pin::InstanceVariable>]
206
213
  def all_instance_variables
207
214
  pins_by_class(Pin::InstanceVariable)
208
215
  end
209
216
 
217
+ # @return [Hash{String => Array<Pin::Base>}]
210
218
  def path_pin_hash
211
219
  @path_pin_hash ||= {}
212
220
  end
213
221
 
222
+ # Add references to a map
223
+ #
224
+ # @param h [Hash{String => Pin:Base}]
225
+ # @param reference_pin [Pin::Reference]
226
+ #
227
+ # @return [void]
228
+ def store_parametric_reference(h, reference_pin)
229
+ referenced_ns = reference_pin.name
230
+ referenced_tag_params = reference_pin.generic_values
231
+ referenced_tag = referenced_ns +
232
+ if referenced_tag_params && referenced_tag_params.length > 0
233
+ "<" + referenced_tag_params.join(', ') + ">"
234
+ else
235
+ ''
236
+ end
237
+ referencing_ns = reference_pin.namespace
238
+ h[referencing_ns] ||= []
239
+ h[referencing_ns].push referenced_tag
240
+ end
241
+
214
242
  # @return [void]
215
243
  def index
216
244
  set = pins.to_set
217
245
  @pin_class_hash = set.classify(&:class).transform_values(&:to_a)
246
+ # @type [Hash{Class => Enumerable<Solargraph::Pin::Base>}]
218
247
  @pin_select_cache = {}
219
248
  @namespace_map = set.classify(&:namespace)
220
249
  @path_pin_hash = set.classify(&:path)
221
250
  @namespaces = @path_pin_hash.keys.compact.to_set
222
251
  pins_by_class(Pin::Reference::Include).each do |pin|
223
- include_references[pin.namespace] ||= []
224
- include_references[pin.namespace].push pin.name
252
+ store_parametric_reference(include_references, pin)
225
253
  end
254
+ # @todo move the rest of these reference pins over to use
255
+ # generic types, adding rbs_map/conversions.rb code to
256
+ # populate type parameters and adding related specs ensuring
257
+ # the generics get resolved, along with any api_map.rb
258
+ # changes needed in
226
259
  pins_by_class(Pin::Reference::Prepend).each do |pin|
227
260
  prepend_references[pin.namespace] ||= []
228
261
  prepend_references[pin.namespace].push pin.name
@@ -247,10 +280,25 @@ module Solargraph
247
280
  end
248
281
  ovr.tags.each do |tag|
249
282
  pin.docstring.add_tag(tag)
250
- new_pin.docstring.add_tag(tag) if new_pin
283
+ redefine_return_type pin, tag
284
+ if new_pin
285
+ new_pin.docstring.add_tag(tag)
286
+ redefine_return_type new_pin, tag
287
+ end
251
288
  end
252
289
  end
253
290
  end
291
+
292
+ # @param pin [Pin::Base]
293
+ # @param tag [String]
294
+ # @return [void]
295
+ def redefine_return_type pin, tag
296
+ return unless pin && tag.tag_name == 'return'
297
+ pin.instance_variable_set(:@return_type, ComplexType.try_parse(tag.type))
298
+ pin.signatures.each do |sig|
299
+ sig.instance_variable_set(:@return_type, ComplexType.try_parse(tag.type))
300
+ end
301
+ end
254
302
  end
255
303
  end
256
304
  end