solargraph 0.54.4 → 0.55.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 +18 -0
- data/lib/solargraph/api_map/index.rb +1 -1
- data/lib/solargraph/api_map/store.rb +40 -19
- data/lib/solargraph/api_map.rb +24 -19
- data/lib/solargraph/bench.rb +17 -1
- data/lib/solargraph/complex_type/unique_type.rb +88 -7
- data/lib/solargraph/complex_type.rb +35 -6
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +51 -0
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +100 -0
- data/lib/solargraph/convention/struct_definition.rb +101 -0
- data/lib/solargraph/convention.rb +1 -0
- data/lib/solargraph/doc_map.rb +42 -18
- data/lib/solargraph/language_server/host/message_worker.rb +10 -7
- data/lib/solargraph/language_server/host.rb +1 -0
- data/lib/solargraph/library.rb +2 -1
- data/lib/solargraph/location.rb +8 -0
- data/lib/solargraph/parser/comment_ripper.rb +11 -6
- data/lib/solargraph/parser/flow_sensitive_typing.rb +226 -0
- data/lib/solargraph/parser/node_methods.rb +14 -0
- data/lib/solargraph/parser/node_processor.rb +0 -1
- data/lib/solargraph/parser/parser_gem/class_methods.rb +11 -6
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +10 -10
- data/lib/solargraph/parser/parser_gem/node_methods.rb +3 -1
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +21 -0
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +21 -1
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +21 -0
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +26 -5
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +41 -0
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +28 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +28 -0
- data/lib/solargraph/parser/parser_gem/node_processors.rb +10 -0
- data/lib/solargraph/parser.rb +1 -0
- data/lib/solargraph/pin/base.rb +9 -3
- data/lib/solargraph/pin/base_variable.rb +7 -1
- data/lib/solargraph/pin/block.rb +2 -0
- data/lib/solargraph/pin/breakable.rb +9 -0
- data/lib/solargraph/pin/local_variable.rb +7 -1
- data/lib/solargraph/pin/method.rb +20 -18
- data/lib/solargraph/pin/namespace.rb +10 -7
- data/lib/solargraph/pin/parameter.rb +13 -5
- data/lib/solargraph/pin/proxy_type.rb +12 -6
- data/lib/solargraph/pin/until.rb +18 -0
- data/lib/solargraph/pin/while.rb +18 -0
- data/lib/solargraph/pin.rb +3 -0
- data/lib/solargraph/rbs_map/conversions.rb +8 -8
- data/lib/solargraph/rbs_map/core_fills.rb +10 -3
- data/lib/solargraph/source/chain/array.rb +4 -3
- data/lib/solargraph/source/chain/call.rb +46 -17
- data/lib/solargraph/source/chain/constant.rb +1 -1
- data/lib/solargraph/source/chain/hash.rb +3 -2
- data/lib/solargraph/source/chain/link.rb +2 -0
- data/lib/solargraph/source/chain/literal.rb +22 -2
- data/lib/solargraph/source/chain/z_super.rb +1 -1
- data/lib/solargraph/source/chain.rb +77 -47
- data/lib/solargraph/source/source_chainer.rb +2 -2
- data/lib/solargraph/source_map/clip.rb +3 -1
- data/lib/solargraph/type_checker/checks.rb +4 -0
- data/lib/solargraph/type_checker.rb +35 -8
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +42 -15
- data/lib/solargraph/yardoc.rb +1 -1
- metadata +15 -3
@@ -11,7 +11,9 @@ module Solargraph
|
|
11
11
|
def initialize api_map, cursor
|
12
12
|
@api_map = api_map
|
13
13
|
@cursor = cursor
|
14
|
-
|
14
|
+
block_pin = block
|
15
|
+
block_pin.rebind(api_map) if block_pin.is_a?(Pin::Block) && !Solargraph::Range.from_node(block_pin.receiver).contain?(cursor.range.start)
|
16
|
+
@in_block = nil
|
15
17
|
end
|
16
18
|
|
17
19
|
# @return [Array<Pin::Base>] Relevant pins for infering the type of the Cursor's position
|
@@ -50,6 +50,8 @@ module Solargraph
|
|
50
50
|
# @param inferred [ComplexType]
|
51
51
|
# @return [Boolean]
|
52
52
|
def any_types_match? api_map, expected, inferred
|
53
|
+
expected = expected.downcast_to_literal_if_possible
|
54
|
+
inferred = inferred.downcast_to_literal_if_possible
|
53
55
|
return duck_types_match?(api_map, expected, inferred) if expected.duck_type?
|
54
56
|
# walk through the union expected type and see if any members
|
55
57
|
# of the union match the inferred type
|
@@ -71,6 +73,8 @@ module Solargraph
|
|
71
73
|
# @param expected [ComplexType]
|
72
74
|
# @return [Boolean]
|
73
75
|
def all_types_match? api_map, inferred, expected
|
76
|
+
expected = expected.downcast_to_literal_if_possible
|
77
|
+
inferred = inferred.downcast_to_literal_if_possible
|
74
78
|
return duck_types_match?(api_map, expected, inferred) if expected.duck_type?
|
75
79
|
inferred.each do |inf|
|
76
80
|
next if inf.duck_type?
|
@@ -470,12 +470,22 @@ module Solargraph
|
|
470
470
|
# @param pin [Pin::Method]
|
471
471
|
# @return [Hash{String => Hash{Symbol => String, ComplexType}}]
|
472
472
|
def param_hash(pin)
|
473
|
-
tags = pin.docstring.tags(:param)
|
474
|
-
return {} if tags.empty?
|
475
473
|
# @type [Hash{String => Hash{Symbol => String, ComplexType}}]
|
476
474
|
result = {}
|
475
|
+
pin.parameters.each do |param|
|
476
|
+
type = param.typify(api_map)
|
477
|
+
next if type.nil? || type.undefined?
|
478
|
+
result[param.name.to_s] = {
|
479
|
+
tagged: type.tags,
|
480
|
+
qualified: type
|
481
|
+
}
|
482
|
+
end
|
483
|
+
# see if we have additional tags to pay attention to from YARD -
|
484
|
+
# e.g., kwargs in a **restkwargs splat
|
485
|
+
tags = pin.docstring.tags(:param)
|
477
486
|
tags.each do |tag|
|
478
|
-
next if
|
487
|
+
next if result.key? tag.name.to_s
|
488
|
+
next if tag.types.nil?
|
479
489
|
result[tag.name.to_s] = {
|
480
490
|
tagged: tag.types.join(', '),
|
481
491
|
qualified: Solargraph::ComplexType.try_parse(*tag.types).qualify(api_map, pin.full_context.namespace)
|
@@ -487,11 +497,27 @@ module Solargraph
|
|
487
497
|
# @param pins [Array<Pin::Method>]
|
488
498
|
# @return [Hash{String => Hash{Symbol => String, ComplexType}}]
|
489
499
|
def first_param_hash(pins)
|
490
|
-
pins.
|
491
|
-
|
492
|
-
|
500
|
+
return {} if pins.empty?
|
501
|
+
first_pin_type = pins.first.typify(api_map)
|
502
|
+
first_pin = pins.first.proxy first_pin_type
|
503
|
+
param_names = first_pin.parameter_names
|
504
|
+
results = param_hash(first_pin)
|
505
|
+
pins[1..].each do |pin|
|
506
|
+
# @todo this assignment from parametric use of Hash should not lose its generic
|
507
|
+
# @type [Hash{String => Hash{Symbol => BasicObject}}]
|
508
|
+
|
509
|
+
# documentation of types in superclasses should fail back to
|
510
|
+
# subclasses if the subclass hasn't documented something
|
511
|
+
superclass_results = param_hash(pin)
|
512
|
+
superclass_results.each do |param_name, details|
|
513
|
+
next unless param_names.include?(param_name)
|
514
|
+
|
515
|
+
results[param_name] ||= {}
|
516
|
+
results[param_name][:tagged] ||= details[:tagged]
|
517
|
+
results[param_name][:qualified] ||= details[:qualified]
|
518
|
+
end
|
493
519
|
end
|
494
|
-
|
520
|
+
results
|
495
521
|
end
|
496
522
|
|
497
523
|
# @param pin [Pin::Base]
|
@@ -584,7 +610,8 @@ module Solargraph
|
|
584
610
|
kwargs.delete param.name.to_sym
|
585
611
|
settled_kwargs += 1
|
586
612
|
elsif param.decl == :kwarg
|
587
|
-
|
613
|
+
last_arg_last_link = arguments.last.links.last
|
614
|
+
return [] if last_arg_last_link.is_a?(Solargraph::Source::Chain::Hash) && last_arg_last_link.splatted?
|
588
615
|
return [Problem.new(location, "Missing keyword argument #{param.name} to #{pin.path}")]
|
589
616
|
end
|
590
617
|
end
|
data/lib/solargraph/version.rb
CHANGED
@@ -16,29 +16,55 @@ module Solargraph
|
|
16
16
|
def self.make code_object, name = nil, scope = nil, visibility = nil, closure = nil, spec = nil
|
17
17
|
closure ||= Solargraph::Pin::Namespace.new(
|
18
18
|
name: code_object.namespace.to_s,
|
19
|
-
gates: [code_object.namespace.to_s]
|
19
|
+
gates: [code_object.namespace.to_s],
|
20
|
+
type: code_object.namespace.is_a?(YARD::CodeObjects::ClassObject) ? :class : :module,
|
21
|
+
source: :yardoc,
|
20
22
|
)
|
21
23
|
location = object_location(code_object, spec)
|
22
24
|
name ||= code_object.name.to_s
|
23
25
|
return_type = ComplexType::SELF if name == 'new'
|
24
26
|
comments = code_object.docstring ? code_object.docstring.all.to_s : ''
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
final_scope = scope || code_object.scope
|
28
|
+
final_visibility = visibility || code_object.visibility
|
29
|
+
if code_object.is_alias?
|
30
|
+
origin_code_object = code_object.namespace.aliases[code_object]
|
31
|
+
pin = Pin::MethodAlias.new(
|
32
|
+
name: name,
|
33
|
+
location: location,
|
34
|
+
original: origin_code_object.name.to_s,
|
35
|
+
closure: closure,
|
36
|
+
comments: comments,
|
37
|
+
scope: final_scope,
|
38
|
+
visibility: final_visibility,
|
39
|
+
explicit: code_object.is_explicit?,
|
40
|
+
return_type: return_type,
|
41
|
+
parameters: [],
|
42
|
+
source: :yardoc,
|
43
|
+
)
|
44
|
+
else
|
45
|
+
pin = Pin::Method.new(
|
46
|
+
location: location,
|
47
|
+
closure: closure,
|
48
|
+
name: name,
|
49
|
+
comments: comments,
|
50
|
+
scope: final_scope,
|
51
|
+
visibility: final_visibility,
|
52
|
+
# @todo Might need to convert overloads to signatures
|
53
|
+
explicit: code_object.is_explicit?,
|
54
|
+
return_type: return_type,
|
55
|
+
attribute: code_object.is_attribute?,
|
56
|
+
parameters: [],
|
57
|
+
source: :yardoc,
|
58
|
+
)
|
59
|
+
pin.parameters.concat get_parameters(code_object, location, comments, pin)
|
60
|
+
end
|
61
|
+
logger.debug { "ToMethod.make: Just created method pin: #{pin.inspect}" }
|
38
62
|
pin
|
39
63
|
end
|
40
64
|
|
41
65
|
class << self
|
66
|
+
include Logging
|
67
|
+
|
42
68
|
private
|
43
69
|
|
44
70
|
# @param code_object [YARD::CodeObjects::Base]
|
@@ -59,7 +85,8 @@ module Solargraph
|
|
59
85
|
name: arg_name(a),
|
60
86
|
presence: nil,
|
61
87
|
decl: arg_type(a),
|
62
|
-
asgn_code: a[1]
|
88
|
+
asgn_code: a[1],
|
89
|
+
source: :yardoc,
|
63
90
|
)
|
64
91
|
end
|
65
92
|
end
|
data/lib/solargraph/yardoc.rb
CHANGED
@@ -35,7 +35,7 @@ module Solargraph
|
|
35
35
|
# @param gemspec [Gem::Specification]
|
36
36
|
# @return [String]
|
37
37
|
def path_for(gemspec)
|
38
|
-
File.join(Solargraph::Cache.
|
38
|
+
File.join(Solargraph::Cache.base_dir, "yard-#{YARD::VERSION}", "#{gemspec.name}-#{gemspec.version}.yardoc")
|
39
39
|
end
|
40
40
|
|
41
41
|
# Load a gem's yardoc and return its code objects.
|
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.55.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-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -410,6 +410,9 @@ files:
|
|
410
410
|
- lib/solargraph/convention/gemfile.rb
|
411
411
|
- lib/solargraph/convention/gemspec.rb
|
412
412
|
- lib/solargraph/convention/rakefile.rb
|
413
|
+
- lib/solargraph/convention/struct_definition.rb
|
414
|
+
- lib/solargraph/convention/struct_definition/struct_assignment_node.rb
|
415
|
+
- lib/solargraph/convention/struct_definition/struct_definition_node.rb
|
413
416
|
- lib/solargraph/converters/dd.rb
|
414
417
|
- lib/solargraph/converters/dl.rb
|
415
418
|
- lib/solargraph/converters/dt.rb
|
@@ -493,6 +496,7 @@ files:
|
|
493
496
|
- lib/solargraph/page.rb
|
494
497
|
- lib/solargraph/parser.rb
|
495
498
|
- lib/solargraph/parser/comment_ripper.rb
|
499
|
+
- lib/solargraph/parser/flow_sensitive_typing.rb
|
496
500
|
- lib/solargraph/parser/node_methods.rb
|
497
501
|
- lib/solargraph/parser/node_processor.rb
|
498
502
|
- lib/solargraph/parser/node_processor/base.rb
|
@@ -503,6 +507,7 @@ files:
|
|
503
507
|
- lib/solargraph/parser/parser_gem/node_methods.rb
|
504
508
|
- lib/solargraph/parser/parser_gem/node_processors.rb
|
505
509
|
- lib/solargraph/parser/parser_gem/node_processors/alias_node.rb
|
510
|
+
- lib/solargraph/parser/parser_gem/node_processors/and_node.rb
|
506
511
|
- lib/solargraph/parser/parser_gem/node_processors/args_node.rb
|
507
512
|
- lib/solargraph/parser/parser_gem/node_processors/begin_node.rb
|
508
513
|
- lib/solargraph/parser/parser_gem/node_processors/block_node.rb
|
@@ -511,21 +516,26 @@ files:
|
|
511
516
|
- lib/solargraph/parser/parser_gem/node_processors/def_node.rb
|
512
517
|
- lib/solargraph/parser/parser_gem/node_processors/defs_node.rb
|
513
518
|
- lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb
|
519
|
+
- lib/solargraph/parser/parser_gem/node_processors/if_node.rb
|
514
520
|
- lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb
|
515
521
|
- lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb
|
516
522
|
- lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb
|
517
523
|
- lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb
|
524
|
+
- lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb
|
518
525
|
- lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb
|
519
526
|
- lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb
|
520
527
|
- lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb
|
521
528
|
- lib/solargraph/parser/parser_gem/node_processors/send_node.rb
|
522
529
|
- lib/solargraph/parser/parser_gem/node_processors/sym_node.rb
|
530
|
+
- lib/solargraph/parser/parser_gem/node_processors/until_node.rb
|
531
|
+
- lib/solargraph/parser/parser_gem/node_processors/while_node.rb
|
523
532
|
- lib/solargraph/parser/region.rb
|
524
533
|
- lib/solargraph/parser/snippet.rb
|
525
534
|
- lib/solargraph/pin.rb
|
526
535
|
- lib/solargraph/pin/base.rb
|
527
536
|
- lib/solargraph/pin/base_variable.rb
|
528
537
|
- lib/solargraph/pin/block.rb
|
538
|
+
- lib/solargraph/pin/breakable.rb
|
529
539
|
- lib/solargraph/pin/callable.rb
|
530
540
|
- lib/solargraph/pin/class_variable.rb
|
531
541
|
- lib/solargraph/pin/closure.rb
|
@@ -556,6 +566,8 @@ files:
|
|
556
566
|
- lib/solargraph/pin/signature.rb
|
557
567
|
- lib/solargraph/pin/singleton.rb
|
558
568
|
- lib/solargraph/pin/symbol.rb
|
569
|
+
- lib/solargraph/pin/until.rb
|
570
|
+
- lib/solargraph/pin/while.rb
|
559
571
|
- lib/solargraph/position.rb
|
560
572
|
- lib/solargraph/range.rb
|
561
573
|
- lib/solargraph/rbs_map.rb
|
@@ -643,7 +655,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
643
655
|
- !ruby/object:Gem::Version
|
644
656
|
version: '0'
|
645
657
|
requirements: []
|
646
|
-
rubygems_version: 3.
|
658
|
+
rubygems_version: 3.5.22
|
647
659
|
signing_key:
|
648
660
|
specification_version: 4
|
649
661
|
summary: A Ruby language server
|