solargraph 0.51.2 → 0.53.0

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 (162) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/plugins.yml +40 -0
  3. data/.github/workflows/rspec.yml +1 -3
  4. data/.github/workflows/typecheck.yml +34 -0
  5. data/.yardopts +2 -2
  6. data/CHANGELOG.md +55 -5
  7. data/README.md +13 -16
  8. data/SPONSORS.md +1 -7
  9. data/lib/solargraph/api_map/cache.rb +60 -20
  10. data/lib/solargraph/api_map/store.rb +47 -11
  11. data/lib/solargraph/api_map.rb +161 -95
  12. data/lib/solargraph/bench.rb +2 -2
  13. data/lib/solargraph/cache.rb +29 -5
  14. data/lib/solargraph/complex_type/type_methods.rb +54 -9
  15. data/lib/solargraph/complex_type/unique_type.rb +155 -58
  16. data/lib/solargraph/complex_type.rb +73 -16
  17. data/lib/solargraph/convention.rb +0 -1
  18. data/lib/solargraph/converters/dd.rb +5 -0
  19. data/lib/solargraph/converters/dl.rb +3 -0
  20. data/lib/solargraph/converters/dt.rb +3 -0
  21. data/lib/solargraph/diagnostics/rubocop.rb +8 -7
  22. data/lib/solargraph/diagnostics/rubocop_helpers.rb +1 -0
  23. data/lib/solargraph/diagnostics/type_check.rb +1 -0
  24. data/lib/solargraph/diagnostics.rb +2 -2
  25. data/lib/solargraph/doc_map.rb +146 -0
  26. data/lib/solargraph/gem_pins.rb +64 -0
  27. data/lib/solargraph/language_server/host/cataloger.rb +1 -0
  28. data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
  29. data/lib/solargraph/language_server/host/dispatch.rb +10 -4
  30. data/lib/solargraph/language_server/host/message_worker.rb +4 -0
  31. data/lib/solargraph/language_server/host/sources.rb +7 -4
  32. data/lib/solargraph/language_server/host.rb +15 -6
  33. data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
  34. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
  35. data/lib/solargraph/language_server/message/initialize.rb +5 -2
  36. data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
  37. data/lib/solargraph/language_server/message/text_document.rb +0 -1
  38. data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
  39. data/lib/solargraph/language_server/transport/adapter.rb +16 -1
  40. data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
  41. data/lib/solargraph/library.rb +70 -16
  42. data/lib/solargraph/location.rb +1 -0
  43. data/lib/solargraph/parser/comment_ripper.rb +4 -0
  44. data/lib/solargraph/parser/node_methods.rb +47 -7
  45. data/lib/solargraph/parser/node_processor/base.rb +9 -0
  46. data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -5
  47. data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
  48. data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +49 -36
  49. data/lib/solargraph/parser/parser_gem/node_methods.rb +499 -0
  50. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
  51. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/args_node.rb +4 -1
  52. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
  53. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
  54. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +2 -2
  55. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
  56. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/def_node.rb +1 -1
  57. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
  58. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
  59. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
  60. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
  61. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
  62. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
  63. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
  64. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sclass_node.rb +1 -1
  65. data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
  66. data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/sym_node.rb +1 -1
  67. data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
  68. data/lib/solargraph/parser/parser_gem.rb +12 -0
  69. data/lib/solargraph/parser/region.rb +1 -1
  70. data/lib/solargraph/parser/snippet.rb +2 -0
  71. data/lib/solargraph/parser.rb +8 -9
  72. data/lib/solargraph/pin/base.rb +64 -9
  73. data/lib/solargraph/pin/base_variable.rb +6 -2
  74. data/lib/solargraph/pin/block.rb +13 -8
  75. data/lib/solargraph/pin/closure.rb +17 -2
  76. data/lib/solargraph/pin/common.rb +7 -3
  77. data/lib/solargraph/pin/conversions.rb +33 -3
  78. data/lib/solargraph/pin/delegated_method.rb +1 -1
  79. data/lib/solargraph/pin/documenting.rb +25 -34
  80. data/lib/solargraph/pin/instance_variable.rb +4 -0
  81. data/lib/solargraph/pin/local_variable.rb +13 -1
  82. data/lib/solargraph/pin/method.rb +169 -18
  83. data/lib/solargraph/pin/namespace.rb +18 -5
  84. data/lib/solargraph/pin/parameter.rb +44 -14
  85. data/lib/solargraph/pin/reference/override.rb +2 -2
  86. data/lib/solargraph/pin/reference.rb +8 -0
  87. data/lib/solargraph/pin/search.rb +3 -3
  88. data/lib/solargraph/pin/signature.rb +123 -3
  89. data/lib/solargraph/pin.rb +0 -1
  90. data/lib/solargraph/range.rb +2 -2
  91. data/lib/solargraph/rbs_map/conversions.rb +287 -45
  92. data/lib/solargraph/rbs_map/core_fills.rb +6 -29
  93. data/lib/solargraph/rbs_map/core_map.rb +2 -1
  94. data/lib/solargraph/rbs_map/core_signs.rb +2 -0
  95. data/lib/solargraph/rbs_map/stdlib_map.rb +2 -8
  96. data/lib/solargraph/rbs_map.rb +20 -11
  97. data/lib/solargraph/shell.rb +62 -59
  98. data/lib/solargraph/source/chain/array.rb +32 -0
  99. data/lib/solargraph/source/chain/block_symbol.rb +13 -0
  100. data/lib/solargraph/source/chain/call.rb +99 -46
  101. data/lib/solargraph/source/chain/constant.rb +15 -1
  102. data/lib/solargraph/source/chain/if.rb +23 -0
  103. data/lib/solargraph/source/chain/link.rb +8 -2
  104. data/lib/solargraph/source/chain/or.rb +1 -1
  105. data/lib/solargraph/source/chain/z_super.rb +3 -3
  106. data/lib/solargraph/source/chain.rb +29 -14
  107. data/lib/solargraph/source/change.rb +3 -0
  108. data/lib/solargraph/source/cursor.rb +2 -0
  109. data/lib/solargraph/source/source_chainer.rb +8 -5
  110. data/lib/solargraph/source.rb +18 -19
  111. data/lib/solargraph/source_map/clip.rb +11 -23
  112. data/lib/solargraph/source_map/mapper.rb +12 -1
  113. data/lib/solargraph/source_map.rb +15 -5
  114. data/lib/solargraph/type_checker/checks.rb +10 -2
  115. data/lib/solargraph/type_checker.rb +92 -26
  116. data/lib/solargraph/version.rb +1 -1
  117. data/lib/solargraph/workspace/config.rb +8 -6
  118. data/lib/solargraph/workspace.rb +3 -2
  119. data/lib/solargraph/yard_map/cache.rb +6 -0
  120. data/lib/solargraph/yard_map/helpers.rb +1 -1
  121. data/lib/solargraph/yard_map/mapper/to_method.rb +11 -1
  122. data/lib/solargraph/yard_map/mapper.rb +1 -1
  123. data/lib/solargraph/yard_map/to_method.rb +11 -4
  124. data/lib/solargraph/yard_map.rb +1 -292
  125. data/lib/solargraph/yard_tags.rb +20 -0
  126. data/lib/solargraph/yardoc.rb +52 -0
  127. data/lib/solargraph.rb +6 -4
  128. data/solargraph.gemspec +3 -2
  129. metadata +51 -58
  130. data/lib/solargraph/api_map/bundler_methods.rb +0 -22
  131. data/lib/solargraph/documentor.rb +0 -76
  132. data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
  133. data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
  134. data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
  135. data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +0 -18
  136. data/lib/solargraph/parser/legacy/node_processors.rb +0 -55
  137. data/lib/solargraph/parser/legacy.rb +0 -12
  138. data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -153
  139. data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
  140. data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -317
  141. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
  142. data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
  143. data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -33
  144. data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
  145. data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +0 -75
  146. data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -68
  147. data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
  148. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
  149. data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
  150. data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
  151. data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
  152. data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
  153. data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
  154. data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
  155. data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -51
  156. data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -32
  157. data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
  158. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -279
  159. data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -64
  160. data/lib/solargraph/parser/rubyvm/node_wrapper.rb +0 -47
  161. data/lib/solargraph/parser/rubyvm.rb +0 -40
  162. data/lib/yard-solargraph.rb +0 -33
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yard'
4
- require 'yard-solargraph'
5
- require 'rubygems/package'
6
- require 'set'
4
+ require 'solargraph/yard_tags'
7
5
 
