solargraph 0.53.4 → 0.54.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/lib/solargraph/api_map/cache.rb +2 -12
- data/lib/solargraph/api_map/store.rb +11 -6
- data/lib/solargraph/api_map.rb +53 -17
- data/lib/solargraph/complex_type/type_methods.rb +62 -30
- data/lib/solargraph/complex_type/unique_type.rb +117 -66
- data/lib/solargraph/complex_type.rb +41 -25
- data/lib/solargraph/doc_map.rb +19 -3
- data/lib/solargraph/gem_pins.rb +9 -1
- data/lib/solargraph/language_server/host/dispatch.rb +8 -1
- data/lib/solargraph/language_server/host/sources.rb +1 -61
- data/lib/solargraph/language_server/host.rb +21 -68
- data/lib/solargraph/language_server/message/base.rb +1 -1
- data/lib/solargraph/language_server/message/initialize.rb +14 -0
- data/lib/solargraph/language_server/message/text_document/formatting.rb +1 -0
- data/lib/solargraph/language_server/progress.rb +118 -0
- data/lib/solargraph/language_server.rb +1 -0
- data/lib/solargraph/library.rb +136 -96
- data/lib/solargraph/parser/node_processor/base.rb +3 -2
- data/lib/solargraph/parser/node_processor.rb +1 -0
- data/lib/solargraph/parser/parser_gem/class_methods.rb +3 -7
- data/lib/solargraph/parser/parser_gem/node_methods.rb +0 -4
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +47 -0
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +5 -3
- data/lib/solargraph/parser/parser_gem/node_processors.rb +2 -0
- data/lib/solargraph/pin/base_variable.rb +34 -5
- data/lib/solargraph/pin/block.rb +55 -0
- data/lib/solargraph/pin/delegated_method.rb +5 -1
- data/lib/solargraph/pin/documenting.rb +2 -0
- data/lib/solargraph/pin/method.rb +3 -1
- data/lib/solargraph/pin/parameter.rb +5 -28
- data/lib/solargraph/rbs_map/conversions.rb +10 -6
- data/lib/solargraph/rbs_map.rb +11 -3
- data/lib/solargraph/shell.rb +18 -13
- data/lib/solargraph/source/chain.rb +20 -0
- data/lib/solargraph/source/updater.rb +1 -0
- data/lib/solargraph/source.rb +0 -44
- data/lib/solargraph/source_map/mapper.rb +3 -2
- data/lib/solargraph/source_map.rb +10 -0
- data/lib/solargraph/type_checker.rb +43 -18
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +2 -1
- data/lib/solargraph/workspace.rb +13 -0
- metadata +4 -3
- data/lib/solargraph/language_server/host/cataloger.rb +0 -57
@@ -291,13 +291,19 @@ module Solargraph
|
|
291
291
|
result = []
|
292
292
|
base = chain
|
293
293
|
until base.links.length == 1 && base.undefined?
|
294
|
+
last_base_link = base.links.last
|
295
|
+
break unless last_base_link.is_a?(Solargraph::Source::Chain::Call)
|
296
|
+
|
297
|
+
arguments = last_base_link.arguments
|
298
|
+
|
294
299
|
pins = base.define(api_map, block_pin, locals)
|
295
300
|
|
296
|
-
|
301
|
+
first_pin = pins.first
|
302
|
+
if first_pin.is_a?(Pin::DelegatedMethod) && !first_pin.resolvable?(api_map)
|
297
303
|
# Do nothing, as we can't find the actual method implementation
|
298
|
-
elsif
|
304
|
+
elsif first_pin.is_a?(Pin::Method)
|
299
305
|
# @type [Pin::Method]
|
300
|
-
pin =
|
306
|
+
pin = first_pin
|
301
307
|
ap = if base.links.last.is_a?(Solargraph::Source::Chain::ZSuper)
|
302
308
|
arity_problems_for(pin, fake_args_for(block_pin), location)
|
303
309
|
elsif pin.path == 'Class#new'
|
@@ -307,9 +313,9 @@ module Solargraph
|
|
307
313
|
base.base.infer(api_map, block_pin, locals).namespace
|
308
314
|
end
|
309
315
|
init = api_map.get_method_stack(fqns, 'initialize').first
|
310
|
-
init ? arity_problems_for(init,
|
316
|
+
init ? arity_problems_for(init, arguments, location) : []
|
311
317
|
else
|
312
|
-
arity_problems_for(pin,
|
318
|
+
arity_problems_for(pin, arguments, location)
|
313
319
|
end
|
314
320
|
unless ap.empty?
|
315
321
|
result.concat ap
|
@@ -322,24 +328,26 @@ module Solargraph
|
|
322
328
|
all_errors = []
|
323
329
|
pin.signatures.sort { |sig| sig.parameters.length }.each do |sig|
|
324
330
|
errors = []
|
325
|
-
# @todo these should be able to be probed
|
326
|
-
# @param par [Parameter]
|
327
|
-
# @param idx [Integer]
|
328
331
|
sig.parameters.each_with_index do |par, idx|
|
329
|
-
|
332
|
+
# @todo add logic mapping up restarg parameters with
|
333
|
+
# arguments (including restarg arguments). Use tuples
|
334
|
+
# when possible, and when not, ensure provably
|
335
|
+
# incorrect situations are detected.
|
336
|
+
break if par.decl == :restarg # bail out pending better arg processing
|
337
|
+
argchain = arguments[idx]
|
330
338
|
if argchain.nil?
|
331
339
|
if par.decl == :arg
|
332
|
-
|
333
|
-
if
|
334
|
-
argchain =
|
340
|
+
final_arg = arguments.last
|
341
|
+
if final_arg && final_arg.node.type == :splat
|
342
|
+
argchain = final_arg
|
335
343
|
next # don't try to apply the type of the splat - unlikely to be specific enough
|
336
344
|
else
|
337
345
|
errors.push Problem.new(location, "Not enough arguments to #{pin.path}")
|
338
346
|
next
|
339
347
|
end
|
340
348
|
else
|
341
|
-
|
342
|
-
argchain =
|
349
|
+
final_arg = arguments.last
|
350
|
+
argchain = final_arg if final_arg && [:kwsplat, :hash].include?(final_arg.node.type)
|
343
351
|
end
|
344
352
|
end
|
345
353
|
if argchain
|
@@ -347,9 +355,26 @@ module Solargraph
|
|
347
355
|
errors.concat kwarg_problems_for sig, argchain, api_map, block_pin, locals, location, pin, params, idx
|
348
356
|
next
|
349
357
|
else
|
350
|
-
|
351
|
-
|
352
|
-
|
358
|
+
if argchain.node.type == :splat && argchain == arguments.last
|
359
|
+
final_arg = argchain
|
360
|
+
end
|
361
|
+
if (final_arg && final_arg.node.type == :splat)
|
362
|
+
# The final argument given has been seen and was a
|
363
|
+
# splat, which doesn't give us useful types or
|
364
|
+
# arities against positional parameters, so let's
|
365
|
+
# continue on in case there are any required
|
366
|
+
# kwargs we should warn about
|
367
|
+
next
|
368
|
+
end
|
369
|
+
|
370
|
+
if argchain.node.type == :splat && par != sig.parameters.last
|
371
|
+
# we have been given a splat and there are more
|
372
|
+
# arguments to come.
|
373
|
+
|
374
|
+
# @todo Improve this so that we can skip past the
|
375
|
+
# rest of the positional parameters here but still
|
376
|
+
# process the kwargs
|
377
|
+
break
|
353
378
|
end
|
354
379
|
ptype = params.key?(par.name) ? params[par.name][:qualified] : ComplexType::UNDEFINED
|
355
380
|
ptype = ptype.self_to(par.context.namespace)
|
@@ -462,7 +487,7 @@ module Solargraph
|
|
462
487
|
def first_param_hash(pins)
|
463
488
|
pins.each do |pin|
|
464
489
|
# @todo this assignment from parametric use of Hash should not lose its generic
|
465
|
-
# @type [Hash{String => Hash{Symbol => BasicObject}]
|
490
|
+
# @type [Hash{String => Hash{Symbol => BasicObject}}]
|
466
491
|
result = param_hash(pin)
|
467
492
|
return result unless result.empty?
|
468
493
|
end
|
data/lib/solargraph/version.rb
CHANGED
@@ -14,7 +14,8 @@ module Solargraph
|
|
14
14
|
# @return [String]
|
15
15
|
attr_reader :directory
|
16
16
|
|
17
|
-
# @
|
17
|
+
# @todo To make this strongly typed we'll need a record syntax
|
18
|
+
# @return [Hash{String => undefined}]
|
18
19
|
attr_reader :raw_data
|
19
20
|
|
20
21
|
# @param directory [String]
|
data/lib/solargraph/workspace.rb
CHANGED
@@ -128,6 +128,11 @@ module Solargraph
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
# @return [String, nil]
|
132
|
+
def rbs_collection_path
|
133
|
+
@gem_rbs_collection ||= read_rbs_collection_path
|
134
|
+
end
|
135
|
+
|
131
136
|
# Synchronize the workspace from the provided updater.
|
132
137
|
#
|
133
138
|
# @param updater [Source::Updater]
|
@@ -222,5 +227,13 @@ module Solargraph
|
|
222
227
|
end
|
223
228
|
end
|
224
229
|
end
|
230
|
+
|
231
|
+
# @return [String, nil]
|
232
|
+
def read_rbs_collection_path
|
233
|
+
yaml_file = File.join(directory, 'rbs_collection.yaml')
|
234
|
+
return unless File.file?(yaml_file)
|
235
|
+
|
236
|
+
YAML.load_file(yaml_file)&.fetch('path')
|
237
|
+
end
|
225
238
|
end
|
226
239
|
end
|
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.
|
4
|
+
version: 0.54.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-
|
11
|
+
date: 2025-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -428,7 +428,6 @@ files:
|
|
428
428
|
- lib/solargraph/language_server/completion_item_kinds.rb
|
429
429
|
- lib/solargraph/language_server/error_codes.rb
|
430
430
|
- lib/solargraph/language_server/host.rb
|
431
|
-
- lib/solargraph/language_server/host/cataloger.rb
|
432
431
|
- lib/solargraph/language_server/host/diagnoser.rb
|
433
432
|
- lib/solargraph/language_server/host/dispatch.rb
|
434
433
|
- lib/solargraph/language_server/host/message_worker.rb
|
@@ -479,6 +478,7 @@ files:
|
|
479
478
|
- lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb
|
480
479
|
- lib/solargraph/language_server/message/workspace/workspace_symbol.rb
|
481
480
|
- lib/solargraph/language_server/message_types.rb
|
481
|
+
- lib/solargraph/language_server/progress.rb
|
482
482
|
- lib/solargraph/language_server/request.rb
|
483
483
|
- lib/solargraph/language_server/symbol_kinds.rb
|
484
484
|
- lib/solargraph/language_server/transport.rb
|
@@ -511,6 +511,7 @@ files:
|
|
511
511
|
- lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb
|
512
512
|
- lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb
|
513
513
|
- lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb
|
514
|
+
- lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb
|
514
515
|
- lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb
|
515
516
|
- lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb
|
516
517
|
- lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Solargraph
|
4
|
-
module LanguageServer
|
5
|
-
class Host
|
6
|
-
# An asynchronous library cataloging handler.
|
7
|
-
#
|
8
|
-
class Cataloger
|
9
|
-
# @param host [Host]
|
10
|
-
def initialize host
|
11
|
-
@host = host
|
12
|
-
@stopped = true
|
13
|
-
end
|
14
|
-
|
15
|
-
# Stop the catalog thread.
|
16
|
-
#
|
17
|
-
# @return [void]
|
18
|
-
def stop
|
19
|
-
@stopped = true
|
20
|
-
end
|
21
|
-
|
22
|
-
# True if the cataloger is stopped.
|
23
|
-
#
|
24
|
-
# @return [Boolean]
|
25
|
-
def stopped?
|
26
|
-
@stopped
|
27
|
-
end
|
28
|
-
|
29
|
-
# Start the catalog thread.
|
30
|
-
#
|
31
|
-
# @return [void]
|
32
|
-
def start
|
33
|
-
return unless stopped?
|
34
|
-
@stopped = false
|
35
|
-
Thread.new do
|
36
|
-
until stopped?
|
37
|
-
tick
|
38
|
-
sleep 0.1
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Perform cataloging.
|
44
|
-
#
|
45
|
-
# @return [void]
|
46
|
-
def tick
|
47
|
-
host.catalog
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
# @return [Host]
|
53
|
-
attr_reader :host
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|