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.
- checksums.yaml +4 -4
- data/.github/workflows/plugins.yml +40 -0
- data/.github/workflows/rspec.yml +1 -3
- data/.github/workflows/typecheck.yml +34 -0
- data/.yardopts +2 -2
- data/CHANGELOG.md +55 -5
- data/README.md +13 -16
- data/SPONSORS.md +1 -7
- data/lib/solargraph/api_map/cache.rb +60 -20
- data/lib/solargraph/api_map/store.rb +47 -11
- data/lib/solargraph/api_map.rb +161 -95
- data/lib/solargraph/bench.rb +2 -2
- data/lib/solargraph/cache.rb +29 -5
- data/lib/solargraph/complex_type/type_methods.rb +54 -9
- data/lib/solargraph/complex_type/unique_type.rb +155 -58
- data/lib/solargraph/complex_type.rb +73 -16
- data/lib/solargraph/convention.rb +0 -1
- data/lib/solargraph/converters/dd.rb +5 -0
- data/lib/solargraph/converters/dl.rb +3 -0
- data/lib/solargraph/converters/dt.rb +3 -0
- data/lib/solargraph/diagnostics/rubocop.rb +8 -7
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +1 -0
- data/lib/solargraph/diagnostics/type_check.rb +1 -0
- data/lib/solargraph/diagnostics.rb +2 -2
- data/lib/solargraph/doc_map.rb +146 -0
- data/lib/solargraph/gem_pins.rb +64 -0
- data/lib/solargraph/language_server/host/cataloger.rb +1 -0
- data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
- data/lib/solargraph/language_server/host/dispatch.rb +10 -4
- data/lib/solargraph/language_server/host/message_worker.rb +4 -0
- data/lib/solargraph/language_server/host/sources.rb +7 -4
- data/lib/solargraph/language_server/host.rb +15 -6
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
- data/lib/solargraph/language_server/message/initialize.rb +5 -2
- data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
- data/lib/solargraph/language_server/message/text_document.rb +0 -1
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
- data/lib/solargraph/language_server/transport/adapter.rb +16 -1
- data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
- data/lib/solargraph/library.rb +70 -16
- data/lib/solargraph/location.rb +1 -0
- data/lib/solargraph/parser/comment_ripper.rb +4 -0
- data/lib/solargraph/parser/node_methods.rb +47 -7
- data/lib/solargraph/parser/node_processor/base.rb +9 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -5
- data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +49 -36
- data/lib/solargraph/parser/parser_gem/node_methods.rb +499 -0
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/args_node.rb +4 -1
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/def_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sclass_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/sym_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
- data/lib/solargraph/parser/parser_gem.rb +12 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/parser.rb +8 -9
- data/lib/solargraph/pin/base.rb +64 -9
- data/lib/solargraph/pin/base_variable.rb +6 -2
- data/lib/solargraph/pin/block.rb +13 -8
- data/lib/solargraph/pin/closure.rb +17 -2
- data/lib/solargraph/pin/common.rb +7 -3
- data/lib/solargraph/pin/conversions.rb +33 -3
- data/lib/solargraph/pin/delegated_method.rb +1 -1
- data/lib/solargraph/pin/documenting.rb +25 -34
- data/lib/solargraph/pin/instance_variable.rb +4 -0
- data/lib/solargraph/pin/local_variable.rb +13 -1
- data/lib/solargraph/pin/method.rb +169 -18
- data/lib/solargraph/pin/namespace.rb +18 -5
- data/lib/solargraph/pin/parameter.rb +44 -14
- data/lib/solargraph/pin/reference/override.rb +2 -2
- data/lib/solargraph/pin/reference.rb +8 -0
- data/lib/solargraph/pin/search.rb +3 -3
- data/lib/solargraph/pin/signature.rb +123 -3
- data/lib/solargraph/pin.rb +0 -1
- data/lib/solargraph/range.rb +2 -2
- data/lib/solargraph/rbs_map/conversions.rb +287 -45
- data/lib/solargraph/rbs_map/core_fills.rb +6 -29
- data/lib/solargraph/rbs_map/core_map.rb +2 -1
- data/lib/solargraph/rbs_map/core_signs.rb +2 -0
- data/lib/solargraph/rbs_map/stdlib_map.rb +2 -8
- data/lib/solargraph/rbs_map.rb +20 -11
- data/lib/solargraph/shell.rb +62 -59
- data/lib/solargraph/source/chain/array.rb +32 -0
- data/lib/solargraph/source/chain/block_symbol.rb +13 -0
- data/lib/solargraph/source/chain/call.rb +99 -46
- data/lib/solargraph/source/chain/constant.rb +15 -1
- data/lib/solargraph/source/chain/if.rb +23 -0
- data/lib/solargraph/source/chain/link.rb +8 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain/z_super.rb +3 -3
- data/lib/solargraph/source/chain.rb +29 -14
- data/lib/solargraph/source/change.rb +3 -0
- data/lib/solargraph/source/cursor.rb +2 -0
- data/lib/solargraph/source/source_chainer.rb +8 -5
- data/lib/solargraph/source.rb +18 -19
- data/lib/solargraph/source_map/clip.rb +11 -23
- data/lib/solargraph/source_map/mapper.rb +12 -1
- data/lib/solargraph/source_map.rb +15 -5
- data/lib/solargraph/type_checker/checks.rb +10 -2
- data/lib/solargraph/type_checker.rb +92 -26
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +8 -6
- data/lib/solargraph/workspace.rb +3 -2
- data/lib/solargraph/yard_map/cache.rb +6 -0
- data/lib/solargraph/yard_map/helpers.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +11 -1
- data/lib/solargraph/yard_map/mapper.rb +1 -1
- data/lib/solargraph/yard_map/to_method.rb +11 -4
- data/lib/solargraph/yard_map.rb +1 -292
- data/lib/solargraph/yard_tags.rb +20 -0
- data/lib/solargraph/yardoc.rb +52 -0
- data/lib/solargraph.rb +6 -4
- data/solargraph.gemspec +3 -2
- metadata +51 -58
- data/lib/solargraph/api_map/bundler_methods.rb +0 -22
- data/lib/solargraph/documentor.rb +0 -76
- data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
- data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
- data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
- data/lib/solargraph/parser/legacy/node_processors/sym_node.rb +0 -18
- data/lib/solargraph/parser/legacy/node_processors.rb +0 -55
- data/lib/solargraph/parser/legacy.rb +0 -12
- data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -153
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
- data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -317
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
- data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -33
- data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/def_node.rb +0 -75
- data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -68
- data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
- data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
- data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
- data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -51
- data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -32
- data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -279
- data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -64
- data/lib/solargraph/parser/rubyvm/node_wrapper.rb +0 -47
- data/lib/solargraph/parser/rubyvm.rb +0 -40
- data/lib/yard-solargraph.rb +0 -33
@@ -1,23 +1,143 @@
|
|
1
1
|
module Solargraph
|
2
2
|
module Pin
|
3
|
-
class Signature
|
4
|
-
# @return [Array<Parameter>]
|
3
|
+
class Signature < Base
|
4
|
+
# @return [::Array<Parameter>]
|
5
5
|
attr_reader :parameters
|
6
6
|
|
7
7
|
# @return [ComplexType]
|
8
8
|
attr_reader :return_type
|
9
9
|
|
10
|
+
# @return [self]
|
10
11
|
attr_reader :block
|
11
12
|
|
12
|
-
|
13
|
+
# @param generics [Array<String>]
|
14
|
+
# @param parameters [Array<Parameter>]
|
15
|
+
# @param return_type [ComplexType]
|
16
|
+
# @param block [Signature, nil]
|
17
|
+
def initialize generics, parameters, return_type, block = nil
|
18
|
+
@generics = generics
|
13
19
|
@parameters = parameters
|
14
20
|
@return_type = return_type
|
15
21
|
@block = block
|
16
22
|
end
|
17
23
|
|
24
|
+
def generics
|
25
|
+
@generics ||= [].freeze
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [String]
|
29
|
+
def to_rbs
|
30
|
+
rbs_generics + '(' + parameters.map { |param| param.to_rbs }.join(', ') + ') ' + (block.nil? ? '' : '{ ' + block.to_rbs + ' } ') + '-> ' + return_type.to_rbs
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [String]
|
34
|
+
def rbs_generics
|
35
|
+
if generics.empty?
|
36
|
+
return ''
|
37
|
+
else
|
38
|
+
return '[' + generics.map { |gen| gen.to_s }.join(', ') + '] '
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Array<String>]
|
43
|
+
# @yieldparam [ComplexType]
|
44
|
+
# @yieldreturn [ComplexType]
|
45
|
+
# @return [self]
|
46
|
+
def transform_types(&transform)
|
47
|
+
# @todo 'super' alone should work here I think, but doesn't typecheck at level typed
|
48
|
+
signature = super(&transform)
|
49
|
+
signature.parameters = signature.parameters.map do |param|
|
50
|
+
param.transform_types(&transform)
|
51
|
+
end
|
52
|
+
signature.block = block.transform_types(&transform) if signature.block?
|
53
|
+
signature
|
54
|
+
end
|
55
|
+
|
56
|
+
# @param generics_to_resolve [Enumerable<String>]
|
57
|
+
# @param arg_types [Array<ComplexType>, nil]
|
58
|
+
# @param return_type_context [ComplexType, nil]
|
59
|
+
# @param yield_arg_types [Array<ComplexType>, nil]
|
60
|
+
# @param yield_return_type_context [ComplexType, nil]
|
61
|
+
# @param context [ComplexType, nil]
|
62
|
+
# @param resolved_generic_values [Hash{String => ComplexType}]
|
63
|
+
# @return [self]
|
64
|
+
def resolve_generics_from_context(generics_to_resolve,
|
65
|
+
arg_types = nil,
|
66
|
+
return_type_context = nil,
|
67
|
+
yield_arg_types = nil,
|
68
|
+
yield_return_type_context = nil,
|
69
|
+
resolved_generic_values: {})
|
70
|
+
signature = super(generics_to_resolve, return_type_context, resolved_generic_values: resolved_generic_values)
|
71
|
+
signature.parameters = signature.parameters.each_with_index.map do |param, i|
|
72
|
+
if arg_types.nil?
|
73
|
+
param.dup
|
74
|
+
else
|
75
|
+
param.resolve_generics_from_context(generics_to_resolve,
|
76
|
+
arg_types[i],
|
77
|
+
resolved_generic_values: resolved_generic_values)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
signature.block = block.resolve_generics_from_context(generics_to_resolve,
|
81
|
+
yield_arg_types,
|
82
|
+
yield_return_type_context,
|
83
|
+
resolved_generic_values: resolved_generic_values) if signature.block?
|
84
|
+
signature
|
85
|
+
end
|
86
|
+
|
87
|
+
# @param generics_to_resolve [Enumerable<String>]
|
88
|
+
# @param arg_types [Array<ComplexType>, nil]
|
89
|
+
# @param return_type_context [ComplexType, nil]
|
90
|
+
# @param yield_arg_types [Array<ComplexType>, nil]
|
91
|
+
# @param yield_return_type_context [ComplexType, nil]
|
92
|
+
# @param context [ComplexType, nil]
|
93
|
+
# @param resolved_generic_values [Hash{String => ComplexType}]
|
94
|
+
# @return [self]
|
95
|
+
def resolve_generics_from_context_until_complete(generics_to_resolve,
|
96
|
+
arg_types = nil,
|
97
|
+
return_type_context = nil,
|
98
|
+
yield_arg_types = nil,
|
99
|
+
yield_return_type_context = nil,
|
100
|
+
resolved_generic_values: {})
|
101
|
+
# See
|
102
|
+
# https://github.com/soutaro/steep/tree/master/lib/steep/type_inference
|
103
|
+
# and
|
104
|
+
# https://github.com/sorbet/sorbet/blob/master/infer/inference.cc
|
105
|
+
# for other implementations
|
106
|
+
|
107
|
+
return self if generics_to_resolve.empty?
|
108
|
+
|
109
|
+
last_resolved_generic_values = resolved_generic_values.dup
|
110
|
+
new_pin = resolve_generics_from_context(generics_to_resolve,
|
111
|
+
arg_types,
|
112
|
+
return_type_context,
|
113
|
+
yield_arg_types,
|
114
|
+
yield_return_type_context,
|
115
|
+
resolved_generic_values: resolved_generic_values)
|
116
|
+
if last_resolved_generic_values == resolved_generic_values
|
117
|
+
# erase anything unresolved
|
118
|
+
return new_pin.erase_generics(self.generics)
|
119
|
+
end
|
120
|
+
new_pin.resolve_generics_from_context_until_complete(generics_to_resolve,
|
121
|
+
arg_types,
|
122
|
+
return_type_context,
|
123
|
+
yield_arg_types,
|
124
|
+
yield_return_type_context,
|
125
|
+
resolved_generic_values: resolved_generic_values)
|
126
|
+
end
|
127
|
+
|
128
|
+
def identity
|
129
|
+
@identity ||= "signature#{object_id}"
|
130
|
+
end
|
131
|
+
|
18
132
|
def block?
|
19
133
|
!!@block
|
20
134
|
end
|
135
|
+
|
136
|
+
protected
|
137
|
+
|
138
|
+
attr_writer :block
|
139
|
+
|
140
|
+
attr_writer :parameters
|
21
141
|
end
|
22
142
|
end
|
23
143
|
end
|
data/lib/solargraph/pin.rb
CHANGED
@@ -27,7 +27,6 @@ module Solargraph
|
|
27
27
|
autoload :Reference, 'solargraph/pin/reference'
|
28
28
|
autoload :Documenting, 'solargraph/pin/documenting'
|
29
29
|
autoload :Block, 'solargraph/pin/block'
|
30
|
-
autoload :Localized, 'solargraph/pin/localized'
|
31
30
|
autoload :ProxyType, 'solargraph/pin/proxy_type'
|
32
31
|
autoload :DuckMethod, 'solargraph/pin/duck_method'
|
33
32
|
autoload :Singleton, 'solargraph/pin/singleton'
|
data/lib/solargraph/range.rb
CHANGED
@@ -62,8 +62,8 @@ module Solargraph
|
|
62
62
|
|
63
63
|
# Get a range from a node.
|
64
64
|
#
|
65
|
-
# @param node [
|
66
|
-
# @return [Range]
|
65
|
+
# @param node [Parser::AST::Node]
|
66
|
+
# @return [Range, nil]
|
67
67
|
def self.from_node node
|
68
68
|
if Parser.rubyvm? && node.is_a?(RubyVM::AbstractSyntaxTree::Node)
|
69
69
|
Solargraph::Range.from_to(node.first_lineno - 1, node.first_column, node.last_lineno - 1, node.last_column)
|