8
6
  module Solargraph
9
7
  # The YardMap provides access to YARD documentation for the Ruby core, the
@@ -14,296 +12,7 @@ module Solargraph
14
12
 
15
13
  autoload :Cache, 'solargraph/yard_map/cache'
16
14
  autoload :Mapper, 'solargraph/yard_map/mapper'
17
- autoload :RdocToYard, 'solargraph/yard_map/rdoc_to_yard'
18
15
  autoload :Helpers, 'solargraph/yard_map/helpers'
19
16
  autoload :ToMethod, 'solargraph/yard_map/to_method'
20
-
21
- include ApiMap::BundlerMethods
22
-
23
- # @return [Boolean]
24
- attr_writer :with_dependencies
25
-
26
- # @param required [Array<String>, Set<String>]
27
- # @param directory [String]
28
- # @param source_gems [Array<String>, Set<String>]
29
- # @param with_dependencies [Boolean]
30
- def initialize(required: [], directory: '', source_gems: [], with_dependencies: true)
31
- @with_dependencies = with_dependencies
32
- change required.to_set, directory, source_gems.to_set
33
- end
34
-
35
- # @return [Array<Solargraph::Pin::Base>]
36
- def pins
37
- @pins ||= []
38
- end
39
-
40
- def with_dependencies?
41
- @with_dependencies ||= true unless @with_dependencies == false
42
- @with_dependencies
43
- end
44
-
45
- # @param new_requires [Set<String>] Required paths to use for loading gems
46
- # @param new_directory [String] The workspace directory
47
- # @param new_source_gems [Set<String>] Gems under local development (i.e., part of the workspace)
48
- # @return [Boolean]
49
- def change new_requires, new_directory, new_source_gems
50
- return false if new_requires == base_required && new_directory == @directory && new_source_gems == @source_gems
51
- @gem_paths = {}
52
- base_required.replace new_requires
53
- required.replace new_requires
54
- # HACK: Hardcoded YAML handling
55
- required.add 'psych' if new_requires.include?('yaml')
56
- @source_gems = new_source_gems
57
- @directory = new_directory
58
- process_requires
59
- @rebindable_method_names = nil
60
- @pin_class_hash = nil
61
- @pin_select_cache = {}
62
- pins.each { |p| p.source = :yard }
63
- true
64
- end
65
-
66
- # @return [Set<String>]
67
- def rebindable_method_names
68
- @rebindable_method_names ||= pins_by_class(Pin::Method)
69
- .select { |pin| pin.comments && pin.comments.include?('@yieldself') }
70
- .map(&:name)
71
- .concat(['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec', 'define_method'])
72
- .to_set
73
- end
74
-
75
- # @return [Array<String>]
76
- def yardocs
77
- @yardocs ||= []
78
- end
79
-
80
- # @return [Set<String>]
81
- def required
82
- @required ||= Set.new
83
- end
84
-
85
- # @return [Array<String>]
86
- def unresolved_requires
87
- @unresolved_requires ||= []
88
- end
89
-
90
- # @return [Array<String>]
91
- def missing_docs
92
- @missing_docs ||= []
93
- end
94
-
95
- # @param y [String]
96
- # @return [YARD::Registry]
97
- def load_yardoc y
98
- if y.is_a?(Array)
99
- YARD::Registry.load y, true
100
- else
101
- YARD::Registry.load! y
102
- end
103
- rescue StandardError => e
104
- Solargraph::Logging.logger.warn "Error loading yardoc '#{y}' #{e.class} #{e.message}"
105
- yardocs.delete y
106
- nil
107
- end
108
-
109
- # @param path [String]
110
- # @return [Pin::Base]
111
- def path_pin path
112
- pins.select { |p| p.path == path }.first
113
- end
114
-
115
- # Get the location of a file referenced by a require path.
116
- #
117
- # @param path [String]
118
- # @return [Location]
119
- def require_reference path
120
- # @type [Gem::Specification]
121
- spec = spec_for_require(path)
122
- spec.full_require_paths.each do |rp|
123
- file = File.join(rp, "#{path}.rb")
124
- next unless File.file?(file)
125
- return Solargraph::Location.new(file, Solargraph::Range.from_to(0, 0, 0, 0))
126
- end
127
- nil
128
- rescue Gem::LoadError
129
- nil
130
- end
131
-
132
- def base_required
133
- @base_required ||= Set.new
134
- end
135
-
136
- def directory
137
- @directory ||= ''
138
- end
139
-
140
- private
141
-
142
- # @return [YardMap::Cache]
143
- def cache
144
- @cache ||= YardMap::Cache.new
145
- end
146
-
147
- # @return [Hash]
148
- def pin_class_hash
149
- @pin_class_hash ||= pins.to_set.classify(&:class).transform_values(&:to_a)
150
- end
151
-
152
- # @return [Array<Pin::Base>]
153
- def pins_by_class klass
154
- @pin_select_cache[klass] ||= pin_class_hash.select { |key, _| key <= klass }.values.flatten
155
- end
156
-
157
- # @param ns [YARD::CodeObjects::NamespaceObject]
158
- # @return [Array<YARD::CodeObjects::Base>]
159
- def recurse_namespace_object ns
160
- result = []
161
- ns.children.each do |c|
162
- result.push c
163
- result.concat recurse_namespace_object(c) if c.respond_to?(:children)
164
- end
165
- result
166
- end
167
-
168
- # @return [void]
169
- def process_requires
170
- @gemset = process_gemsets
171
- required.merge @gemset.keys if required.include?('bundler/require')
172
- pins.clear
173
- unresolved_requires.clear
174
- missing_docs.clear
175
- environ = Convention.for_global(self)
176
- done = []
177
- already_errored = []
178
- (required + environ.requires).each do |r|
179
- next if r.nil? || r.empty? || done.include?(r)
180
- done.push r
181
- cached = cache.get_path_pins(r)
182
- unless cached.nil?
183
- pins.concat cached
184
- next
185
- end
186
- result = pins_for_require r, already_errored
187
- result.delete_if(&:nil?)
188
- unless result.empty?
189
- cache.set_path_pins r, result
190
- pins.concat result
191
- end
192
- end
193
- if required.include?('yaml') && required.include?('psych')
194
- # HACK: Hardcoded YAML handling
195
- # @todo Why can't this be handled with an override or a virtual pin?
196
- pin = path_pin('YAML')
197
- pin.instance_variable_set(:@return_type, ComplexType.parse('Module<Psych>')) unless pin.nil?
198
- end
199
- pins.concat environ.pins
200
- end
201
-
202
- def process_error(req, result, already_errored, yd = 1)
203
- base = req.split('/').first
204
- return if already_errored.include?(base)
205
- already_errored.push base
206
- if yd.nil?
207
- missing_docs.push req
208
- else
209
- unresolved_requires.push req
210
- end
211
- end
212
-
213
- def process_gemsets
214
- return {} if directory.empty? || !File.file?(File.join(directory, 'Gemfile'))
215
- require_from_bundle(directory)
216
- end
217
-
218
- # @param r [String]
219
- def pins_for_require r, already_errored
220
- result = []
221
- begin
222
- name = r.split('/').first.to_s
223
- return [] if name.empty?
224
-
225
- spec = spec_for_require(r)
226
- return [] if @source_gems.include?(spec.name) || @gem_paths.key?(spec.name)
227
- @gem_paths[spec.name] = spec.full_gem_path
228
-
229
- yd = yardoc_file_for_spec(spec)
230
- # YARD detects gems for certain libraries that do not have a yardoc
231
- # but exist in the stdlib. `fileutils` is an example. Treat those
232
- # cases as errors and check the stdlib yardoc.
233
- if yd.nil?
234
- process_error(r, result, already_errored, nil)
235
- return []
236
- end
237
- unless yardocs.include?(yd)
238
- yardocs.unshift yd
239
- result.concat process_yardoc yd, spec
240
- if with_dependencies?
241
- (spec.dependencies - spec.development_dependencies).each do |dep|
242
- result.concat pins_for_require dep.name, already_errored
243
- end
244
- end
245
- end
246
- rescue Gem::LoadError, NoYardocError
247
- process_error(r, result, already_errored)
248
- end
249
- return result
250
- end
251
-
252
- # @param y [String, nil]
253
- # @param spec [Gem::Specification, nil]
254
- # @return [Array<Pin::Base>]
255
- def process_yardoc y, spec = nil
256
- return [] if y.nil?
257
- if spec
258
- cache = Solargraph::Cache.load('gems', "#{spec.name}-#{spec.version}.ser")
259
- return cache if cache
260
- end
261
- size = Dir.glob(File.join(y, '**', '*'))
262
- .map{ |f| File.size(f) }
263
- .inject(:+)
264
- if !size.nil? && size > 20_000_000
265
- Solargraph::Logging.logger.warn "Yardoc at #{y} is too large to process (#{size} bytes)"
266
- return []
267
- end
268
- Solargraph.logger.info "Loading #{spec.name} #{spec.version} from #{y}"
269
- load_yardoc y
270
- result = Mapper.new(YARD::Registry.all, spec).map
271
- raise NoYardocError, "Yardoc at #{y} is empty" if result.empty?
272
- if spec
273
- Solargraph::Cache.save 'gems', "#{spec.name}-#{spec.version}.ser", result
274
- end
275
- result
276
- end
277
-
278
- # @param spec [Gem::Specification]
279
- # @return [String]
280
- def yardoc_file_for_spec spec
281
- YARD::Registry.yardoc_file_for_gem(spec.name, "= #{spec.version}")
282
- end
283
-
284
- # @param path [String]
285
- # @return [Gem::Specification]
286
- def spec_for_require path
287
- relatives = path.split('/')
288
- spec = nil
289
- while spec.nil? && !relatives.empty?
290
- name = relatives.join('-')
291
- spec = Gem::Specification.find_by_name(name, @gemset[name])
292
- relatives.pop
293
- end
294
- raise Gem::LoadError if spec.nil?
295
-
296
- # Avoid loading the spec again if it's going to be skipped anyway
297
- return spec if @source_gems.include?(spec.name)
298
- # Avoid loading the spec again if it's already the correct version
299
- if @gemset[spec.name] && spec.version != @gemset[spec.name]
300
- begin
301
- return Gem::Specification.find_by_name(spec.name, "= #{@gemset[spec.name]}")
302
- rescue Gem::LoadError
303
- Solargraph.logger.warn "Unable to load #{spec.name} #{@gemset[spec.name]} specified by workspace, using #{spec.version} instead"
304
- end
305
- end
306
- spec
307
- end
308
17
  end
