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.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/plugins.yml +40 -0
- data/.github/workflows/rspec.yml +4 -8
- data/.github/workflows/typecheck.yml +34 -0
- data/.yardopts +2 -2
- data/CHANGELOG.md +137 -3
- data/LICENSE +1 -1
- data/README.md +19 -16
- data/SPONSORS.md +2 -9
- data/lib/solargraph/api_map/cache.rb +60 -20
- data/lib/solargraph/api_map/source_to_yard.rb +17 -10
- data/lib/solargraph/api_map/store.rb +60 -12
- data/lib/solargraph/api_map.rb +171 -99
- data/lib/solargraph/bench.rb +3 -2
- data/lib/solargraph/cache.rb +77 -0
- data/lib/solargraph/complex_type/type_methods.rb +61 -12
- data/lib/solargraph/complex_type/unique_type.rb +193 -16
- data/lib/solargraph/complex_type.rb +113 -10
- data/lib/solargraph/convention/rakefile.rb +17 -0
- data/lib/solargraph/convention.rb +2 -3
- 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 +23 -8
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -1
- data/lib/solargraph/diagnostics/type_check.rb +1 -0
- data/lib/solargraph/diagnostics.rb +2 -2
- data/lib/solargraph/doc_map.rb +171 -0
- data/lib/solargraph/gem_pins.rb +64 -0
- data/lib/solargraph/language_server/host/cataloger.rb +2 -1
- data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
- data/lib/solargraph/language_server/host/dispatch.rb +15 -5
- 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 +50 -26
- 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/extended/download_core.rb +1 -5
- data/lib/solargraph/language_server/message/initialize.rb +13 -0
- data/lib/solargraph/language_server/message/initialized.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +4 -1
- data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -4
- data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -6
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +24 -0
- data/lib/solargraph/language_server/message/text_document.rb +1 -1
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +10 -3
- data/lib/solargraph/language_server/message.rb +1 -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 +124 -37
- data/lib/solargraph/location.rb +1 -0
- data/lib/solargraph/page.rb +6 -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 +57 -41
- 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/parser_gem/node_processors/args_node.rb +53 -0
- 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 +14 -4
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/def_node.rb +7 -20
- 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/parser_gem/node_processors/sclass_node.rb +42 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → 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 +9 -10
- data/lib/solargraph/pin/base.rb +69 -11
- data/lib/solargraph/pin/base_variable.rb +8 -4
- data/lib/solargraph/pin/block.rb +21 -28
- data/lib/solargraph/pin/closure.rb +17 -2
- data/lib/solargraph/pin/common.rb +7 -3
- data/lib/solargraph/pin/conversions.rb +34 -8
- data/lib/solargraph/pin/delegated_method.rb +97 -0
- 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 +270 -16
- data/lib/solargraph/pin/namespace.rb +17 -1
- data/lib/solargraph/pin/parameter.rb +52 -17
- data/lib/solargraph/pin/reference/override.rb +2 -2
- data/lib/solargraph/pin/reference.rb +8 -0
- data/lib/solargraph/pin/search.rb +4 -4
- data/lib/solargraph/pin/signature.rb +143 -0
- data/lib/solargraph/pin.rb +2 -1
- data/lib/solargraph/range.rb +4 -6
- data/lib/solargraph/rbs_map/conversions.rb +601 -0
- data/lib/solargraph/rbs_map/core_fills.rb +47 -0
- data/lib/solargraph/rbs_map/core_map.rb +28 -0
- data/lib/solargraph/rbs_map/stdlib_map.rb +33 -0
- data/lib/solargraph/rbs_map.rb +84 -0
- data/lib/solargraph/shell.rb +69 -48
- 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 +125 -61
- 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 +44 -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 +30 -23
- data/lib/solargraph/source_map/mapper.rb +20 -5
- data/lib/solargraph/source_map.rb +28 -13
- data/lib/solargraph/type_checker/checks.rb +10 -2
- data/lib/solargraph/type_checker.rb +201 -98
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +2 -2
- data/lib/solargraph/workspace/config.rb +14 -11
- data/lib/solargraph/workspace.rb +28 -17
- 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 +18 -5
- 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 -443
- data/lib/solargraph/yard_tags.rb +20 -0
- data/lib/solargraph/yardoc.rb +52 -0
- data/lib/solargraph.rb +8 -6
- data/solargraph.gemspec +19 -8
- metadata +162 -98
- data/.travis.yml +0 -19
- data/lib/solargraph/api_map/bundler_methods.rb +0 -22
- data/lib/solargraph/compat.rb +0 -37
- data/lib/solargraph/convention/rspec.rb +0 -30
- 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/args_node.rb +0 -35
- data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
- data/lib/solargraph/parser/legacy/node_processors/def_node.rb +0 -63
- data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +0 -21
- data/lib/solargraph/parser/legacy/node_processors.rb +0 -54
- data/lib/solargraph/parser/legacy.rb +0 -12
- data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -144
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
- data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -315
- 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 -22
- data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -57
- 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 -45
- data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -21
- data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -277
- data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +0 -18
- data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -63
- data/lib/solargraph/parser/rubyvm.rb +0 -40
- data/lib/solargraph/yard_map/core_docs.rb +0 -170
- data/lib/solargraph/yard_map/core_fills.rb +0 -208
- data/lib/solargraph/yard_map/core_gen.rb +0 -76
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +0 -140
- data/lib/solargraph/yard_map/stdlib_fills.rb +0 -43
- data/lib/yard-solargraph.rb +0 -33
- data/yardoc/2.2.2.tar.gz +0 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
module Solargraph
|
2
|
+
module Pin
|
3
|
+
class Signature < Base
|
4
|
+
# @return [::Array<Parameter>]
|
5
|
+
attr_reader :parameters
|
6
|
+
|
7
|
+
# @return [ComplexType]
|
8
|
+
attr_reader :return_type
|
9
|
+
|
10
|
+
# @return [self]
|
11
|
+
attr_reader :block
|
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
|
19
|
+
@parameters = parameters
|
20
|
+
@return_type = return_type
|
21
|
+
@block = block
|
22
|
+
end
|
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
|
+
|
132
|
+
def block?
|
133
|
+
!!@block
|
134
|
+
end
|
135
|
+
|
136
|
+
protected
|
137
|
+
|
138
|
+
attr_writer :block
|
139
|
+
|
140
|
+
attr_writer :parameters
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
data/lib/solargraph/pin.rb
CHANGED
@@ -10,7 +10,9 @@ module Solargraph
|
|
10
10
|
autoload :Conversions, 'solargraph/pin/conversions'
|
11
11
|
autoload :Base, 'solargraph/pin/base'
|
12
12
|
autoload :Method, 'solargraph/pin/method'
|
13
|
+
autoload :Signature, 'solargraph/pin/signature'
|
13
14
|
autoload :MethodAlias, 'solargraph/pin/method_alias'
|
15
|
+
autoload :DelegatedMethod, 'solargraph/pin/delegated_method'
|
14
16
|
autoload :BaseVariable, 'solargraph/pin/base_variable'
|
15
17
|
autoload :InstanceVariable, 'solargraph/pin/instance_variable'
|
16
18
|
autoload :ClassVariable, 'solargraph/pin/class_variable'
|
@@ -25,7 +27,6 @@ module Solargraph
|
|
25
27
|
autoload :Reference, 'solargraph/pin/reference'
|
26
28
|
autoload :Documenting, 'solargraph/pin/documenting'
|
27
29
|
autoload :Block, 'solargraph/pin/block'
|
28
|
-
autoload :Localized, 'solargraph/pin/localized'
|
29
30
|
autoload :ProxyType, 'solargraph/pin/proxy_type'
|
30
31
|
autoload :DuckMethod, 'solargraph/pin/duck_method'
|
31
32
|
autoload :Singleton, 'solargraph/pin/singleton'
|
data/lib/solargraph/range.rb
CHANGED
@@ -62,13 +62,11 @@ 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
|
-
if
|
69
|
-
|
70
|
-
Solargraph::Range.from_to(node.first_lineno - 1, node.first_column, node.last_lineno - 1, node.last_column)
|
71
|
-
end
|
68
|
+
if Parser.rubyvm? && node.is_a?(RubyVM::AbstractSyntaxTree::Node)
|
69
|
+
Solargraph::Range.from_to(node.first_lineno - 1, node.first_column, node.last_lineno - 1, node.last_column)
|
72
70
|
elsif node&.loc && node.loc.expression
|
73
71
|
from_expr(node.loc.expression)
|
74
72
|
end
|