solargraph 0.55.3 → 0.55.5
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 +2 -0
- data/.github/workflows/typecheck.yml +3 -1
- data/.gitignore +2 -0
- data/CHANGELOG.md +7 -1
- data/README.md +13 -3
- data/lib/solargraph/api_map/index.rb +23 -15
- data/lib/solargraph/api_map/store.rb +8 -4
- data/lib/solargraph/api_map.rb +150 -57
- data/lib/solargraph/complex_type/type_methods.rb +6 -1
- data/lib/solargraph/complex_type/unique_type.rb +10 -2
- data/lib/solargraph/convention/base.rb +3 -3
- data/lib/solargraph/convention.rb +3 -3
- data/lib/solargraph/doc_map.rb +192 -46
- data/lib/solargraph/gem_pins.rb +53 -37
- data/lib/solargraph/language_server/host.rb +11 -2
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +2 -0
- data/lib/solargraph/language_server/message/extended/document.rb +5 -2
- data/lib/solargraph/language_server/message/extended/document_gems.rb +3 -3
- data/lib/solargraph/library.rb +7 -4
- data/lib/solargraph/location.rb +13 -0
- data/lib/solargraph/logging.rb +1 -0
- data/lib/solargraph/parser/comment_ripper.rb +1 -0
- data/lib/solargraph/parser/flow_sensitive_typing.rb +2 -1
- data/lib/solargraph/parser/node_processor.rb +3 -1
- data/lib/solargraph/parser/parser_gem/class_methods.rb +5 -8
- data/lib/solargraph/parser/parser_gem/node_methods.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +4 -3
- data/lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +6 -3
- data/lib/solargraph/parser/parser_gem/node_processors/defs_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +4 -2
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +6 -4
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +4 -3
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +28 -16
- data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +2 -1
- data/lib/solargraph/parser/parser_gem/node_processors/until_node.rb +1 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +1 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/pin/base.rb +295 -28
- data/lib/solargraph/pin/base_variable.rb +9 -8
- data/lib/solargraph/pin/callable.rb +74 -3
- data/lib/solargraph/pin/closure.rb +18 -1
- data/lib/solargraph/pin/common.rb +5 -0
- data/lib/solargraph/pin/delegated_method.rb +2 -0
- data/lib/solargraph/pin/documenting.rb +16 -0
- data/lib/solargraph/pin/keyword.rb +7 -2
- data/lib/solargraph/pin/local_variable.rb +8 -5
- data/lib/solargraph/pin/method.rb +147 -25
- data/lib/solargraph/pin/namespace.rb +7 -2
- data/lib/solargraph/pin/parameter.rb +47 -6
- data/lib/solargraph/pin/proxy_type.rb +3 -3
- data/lib/solargraph/pin/reference/override.rb +10 -6
- data/lib/solargraph/pin/reference/require.rb +2 -2
- data/lib/solargraph/pin/signature.rb +42 -0
- data/lib/solargraph/pin/singleton.rb +1 -1
- data/lib/solargraph/pin/symbol.rb +3 -2
- data/lib/solargraph/pin.rb +1 -1
- data/lib/solargraph/pin_cache.rb +185 -0
- data/lib/solargraph/position.rb +9 -0
- data/lib/solargraph/range.rb +9 -0
- data/lib/solargraph/rbs_map/conversions.rb +183 -56
- data/lib/solargraph/rbs_map/core_fills.rb +24 -15
- data/lib/solargraph/rbs_map/core_map.rb +34 -11
- data/lib/solargraph/rbs_map/stdlib_map.rb +15 -5
- data/lib/solargraph/rbs_map.rb +74 -17
- data/lib/solargraph/shell.rb +12 -15
- data/lib/solargraph/source/chain/array.rb +7 -4
- data/lib/solargraph/source/chain/block_symbol.rb +1 -1
- data/lib/solargraph/source/chain/block_variable.rb +1 -1
- data/lib/solargraph/source/chain/call.rb +8 -7
- data/lib/solargraph/source/chain/hash.rb +1 -1
- data/lib/solargraph/source/chain/head.rb +1 -1
- data/lib/solargraph/source/chain/if.rb +1 -1
- data/lib/solargraph/source/chain/literal.rb +2 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain.rb +2 -2
- data/lib/solargraph/source_map/mapper.rb +9 -5
- data/lib/solargraph/source_map.rb +0 -17
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/_method.erb +10 -10
- data/lib/solargraph/views/_namespace.erb +3 -3
- data/lib/solargraph/views/document.erb +10 -10
- data/lib/solargraph/workspace.rb +15 -5
- data/lib/solargraph/yard_map/mapper/to_constant.rb +4 -2
- data/lib/solargraph/yard_map/mapper/to_method.rb +14 -1
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +4 -2
- data/lib/solargraph/yard_map/mapper.rb +4 -3
- data/lib/solargraph/yard_map/to_method.rb +4 -2
- data/lib/solargraph/yardoc.rb +3 -11
- data/lib/solargraph.rb +18 -1
- data/rbs/fills/tuple.rbs +150 -0
- data/rbs_collection.yaml +19 -0
- data/solargraph.gemspec +1 -0
- metadata +20 -7
- data/lib/solargraph/cache.rb +0 -77
@@ -12,7 +12,8 @@ module Solargraph
|
|
12
12
|
closure: region.closure,
|
13
13
|
name: node.children[0].children[0].to_s,
|
14
14
|
original: node.children[1].children[0].to_s,
|
15
|
-
scope: region.scope || :instance
|
15
|
+
scope: region.scope || :instance,
|
16
|
+
source: :parser
|
16
17
|
)
|
17
18
|
process_children
|
18
19
|
end
|
@@ -21,7 +21,8 @@ module Solargraph
|
|
21
21
|
assignment: u.children[1],
|
22
22
|
asgn_code: u.children[1] ? region.code_for(u.children[1]) : nil,
|
23
23
|
presence: callable.location.range,
|
24
|
-
decl: get_decl(u)
|
24
|
+
decl: get_decl(u),
|
25
|
+
source: :parser
|
25
26
|
)
|
26
27
|
callable.parameters.push locals.last
|
27
28
|
end
|
@@ -40,7 +41,8 @@ module Solargraph
|
|
40
41
|
location: loc,
|
41
42
|
closure: callable,
|
42
43
|
presence: region.closure.location.range,
|
43
|
-
decl: get_decl(node)
|
44
|
+
decl: get_decl(node),
|
45
|
+
source: :parser
|
44
46
|
)
|
45
47
|
callable.parameters.push locals.last
|
46
48
|
end
|
@@ -13,7 +13,8 @@ module Solargraph
|
|
13
13
|
Solargraph::Pin::Namespace.new(
|
14
14
|
location: location,
|
15
15
|
type: :class,
|
16
|
-
name: unpack_name(node.children[0].children[0])
|
16
|
+
name: unpack_name(node.children[0].children[0]),
|
17
|
+
source: :parser,
|
17
18
|
)
|
18
19
|
else
|
19
20
|
region.closure
|
@@ -24,7 +25,8 @@ module Solargraph
|
|
24
25
|
node: node,
|
25
26
|
receiver: node.children[0],
|
26
27
|
comments: comments_for(node),
|
27
|
-
scope: region.scope || region.closure.context.scope
|
28
|
+
scope: region.scope || region.closure.context.scope,
|
29
|
+
source: :parser
|
28
30
|
)
|
29
31
|
process_children region.update(closure: pins.last)
|
30
32
|
end
|
@@ -24,13 +24,14 @@ module Solargraph
|
|
24
24
|
closure: region.closure,
|
25
25
|
name: const_name,
|
26
26
|
comments: comments_for(node),
|
27
|
-
assignment: node.children[2]
|
27
|
+
assignment: node.children[2],
|
28
|
+
source: :parser
|
28
29
|
)
|
29
30
|
process_children
|
30
31
|
end
|
31
32
|
|
32
|
-
#
|
33
|
-
#
|
33
|
+
# @todo Move this out of [CasgnNode] once [Solargraph::Parser::NodeProcessor] supports
|
34
|
+
# multiple processors.
|
34
35
|
def process_struct_assignment
|
35
36
|
processor_klass = Convention::StructDefinition::NodeProcessors::StructNode
|
36
37
|
processor = processor_klass.new(node, region, pins, locals)
|
@@ -15,7 +15,8 @@ module Solargraph
|
|
15
15
|
comments: comments_for(node),
|
16
16
|
scope: scope,
|
17
17
|
visibility: scope == :instance && name == 'initialize' ? :private : region.visibility,
|
18
|
-
node: node
|
18
|
+
node: node,
|
19
|
+
source: :parser,
|
19
20
|
)
|
20
21
|
if region.visibility == :module_function
|
21
22
|
pins.push Solargraph::Pin::Method.new(
|
@@ -26,7 +27,8 @@ module Solargraph
|
|
26
27
|
scope: :class,
|
27
28
|
visibility: :public,
|
28
29
|
parameters: methpin.parameters,
|
29
|
-
node: methpin.node
|
30
|
+
node: methpin.node,
|
31
|
+
source: :parser,
|
30
32
|
)
|
31
33
|
pins.push Solargraph::Pin::Method.new(
|
32
34
|
location: methpin.location,
|
@@ -36,7 +38,8 @@ module Solargraph
|
|
36
38
|
scope: :instance,
|
37
39
|
visibility: :private,
|
38
40
|
parameters: methpin.parameters,
|
39
|
-
node: methpin.node
|
41
|
+
node: methpin.node,
|
42
|
+
source: :parser,
|
40
43
|
)
|
41
44
|
else
|
42
45
|
pins.push methpin
|
@@ -14,7 +14,8 @@ module Solargraph
|
|
14
14
|
closure: region.closure,
|
15
15
|
name: node.children[0].to_s,
|
16
16
|
comments: comments_for(node),
|
17
|
-
assignment: node.children[1]
|
17
|
+
assignment: node.children[1],
|
18
|
+
source: :parser
|
18
19
|
)
|
19
20
|
if region.visibility == :module_function
|
20
21
|
here = get_node_start_position(node)
|
@@ -25,7 +26,8 @@ module Solargraph
|
|
25
26
|
closure: Pin::Namespace.new(type: :module, closure: region.closure.closure, name: region.closure.name),
|
26
27
|
name: node.children[0].to_s,
|
27
28
|
comments: comments_for(node),
|
28
|
-
assignment: node.children[1]
|
29
|
+
assignment: node.children[1],
|
30
|
+
source: :parser
|
29
31
|
)
|
30
32
|
end
|
31
33
|
end
|
@@ -30,21 +30,23 @@ module Solargraph
|
|
30
30
|
name: unpack_name(node.children[0]),
|
31
31
|
comments: comments_for(node),
|
32
32
|
visibility: :public,
|
33
|
-
gates: region.closure.gates.freeze
|
33
|
+
gates: region.closure.gates.freeze,
|
34
|
+
source: :parser
|
34
35
|
)
|
35
36
|
pins.push nspin
|
36
37
|
unless superclass_name.nil?
|
37
38
|
pins.push Pin::Reference::Superclass.new(
|
38
39
|
location: loc,
|
39
40
|
closure: pins.last,
|
40
|
-
name: superclass_name
|
41
|
+
name: superclass_name,
|
42
|
+
source: :parser
|
41
43
|
)
|
42
44
|
end
|
43
45
|
process_children region.update(closure: nspin, visibility: :public)
|
44
46
|
end
|
45
47
|
|
46
|
-
#
|
47
|
-
#
|
48
|
+
# @todo Move this out of [NamespaceNode] once [Solargraph::Parser::NodeProcessor] supports
|
49
|
+
# multiple processors.
|
48
50
|
def process_struct_definition
|
49
51
|
processor_klass = Convention::StructDefinition::NodeProcessors::StructNode
|
50
52
|
processor = processor_klass.new(node, region, pins, locals)
|
@@ -24,7 +24,8 @@ module Solargraph
|
|
24
24
|
closure: region.closure,
|
25
25
|
name: node.children[1].children[0].to_s,
|
26
26
|
comments: "@type [#{types.join(',')}]",
|
27
|
-
presence: presence
|
27
|
+
presence: presence,
|
28
|
+
source: :parser
|
28
29
|
)
|
29
30
|
end
|
30
31
|
NodeProcessor.process(node.children[2], region, pins, locals)
|
@@ -17,7 +17,7 @@ module Solargraph
|
|
17
17
|
names.concat [NodeMethods.unpack_name(sclass.children[0]), sclass.children[1].to_s]
|
18
18
|
end
|
19
19
|
name = names.reject(&:empty?).join('::')
|
20
|
-
closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location)
|
20
|
+
closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location, source: :parser)
|
21
21
|
elsif sclass.is_a?(AST::Node) && sclass.type == :const
|
22
22
|
names = [region.closure.namespace, region.closure.name]
|
23
23
|
also = NodeMethods.unpack_name(sclass)
|
@@ -25,13 +25,14 @@ module Solargraph
|
|
25
25
|
names << also
|
26
26
|
end
|
27
27
|
name = names.reject(&:empty?).join('::')
|
28
|
-
closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location)
|
28
|
+
closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location, source: :parser)
|
29
29
|
else
|
30
30
|
return
|
31
31
|
end
|
32
32
|
pins.push Solargraph::Pin::Singleton.new(
|
33
33
|
location: get_node_location(node),
|
34
|
-
closure: closure
|
34
|
+
closure: closure,
|
35
|
+
source: :parser,
|
35
36
|
)
|
36
37
|
process_children region.update(visibility: :public, scope: :class, closure: pins.last)
|
37
38
|
end
|
@@ -34,7 +34,7 @@ module Solargraph
|
|
34
34
|
return if process_private_class_method
|
35
35
|
end
|
36
36
|
elsif node.children[1] == :require && node.children[0].to_s == '(const nil :Bundler)'
|
37
|
-
pins.push Pin::Reference::Require.new(Solargraph::Location.new(region.filename, Solargraph::Range.from_to(0, 0, 0, 0)), 'bundler/require')
|
37
|
+
pins.push Pin::Reference::Require.new(Solargraph::Location.new(region.filename, Solargraph::Range.from_to(0, 0, 0, 0)), 'bundler/require', source: :parser)
|
38
38
|
end
|
39
39
|
process_children
|
40
40
|
end
|
@@ -76,7 +76,8 @@ module Solargraph
|
|
76
76
|
comments: cmnt,
|
77
77
|
scope: region.scope || :instance,
|
78
78
|
visibility: region.visibility,
|
79
|
-
attribute: true
|
79
|
+
attribute: true,
|
80
|
+
source: :parser
|
80
81
|
)
|
81
82
|
end
|
82
83
|
if node.children[1] == :attr_writer || node.children[1] == :attr_accessor
|
@@ -87,10 +88,11 @@ module Solargraph
|
|
87
88
|
comments: cmnt,
|
88
89
|
scope: region.scope || :instance,
|
89
90
|
visibility: region.visibility,
|
90
|
-
attribute: true
|
91
|
+
attribute: true,
|
92
|
+
source: :parser
|
91
93
|
)
|
92
94
|
pins.push method_pin
|
93
|
-
method_pin.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last)
|
95
|
+
method_pin.parameters.push Pin::Parameter.new(name: 'value', decl: :arg, closure: pins.last, source: :parser)
|
94
96
|
if method_pin.return_type.defined?
|
95
97
|
pins.last.docstring.add_tag YARD::Tags::Tag.new(:param, '', pins.last.return_type.items.map(&:rooted_tags), 'value')
|
96
98
|
end
|
@@ -107,7 +109,8 @@ module Solargraph
|
|
107
109
|
pins.push type.new(
|
108
110
|
location: get_node_location(i),
|
109
111
|
closure: cp,
|
110
|
-
name: unpack_name(i)
|
112
|
+
name: unpack_name(i),
|
113
|
+
source: :parser
|
111
114
|
)
|
112
115
|
end
|
113
116
|
end
|
@@ -121,7 +124,8 @@ module Solargraph
|
|
121
124
|
pins.push Pin::Reference::Prepend.new(
|
122
125
|
location: get_node_location(i),
|
123
126
|
closure: cp,
|
124
|
-
name: unpack_name(i)
|
127
|
+
name: unpack_name(i),
|
128
|
+
source: :parser
|
125
129
|
)
|
126
130
|
end
|
127
131
|
end
|
@@ -135,13 +139,15 @@ module Solargraph
|
|
135
139
|
pins.push Pin::Reference::Extend.new(
|
136
140
|
location: loc,
|
137
141
|
closure: region.closure,
|
138
|
-
name: region.closure.full_context.namespace
|
142
|
+
name: region.closure.full_context.namespace,
|
143
|
+
source: :parser
|
139
144
|
)
|
140
145
|
else
|
141
146
|
pins.push Pin::Reference::Extend.new(
|
142
147
|
location: loc,
|
143
148
|
closure: region.closure,
|
144
|
-
name: unpack_name(i)
|
149
|
+
name: unpack_name(i),
|
150
|
+
source: :parser
|
145
151
|
)
|
146
152
|
end
|
147
153
|
end
|
@@ -151,7 +157,7 @@ module Solargraph
|
|
151
157
|
def process_require
|
152
158
|
if node.children[2].is_a?(AST::Node) && node.children[2].type == :str
|
153
159
|
path = node.children[2].children[0].to_s
|
154
|
-
pins.push Pin::Reference::Require.new(get_node_location(node), path)
|
160
|
+
pins.push Pin::Reference::Require.new(get_node_location(node), path, source: :parser)
|
155
161
|
end
|
156
162
|
end
|
157
163
|
|
@@ -159,7 +165,7 @@ module Solargraph
|
|
159
165
|
def process_autoload
|
160
166
|
if node.children[3].is_a?(AST::Node) && node.children[3].type == :str
|
161
167
|
path = node.children[3].children[0].to_s
|
162
|
-
pins.push Pin::Reference::Require.new(get_node_location(node), path)
|
168
|
+
pins.push Pin::Reference::Require.new(get_node_location(node), path, source: :parser)
|
163
169
|
end
|
164
170
|
end
|
165
171
|
|
@@ -171,7 +177,8 @@ module Solargraph
|
|
171
177
|
elsif node.children[2].type == :sym || node.children[2].type == :str
|
172
178
|
node.children[2..-1].each do |x|
|
173
179
|
cn = x.children[0].to_s
|
174
|
-
|
180
|
+
# @type [Pin::Method]
|
181
|
+
ref = pins.find { |p| p.is_a?(Pin::Method) && p.namespace == region.closure.full_context.namespace && p.name == cn }
|
175
182
|
unless ref.nil?
|
176
183
|
pins.delete ref
|
177
184
|
mm = Solargraph::Pin::Method.new(
|
@@ -182,7 +189,8 @@ module Solargraph
|
|
182
189
|
comments: ref.comments,
|
183
190
|
scope: :class,
|
184
191
|
visibility: :public,
|
185
|
-
node: ref.node
|
192
|
+
node: ref.node,
|
193
|
+
source: :parser
|
186
194
|
)
|
187
195
|
cm = Solargraph::Pin::Method.new(
|
188
196
|
location: ref.location,
|
@@ -192,7 +200,8 @@ module Solargraph
|
|
192
200
|
comments: ref.comments,
|
193
201
|
scope: :instance,
|
194
202
|
visibility: :private,
|
195
|
-
node: ref.node
|
203
|
+
node: ref.node,
|
204
|
+
source: :parser)
|
196
205
|
pins.push mm, cm
|
197
206
|
pins.select{|pin| pin.is_a?(Pin::InstanceVariable) && pin.closure.path == ref.path}.each do |ivar|
|
198
207
|
pins.delete ivar
|
@@ -201,14 +210,16 @@ module Solargraph
|
|
201
210
|
closure: cm,
|
202
211
|
name: ivar.name,
|
203
212
|
comments: ivar.comments,
|
204
|
-
assignment: ivar.assignment
|
213
|
+
assignment: ivar.assignment,
|
214
|
+
source: :parser
|
205
215
|
)
|
206
216
|
pins.push Solargraph::Pin::InstanceVariable.new(
|
207
217
|
location: ivar.location,
|
208
218
|
closure: mm,
|
209
219
|
name: ivar.name,
|
210
220
|
comments: ivar.comments,
|
211
|
-
assignment: ivar.assignment
|
221
|
+
assignment: ivar.assignment,
|
222
|
+
source: :parser
|
212
223
|
)
|
213
224
|
end
|
214
225
|
end
|
@@ -236,7 +247,8 @@ module Solargraph
|
|
236
247
|
closure: region.closure,
|
237
248
|
name: node.children[2].children[0].to_s,
|
238
249
|
original: node.children[3].children[0].to_s,
|
239
|
-
scope: region.scope || :instance
|
250
|
+
scope: region.scope || :instance,
|
251
|
+
source: :parser
|
240
252
|
)
|
241
253
|
end
|
242
254
|
|
@@ -29,7 +29,7 @@ module Solargraph
|
|
29
29
|
scope: nil, visibility: :public, lvars: []
|
30
30
|
@source = source
|
31
31
|
# @closure = closure
|
32
|
-
@closure = closure || Pin::Namespace.new(name: '', location: source.location)
|
32
|
+
@closure = closure || Pin::Namespace.new(name: '', location: source.location, source: :parser)
|
33
33
|
@scope = scope
|
34
34
|
@visibility = visibility
|
35
35
|
@lvars = lvars
|