309
18
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yard'
4
+
5
+ # Change YARD log IO to avoid sending unexpected messages to STDOUT
6
+ YARD::Logger.instance.io = File.new(File::NULL, 'w')
7
+
8
+ module Solargraph
9
+ # A placeholder for the @!domain directive. It doesn't need to do anything
10
+ # for yardocs. It's only used for Solargraph API maps.
11
+ class DomainDirective < YARD::Tags::Directive
12
+ def call; end
13
+ end
14
+ end
15
+
16
+ # Define a @type tag for documenting variables
17
+ YARD::Tags::Library.define_tag("Type", :type, :with_types_and_name)
18
+
19
+ # Define an @!override directive for overriding method tags
20
+ YARD::Tags::Library.define_directive("override", :with_name, Solargraph::DomainDirective)
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solargraph
4
+ # Methods for caching and loading YARD documentation for gems.
5
+ #
6
+ module Yardoc
7
+ module_function
8
+
9
+ # Build and cache a gem's yardoc and return the path. If the cache already
10
+ # exists, do nothing and return the path.
11
+ #
12
+ # @param gemspec [Gem::Specification]
13
+ # @return [String] The path to the cached yardoc.
14
+ def cache(gemspec)
15
+ path = path_for(gemspec)
16
+ return path if cached?(gemspec)
17
+
18
+ Solargraph.logger.info "Caching yardoc for #{gemspec.name} #{gemspec.version}"
19
+ Dir.chdir gemspec.gem_dir do
20
+ `yardoc --db #{path} --no-output --plugin solargraph`
21
+ end
22
+ path
23
+ end
24
+
25
+ # True if the gem yardoc is cached.
26
+ #
27
+ # @param gemspec [Gem::Specification]
28
+ def cached?(gemspec)
29
+ yardoc = File.join(path_for(gemspec), 'complete')
30
+ File.exist?(yardoc)
31
+ end
32
+
33
+ # Get the absolute path for a cached gem yardoc.
34
+ #
35
+ # @param gemspec [Gem::Specification]
36
+ # @return [String]
37
+ def path_for(gemspec)
38
+ File.join(Solargraph::Cache.work_dir, 'gems', "#{gemspec.name}-#{gemspec.version}.yardoc")
39
+ end
40
+
41
+ # Load a gem's yardoc and return its code objects.
42
+ #
43
+ # @note This method modifies the global YARD registry.
44
+ #
45
+ # @param gemspec [Gem::Specification]
46
+ # @return [Array<YARD::CodeObjects::Base>]
47
+ def load!(gemspec)
48
+ YARD::Registry.load! path_for(gemspec)
49
+ YARD::Registry.all
50
+ end
51
+ end
52
+ end
data/lib/solargraph.rb CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  Encoding.default_external = 'UTF-8'
4
4
 
5
+ require 'set'
6
+ require 'yard-solargraph'
7
+ require 'solargraph/yard_tags'
5
8
  require 'solargraph/version'
6
9
 
7
10
  # The top-level namespace for the Solargraph code mapping, documentation,
@@ -24,8 +27,10 @@ module Solargraph
24
27
  autoload :Source, 'solargraph/source'
25
28
  autoload :SourceMap, 'solargraph/source_map'
26
29
  autoload :ApiMap, 'solargraph/api_map'
30
+ autoload :Yardoc, 'solargraph/yardoc'
27
31
  autoload :YardMap, 'solargraph/yard_map'
28
32
  autoload :Pin, 'solargraph/pin'
33
+ autoload :DocMap, 'solargraph/doc_map'
29
34
  autoload :ServerMethods, 'solargraph/server_methods'
30
35
  autoload :LanguageServer, 'solargraph/language_server'
31
36
  autoload :Workspace, 'solargraph/workspace'
@@ -38,13 +43,12 @@ module Solargraph
38
43
  autoload :TypeChecker, 'solargraph/type_checker'
39
44
  autoload :Environ, 'solargraph/environ'
40
45
  autoload :Convention, 'solargraph/convention'
41
- autoload :Documentor, 'solargraph/documentor'
42
46
  autoload :Parser, 'solargraph/parser'
43
47
  autoload :RbsMap, 'solargraph/rbs_map'
48
+ autoload :GemPins, 'solargraph/gem_pins'
44
49
  autoload :Cache, 'solargraph/cache'
45
50
 
46
51
  dir = File.dirname(__FILE__)
47
- YARD_EXTENSION_FILE = File.join(dir, 'yard-solargraph.rb')
48
52
  VIEWS_PATH = File.join(dir, 'solargraph', 'views')
49
53
 
50
54
  # A convenience method for Solargraph::Logging.logger.
@@ -56,8 +60,6 @@ module Solargraph
56
60
 
57
61
  # A helper method that runs Bundler.with_unbundled_env or falls back to
58
62
  # Bundler.with_clean_env for earlier versions of Bundler.
59
- #
60
- # @return [void]
61
63
  def self.with_clean_env &block
62
64
  meth = if Bundler.respond_to?(:with_original_env)
63
65
  :with_original_env
data/solargraph.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.metadata["changelog_uri"] = "https://github.com/castwide/solargraph/blob/master/CHANGELOG.md"
22
22
  s.metadata["source_code_uri"] = "https://github.com/castwide/solargraph"
23
23
 
24
- s.required_ruby_version = '>= 2.6'
24
+ s.required_ruby_version = '>= 3.0'
25
25
 
26
26
  s.add_runtime_dependency 'backport', '~> 1.2'
27
27
  s.add_runtime_dependency 'benchmark'
@@ -34,12 +34,13 @@ Gem::Specification.new do |s|
34
34
  s.add_runtime_dependency 'observer', '~> 0.1'
35
35
  s.add_runtime_dependency 'ostruct', '~> 0.6'
36
36
  s.add_runtime_dependency 'parser', '~> 3.0'
37
- s.add_runtime_dependency 'rbs', '~> 3.0'
37
+ s.add_runtime_dependency 'rbs', '~> 3.3'
38
38
  s.add_runtime_dependency 'reverse_markdown', '>= 2.0', '< 4'
39
39
  s.add_runtime_dependency 'rubocop', '~> 1.38'
40
40
  s.add_runtime_dependency 'thor', '~> 1.0'
41
41
  s.add_runtime_dependency 'tilt', '~> 2.0'
42
42
  s.add_runtime_dependency 'yard', '~> 0.9', '>= 0.9.24'
43
+ s.add_runtime_dependency 'yard-solargraph', '~> 0.1'
43
44
 
44
45
  s.add_development_dependency 'pry'
45
46
  s.add_development_dependency 'public_suffix', '~> 3.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.51.2
4
+ version: 0.53.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-01 00:00:00.000000000 Z
11
+ date: 2025-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '3.0'
173
+ version: '3.3'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '3.0'
180
+ version: '3.3'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: reverse_markdown
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -260,6 +260,20 @@ dependencies:
260
260
  - - ">="
261
261
  - !ruby/object:Gem::Version
262
262
  version: 0.9.24
263
+ - !ruby/object:Gem::Dependency
264
+ name: yard-solargraph
265
+ requirement: !ruby/object:Gem::Requirement
266
+ requirements:
267
+ - - "~>"
268
+ - !ruby/object:Gem::Version
269
+ version: '0.1'
270
+ type: :runtime
271
+ prerelease: false
272
+ version_requirements: !ruby/object:Gem::Requirement
273
+ requirements:
274
+ - - "~>"
275
+ - !ruby/object:Gem::Version
276
+ version: '0.1'
263
277
  - !ruby/object:Gem::Dependency
264
278
  name: pry
265
279
  requirement: !ruby/object:Gem::Requirement
@@ -366,7 +380,9 @@ extensions: []
366
380
  extra_rdoc_files: []
367
381
  files:
368
382
  - ".github/FUNDING.yml"
383
+ - ".github/workflows/plugins.yml"
369
384
  - ".github/workflows/rspec.yml"
385
+ - ".github/workflows/typecheck.yml"
370
386
  - ".gitignore"
371
387
  - ".rspec"
372
388
  - ".yardopts"
@@ -380,7 +396,6 @@ files:
380
396
  - lib/.rubocop.yml
381
397
  - lib/solargraph.rb
382
398
  - lib/solargraph/api_map.rb
383
- - lib/solargraph/api_map/bundler_methods.rb
384
399
  - lib/solargraph/api_map/cache.rb
385
400
  - lib/solargraph/api_map/source_to_yard.rb
386
401
  - lib/solargraph/api_map/store.rb
@@ -406,8 +421,9 @@ files:
406
421
  - lib/solargraph/diagnostics/severities.rb
407
422
  - lib/solargraph/diagnostics/type_check.rb
408
423
  - lib/solargraph/diagnostics/update_errors.rb
409
- - lib/solargraph/documentor.rb
424
+ - lib/solargraph/doc_map.rb
410
425
  - lib/solargraph/environ.rb
426
+ - lib/solargraph/gem_pins.rb
411
427
  - lib/solargraph/language_server.rb
412
428
  - lib/solargraph/language_server/completion_item_kinds.rb
413
429
  - lib/solargraph/language_server/error_codes.rb
@@ -475,60 +491,33 @@ files:
475
491
  - lib/solargraph/page.rb
476
492
  - lib/solargraph/parser.rb
477
493
  - lib/solargraph/parser/comment_ripper.rb
478
- - lib/solargraph/parser/legacy.rb
479
- - lib/solargraph/parser/legacy/class_methods.rb
480
- - lib/solargraph/parser/legacy/flawed_builder.rb
481
- - lib/solargraph/parser/legacy/node_chainer.rb
482
- - lib/solargraph/parser/legacy/node_methods.rb
483
- - lib/solargraph/parser/legacy/node_processors.rb
484
- - lib/solargraph/parser/legacy/node_processors/alias_node.rb
485
- - lib/solargraph/parser/legacy/node_processors/args_node.rb
486
- - lib/solargraph/parser/legacy/node_processors/begin_node.rb
487
- - lib/solargraph/parser/legacy/node_processors/block_node.rb
488
- - lib/solargraph/parser/legacy/node_processors/casgn_node.rb
489
- - lib/solargraph/parser/legacy/node_processors/cvasgn_node.rb
490
- - lib/solargraph/parser/legacy/node_processors/def_node.rb
491
- - lib/solargraph/parser/legacy/node_processors/defs_node.rb
492
- - lib/solargraph/parser/legacy/node_processors/gvasgn_node.rb
493
- - lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb
494
- - lib/solargraph/parser/legacy/node_processors/lvasgn_node.rb
495
- - lib/solargraph/parser/legacy/node_processors/namespace_node.rb
496
- - lib/solargraph/parser/legacy/node_processors/orasgn_node.rb
497
- - lib/solargraph/parser/legacy/node_processors/resbody_node.rb
498
- - lib/solargraph/parser/legacy/node_processors/sclass_node.rb
499
- - lib/solargraph/parser/legacy/node_processors/send_node.rb
500
- - lib/solargraph/parser/legacy/node_processors/sym_node.rb
501
494
  - lib/solargraph/parser/node_methods.rb
502
495
  - lib/solargraph/parser/node_processor.rb
503
496
  - lib/solargraph/parser/node_processor/base.rb
497
+ - lib/solargraph/parser/parser_gem.rb
498
+ - lib/solargraph/parser/parser_gem/class_methods.rb
499
+ - lib/solargraph/parser/parser_gem/flawed_builder.rb
500
+ - lib/solargraph/parser/parser_gem/node_chainer.rb
501
+ - lib/solargraph/parser/parser_gem/node_methods.rb
502
+ - lib/solargraph/parser/parser_gem/node_processors.rb
503
+ - lib/solargraph/parser/parser_gem/node_processors/alias_node.rb
504
+ - lib/solargraph/parser/parser_gem/node_processors/args_node.rb
505
+ - lib/solargraph/parser/parser_gem/node_processors/begin_node.rb
506
+ - lib/solargraph/parser/parser_gem/node_processors/block_node.rb
507
+ - lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb
508
+ - lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb
509
+ - lib/solargraph/parser/parser_gem/node_processors/def_node.rb
510
+ - lib/solargraph/parser/parser_gem/node_processors/defs_node.rb
511
+ - lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb
512
+ - lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb
513
+ - lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb
514
+ - lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb
515
+ - lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb
516
+ - lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb
517
+ - lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb
518
+ - lib/solargraph/parser/parser_gem/node_processors/send_node.rb
519
+ - lib/solargraph/parser/parser_gem/node_processors/sym_node.rb
504
520
  - lib/solargraph/parser/region.rb
505
- - lib/solargraph/parser/rubyvm.rb
506
- - lib/solargraph/parser/rubyvm/class_methods.rb
507
- - lib/solargraph/parser/rubyvm/node_chainer.rb
508
- - lib/solargraph/parser/rubyvm/node_methods.rb
509
- - lib/solargraph/parser/rubyvm/node_processors.rb
510
- - lib/solargraph/parser/rubyvm/node_processors/alias_node.rb
511
- - lib/solargraph/parser/rubyvm/node_processors/args_node.rb
512
- - lib/solargraph/parser/rubyvm/node_processors/begin_node.rb
513
- - lib/solargraph/parser/rubyvm/node_processors/block_node.rb
514
- - lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb
515
- - lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb
516
- - lib/solargraph/parser/rubyvm/node_processors/def_node.rb
517
- - lib/solargraph/parser/rubyvm/node_processors/defs_node.rb
518
- - lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb
519
- - lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb
520
- - lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb
521
- - lib/solargraph/parser/rubyvm/node_processors/lit_node.rb
522
- - lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb
523
- - lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb
524
- - lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb
525
- - lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb
526
- - lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb
527
- - lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb
528
- - lib/solargraph/parser/rubyvm/node_processors/scope_node.rb
529
- - lib/solargraph/parser/rubyvm/node_processors/send_node.rb
530
- - lib/solargraph/parser/rubyvm/node_processors/sym_node.rb
531
- - lib/solargraph/parser/rubyvm/node_wrapper.rb
532
521
  - lib/solargraph/parser/snippet.rb
533
522
  - lib/solargraph/pin.rb
534
523
  - lib/solargraph/pin/base.rb
@@ -575,6 +564,8 @@ files:
575
564
  - lib/solargraph/shell.rb
576
565
  - lib/solargraph/source.rb
577
566
  - lib/solargraph/source/chain.rb
567
+ - lib/solargraph/source/chain/array.rb
568
+ - lib/solargraph/source/chain/block_symbol.rb
578
569
  - lib/solargraph/source/chain/block_variable.rb
579
570
  - lib/solargraph/source/chain/call.rb
580
571
  - lib/solargraph/source/chain/class_variable.rb
@@ -582,6 +573,7 @@ files:
582
573
  - lib/solargraph/source/chain/global_variable.rb
583
574
  - lib/solargraph/source/chain/hash.rb
584
575
  - lib/solargraph/source/chain/head.rb
576
+ - lib/solargraph/source/chain/if.rb
585
577
  - lib/solargraph/source/chain/instance_variable.rb
586
578
  - lib/solargraph/source/chain/link.rb
587
579
  - lib/solargraph/source/chain/literal.rb
@@ -621,7 +613,8 @@ files:
621
613
  - lib/solargraph/yard_map/mapper/to_method.rb
622
614
  - lib/solargraph/yard_map/mapper/to_namespace.rb
623
615
  - lib/solargraph/yard_map/to_method.rb
624
- - lib/yard-solargraph.rb
616
+ - lib/solargraph/yard_tags.rb
617
+ - lib/solargraph/yardoc.rb
625
618
  - solargraph.gemspec
626
619
  homepage: https://solargraph.org
627
620
  licenses:
@@ -639,7 +632,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
639
632
  requirements:
640
633
  - - ">="
641
634
  - !ruby/object:Gem::Version
642
- version: '2.6'
635
+ version: '3.0'
643
636
  required_rubygems_version: !ruby/object:Gem::Requirement
644
637
  requirements:
645
638
  - - ">="
@@ -1,22 +0,0 @@
1
- require 'bundler'
2
- require 'shellwords'
3
-
4
- module Solargraph
5
- class ApiMap
6
- module BundlerMethods
7
- module_function
8
-
9
- # @param directory [String]
10
- # @return [Hash]
11
- def require_from_bundle directory
12
- begin
13
- Solargraph.logger.info "Loading gems for bundler/require"
14
- Documentor.specs_from_bundle(directory)
15
- rescue BundleNotFoundError => e
16
- Solargraph.logger.warn e.message
17
- {}
18
- end
19
- end
20
- end
21
- end
22
- end