ruby-lsp 0.23.11 → 0.23.12
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/README.md +2 -2
- data/VERSION +1 -1
- data/exe/ruby-lsp-launcher +12 -11
- data/lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb +3 -5
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +52 -77
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +61 -144
- data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +8 -6
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +73 -182
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +48 -181
- data/lib/ruby_indexer/lib/ruby_indexer/location.rb +4 -27
- data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +12 -14
- data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +21 -44
- data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +40 -58
- data/lib/ruby_indexer/lib/ruby_indexer/uri.rb +9 -16
- data/lib/ruby_indexer/lib/ruby_indexer/visibility_scope.rb +5 -9
- data/lib/ruby_indexer/test/configuration_test.rb +32 -2
- data/lib/ruby_indexer/test/method_test.rb +2 -2
- data/lib/ruby_lsp/addon.rb +32 -67
- data/lib/ruby_lsp/base_server.rb +10 -10
- data/lib/ruby_lsp/client_capabilities.rb +4 -6
- data/lib/ruby_lsp/document.rb +21 -32
- data/lib/ruby_lsp/erb_document.rb +17 -27
- data/lib/ruby_lsp/global_state.rb +30 -32
- data/lib/ruby_lsp/internal.rb +2 -0
- data/lib/ruby_lsp/listeners/code_lens.rb +21 -39
- data/lib/ruby_lsp/listeners/completion.rb +34 -53
- data/lib/ruby_lsp/listeners/definition.rb +35 -49
- data/lib/ruby_lsp/listeners/document_highlight.rb +60 -69
- data/lib/ruby_lsp/listeners/document_link.rb +9 -19
- data/lib/ruby_lsp/listeners/document_symbol.rb +34 -48
- data/lib/ruby_lsp/listeners/folding_ranges.rb +31 -38
- data/lib/ruby_lsp/listeners/hover.rb +37 -47
- data/lib/ruby_lsp/listeners/inlay_hints.rb +3 -10
- data/lib/ruby_lsp/listeners/semantic_highlighting.rb +29 -35
- data/lib/ruby_lsp/listeners/signature_help.rb +4 -23
- data/lib/ruby_lsp/listeners/spec_style.rb +199 -0
- data/lib/ruby_lsp/listeners/test_style.rb +136 -30
- data/lib/ruby_lsp/node_context.rb +8 -35
- data/lib/ruby_lsp/rbs_document.rb +7 -5
- data/lib/ruby_lsp/requests/code_action_resolve.rb +10 -10
- data/lib/ruby_lsp/requests/code_actions.rb +5 -14
- data/lib/ruby_lsp/requests/code_lens.rb +4 -13
- data/lib/ruby_lsp/requests/completion.rb +4 -15
- data/lib/ruby_lsp/requests/completion_resolve.rb +4 -4
- data/lib/ruby_lsp/requests/definition.rb +4 -12
- data/lib/ruby_lsp/requests/diagnostics.rb +6 -9
- data/lib/ruby_lsp/requests/discover_tests.rb +15 -3
- data/lib/ruby_lsp/requests/document_highlight.rb +3 -11
- data/lib/ruby_lsp/requests/document_link.rb +4 -13
- data/lib/ruby_lsp/requests/document_symbol.rb +4 -7
- data/lib/ruby_lsp/requests/folding_ranges.rb +4 -7
- data/lib/ruby_lsp/requests/formatting.rb +4 -7
- data/lib/ruby_lsp/requests/go_to_relevant_file.rb +87 -0
- data/lib/ruby_lsp/requests/hover.rb +6 -16
- data/lib/ruby_lsp/requests/inlay_hints.rb +4 -13
- data/lib/ruby_lsp/requests/on_type_formatting.rb +17 -24
- data/lib/ruby_lsp/requests/prepare_rename.rb +3 -8
- data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +4 -13
- data/lib/ruby_lsp/requests/range_formatting.rb +3 -4
- data/lib/ruby_lsp/requests/references.rb +5 -35
- data/lib/ruby_lsp/requests/rename.rb +9 -35
- data/lib/ruby_lsp/requests/request.rb +5 -17
- data/lib/ruby_lsp/requests/selection_ranges.rb +3 -3
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +6 -23
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +4 -5
- data/lib/ruby_lsp/requests/signature_help.rb +6 -24
- data/lib/ruby_lsp/requests/support/annotation.rb +4 -10
- data/lib/ruby_lsp/requests/support/common.rb +12 -49
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +12 -14
- data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +7 -10
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +9 -15
- data/lib/ruby_lsp/requests/support/selection_range.rb +1 -3
- data/lib/ruby_lsp/requests/support/sorbet.rb +1 -7
- data/lib/ruby_lsp/requests/support/source_uri.rb +5 -16
- data/lib/ruby_lsp/requests/support/syntax_tree_formatter.rb +7 -10
- data/lib/ruby_lsp/requests/support/test_item.rb +14 -13
- data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +4 -5
- data/lib/ruby_lsp/requests/workspace_symbol.rb +3 -3
- data/lib/ruby_lsp/response_builders/collection_response_builder.rb +4 -4
- data/lib/ruby_lsp/response_builders/document_symbol.rb +8 -11
- data/lib/ruby_lsp/response_builders/hover.rb +5 -5
- data/lib/ruby_lsp/response_builders/response_builder.rb +1 -1
- data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +18 -40
- data/lib/ruby_lsp/response_builders/signature_help.rb +4 -5
- data/lib/ruby_lsp/response_builders/test_collection.rb +5 -9
- data/lib/ruby_lsp/ruby_document.rb +15 -40
- data/lib/ruby_lsp/ruby_lsp_reporter_plugin.rb +106 -0
- data/lib/ruby_lsp/scope.rb +6 -10
- data/lib/ruby_lsp/server.rb +125 -74
- data/lib/ruby_lsp/setup_bundler.rb +22 -15
- data/lib/ruby_lsp/store.rb +12 -28
- data/lib/ruby_lsp/test_helper.rb +3 -12
- data/lib/ruby_lsp/test_reporter.rb +71 -0
- data/lib/ruby_lsp/test_unit_test_runner.rb +96 -0
- data/lib/ruby_lsp/type_inferrer.rb +9 -13
- data/lib/ruby_lsp/utils.rb +27 -65
- metadata +8 -3
@@ -11,30 +11,21 @@ module RubyIndexer
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
sig { returns(String) }
|
14
|
+
#: String
|
17
15
|
attr_reader :name
|
18
16
|
|
19
|
-
|
17
|
+
#: URI::Generic
|
20
18
|
attr_reader :uri
|
21
19
|
|
22
|
-
|
20
|
+
#: RubyIndexer::Location
|
23
21
|
attr_reader :location
|
24
22
|
|
25
23
|
alias_method :name_location, :location
|
26
24
|
|
27
|
-
|
25
|
+
#: Visibility
|
28
26
|
attr_accessor :visibility
|
29
27
|
|
30
|
-
|
31
|
-
params(
|
32
|
-
name: String,
|
33
|
-
uri: URI::Generic,
|
34
|
-
location: Location,
|
35
|
-
comments: T.nilable(String),
|
36
|
-
).void
|
37
|
-
end
|
28
|
+
#: (String name, URI::Generic uri, Location location, String? comments) -> void
|
38
29
|
def initialize(name, uri, location, comments)
|
39
30
|
@name = name
|
40
31
|
@uri = uri
|
@@ -43,22 +34,22 @@ module RubyIndexer
|
|
43
34
|
@location = location
|
44
35
|
end
|
45
36
|
|
46
|
-
|
37
|
+
#: -> bool
|
47
38
|
def public?
|
48
39
|
visibility == Visibility::PUBLIC
|
49
40
|
end
|
50
41
|
|
51
|
-
|
42
|
+
#: -> bool
|
52
43
|
def protected?
|
53
44
|
visibility == Visibility::PROTECTED
|
54
45
|
end
|
55
46
|
|
56
|
-
|
47
|
+
#: -> bool
|
57
48
|
def private?
|
58
49
|
visibility == Visibility::PRIVATE
|
59
50
|
end
|
60
51
|
|
61
|
-
|
52
|
+
#: -> String
|
62
53
|
def file_name
|
63
54
|
if @uri.scheme == "untitled"
|
64
55
|
T.must(@uri.opaque)
|
@@ -67,12 +58,12 @@ module RubyIndexer
|
|
67
58
|
end
|
68
59
|
end
|
69
60
|
|
70
|
-
|
61
|
+
#: -> String?
|
71
62
|
def file_path
|
72
63
|
@uri.full_path
|
73
64
|
end
|
74
65
|
|
75
|
-
|
66
|
+
#: -> String
|
76
67
|
def comments
|
77
68
|
@comments ||= begin
|
78
69
|
# Parse only the comments based on the file path, which is much faster than parsing the entire file
|
@@ -119,10 +110,10 @@ module RubyIndexer
|
|
119
110
|
|
120
111
|
abstract!
|
121
112
|
|
122
|
-
|
113
|
+
#: String
|
123
114
|
attr_reader :module_name
|
124
115
|
|
125
|
-
|
116
|
+
#: (String module_name) -> void
|
126
117
|
def initialize(module_name)
|
127
118
|
@module_name = module_name
|
128
119
|
end
|
@@ -137,22 +128,14 @@ module RubyIndexer
|
|
137
128
|
|
138
129
|
abstract!
|
139
130
|
|
140
|
-
|
131
|
+
#: Array[String]
|
141
132
|
attr_reader :nesting
|
142
133
|
|
143
134
|
# Returns the location of the constant name, excluding the parent class or the body
|
144
|
-
|
135
|
+
#: Location
|
145
136
|
attr_reader :name_location
|
146
137
|
|
147
|
-
|
148
|
-
params(
|
149
|
-
nesting: T::Array[String],
|
150
|
-
uri: URI::Generic,
|
151
|
-
location: Location,
|
152
|
-
name_location: Location,
|
153
|
-
comments: T.nilable(String),
|
154
|
-
).void
|
155
|
-
end
|
138
|
+
#: (Array[String] nesting, URI::Generic uri, Location location, Location name_location, String? comments) -> void
|
156
139
|
def initialize(nesting, uri, location, name_location, comments)
|
157
140
|
@name = T.let(nesting.join("::"), String)
|
158
141
|
# The original nesting where this namespace was discovered
|
@@ -163,7 +146,7 @@ module RubyIndexer
|
|
163
146
|
@name_location = name_location
|
164
147
|
end
|
165
148
|
|
166
|
-
|
149
|
+
#: -> Array[String]
|
167
150
|
def mixin_operation_module_names
|
168
151
|
mixin_operations.map(&:module_name)
|
169
152
|
end
|
@@ -171,12 +154,12 @@ module RubyIndexer
|
|
171
154
|
# Stores all explicit prepend, include and extend operations in the exact order they were discovered in the source
|
172
155
|
# code. Maintaining the order is essential to linearize ancestors the right way when a module is both included
|
173
156
|
# and prepended
|
174
|
-
|
157
|
+
#: -> Array[ModuleOperation]
|
175
158
|
def mixin_operations
|
176
159
|
@mixin_operations ||= T.let([], T.nilable(T::Array[ModuleOperation]))
|
177
160
|
end
|
178
161
|
|
179
|
-
|
162
|
+
#: -> Integer
|
180
163
|
def ancestor_hash
|
181
164
|
mixin_operation_module_names.hash
|
182
165
|
end
|
@@ -186,44 +169,26 @@ module RubyIndexer
|
|
186
169
|
end
|
187
170
|
|
188
171
|
class Class < Namespace
|
189
|
-
extend T::Sig
|
190
|
-
|
191
172
|
# The unresolved name of the parent class. This may return `nil`, which indicates the lack of an explicit parent
|
192
173
|
# and therefore ::Object is the correct parent class
|
193
|
-
|
174
|
+
#: String?
|
194
175
|
attr_reader :parent_class
|
195
176
|
|
196
|
-
|
197
|
-
params(
|
198
|
-
nesting: T::Array[String],
|
199
|
-
uri: URI::Generic,
|
200
|
-
location: Location,
|
201
|
-
name_location: Location,
|
202
|
-
comments: T.nilable(String),
|
203
|
-
parent_class: T.nilable(String),
|
204
|
-
).void
|
205
|
-
end
|
177
|
+
#: (Array[String] nesting, URI::Generic uri, Location location, Location name_location, String? comments, String? parent_class) -> void
|
206
178
|
def initialize(nesting, uri, location, name_location, comments, parent_class) # rubocop:disable Metrics/ParameterLists
|
207
179
|
super(nesting, uri, location, name_location, comments)
|
208
180
|
@parent_class = parent_class
|
209
181
|
end
|
210
182
|
|
211
|
-
|
183
|
+
# @override
|
184
|
+
#: -> Integer
|
212
185
|
def ancestor_hash
|
213
186
|
[mixin_operation_module_names, @parent_class].hash
|
214
187
|
end
|
215
188
|
end
|
216
189
|
|
217
190
|
class SingletonClass < Class
|
218
|
-
|
219
|
-
|
220
|
-
sig do
|
221
|
-
params(
|
222
|
-
location: Location,
|
223
|
-
name_location: Location,
|
224
|
-
comments: T.nilable(String),
|
225
|
-
).void
|
226
|
-
end
|
191
|
+
#: (Location location, Location name_location, String? comments) -> void
|
227
192
|
def update_singleton_information(location, name_location, comments)
|
228
193
|
@location = location
|
229
194
|
@name_location = name_location
|
@@ -241,13 +206,13 @@ module RubyIndexer
|
|
241
206
|
abstract!
|
242
207
|
|
243
208
|
# Name includes just the name of the parameter, excluding symbols like splats
|
244
|
-
|
209
|
+
#: Symbol
|
245
210
|
attr_reader :name
|
246
211
|
|
247
212
|
# Decorated name is the parameter name including the splat or block prefix, e.g.: `*foo`, `**foo` or `&block`
|
248
213
|
alias_method :decorated_name, :name
|
249
214
|
|
250
|
-
|
215
|
+
#: (name: Symbol) -> void
|
251
216
|
def initialize(name:)
|
252
217
|
@name = name
|
253
218
|
end
|
@@ -259,7 +224,8 @@ module RubyIndexer
|
|
259
224
|
|
260
225
|
# An optional method parameter, e.g. `def foo(a = 123)`
|
261
226
|
class OptionalParameter < Parameter
|
262
|
-
|
227
|
+
# @override
|
228
|
+
#: -> Symbol
|
263
229
|
def decorated_name
|
264
230
|
:"#{@name} = <default>"
|
265
231
|
end
|
@@ -267,7 +233,8 @@ module RubyIndexer
|
|
267
233
|
|
268
234
|
# An required keyword method parameter, e.g. `def foo(a:)`
|
269
235
|
class KeywordParameter < Parameter
|
270
|
-
|
236
|
+
# @override
|
237
|
+
#: -> Symbol
|
271
238
|
def decorated_name
|
272
239
|
:"#{@name}:"
|
273
240
|
end
|
@@ -275,7 +242,8 @@ module RubyIndexer
|
|
275
242
|
|
276
243
|
# An optional keyword method parameter, e.g. `def foo(a: 123)`
|
277
244
|
class OptionalKeywordParameter < Parameter
|
278
|
-
|
245
|
+
# @override
|
246
|
+
#: -> Symbol
|
279
247
|
def decorated_name
|
280
248
|
:"#{@name}: <default>"
|
281
249
|
end
|
@@ -285,7 +253,8 @@ module RubyIndexer
|
|
285
253
|
class RestParameter < Parameter
|
286
254
|
DEFAULT_NAME = T.let(:"<anonymous splat>", Symbol)
|
287
255
|
|
288
|
-
|
256
|
+
# @override
|
257
|
+
#: -> Symbol
|
289
258
|
def decorated_name
|
290
259
|
:"*#{@name}"
|
291
260
|
end
|
@@ -295,7 +264,8 @@ module RubyIndexer
|
|
295
264
|
class KeywordRestParameter < Parameter
|
296
265
|
DEFAULT_NAME = T.let(:"<anonymous keyword splat>", Symbol)
|
297
266
|
|
298
|
-
|
267
|
+
# @override
|
268
|
+
#: -> Symbol
|
299
269
|
def decorated_name
|
300
270
|
:"**#{@name}"
|
301
271
|
end
|
@@ -306,14 +276,14 @@ module RubyIndexer
|
|
306
276
|
DEFAULT_NAME = T.let(:"<anonymous block>", Symbol)
|
307
277
|
|
308
278
|
class << self
|
309
|
-
|
310
|
-
sig { returns(BlockParameter) }
|
279
|
+
#: -> BlockParameter
|
311
280
|
def anonymous
|
312
281
|
new(name: DEFAULT_NAME)
|
313
282
|
end
|
314
283
|
end
|
315
284
|
|
316
|
-
|
285
|
+
# @override
|
286
|
+
#: -> Symbol
|
317
287
|
def decorated_name
|
318
288
|
:"&#{@name}"
|
319
289
|
end
|
@@ -321,9 +291,7 @@ module RubyIndexer
|
|
321
291
|
|
322
292
|
# A forwarding method parameter, e.g. `def foo(...)`
|
323
293
|
class ForwardingParameter < Parameter
|
324
|
-
|
325
|
-
|
326
|
-
sig { void }
|
294
|
+
#: -> void
|
327
295
|
def initialize
|
328
296
|
# You can't name a forwarding parameter, it's always called `...`
|
329
297
|
super(name: :"...")
|
@@ -336,19 +304,10 @@ module RubyIndexer
|
|
336
304
|
|
337
305
|
abstract!
|
338
306
|
|
339
|
-
|
307
|
+
#: Entry::Namespace?
|
340
308
|
attr_reader :owner
|
341
309
|
|
342
|
-
|
343
|
-
params(
|
344
|
-
name: String,
|
345
|
-
uri: URI::Generic,
|
346
|
-
location: Location,
|
347
|
-
comments: T.nilable(String),
|
348
|
-
visibility: Visibility,
|
349
|
-
owner: T.nilable(Entry::Namespace),
|
350
|
-
).void
|
351
|
-
end
|
310
|
+
#: (String name, URI::Generic uri, Location location, String? comments, Visibility visibility, Entry::Namespace? owner) -> void
|
352
311
|
def initialize(name, uri, location, comments, visibility, owner) # rubocop:disable Metrics/ParameterLists
|
353
312
|
super(name, uri, location, comments)
|
354
313
|
@visibility = visibility
|
@@ -358,7 +317,7 @@ module RubyIndexer
|
|
358
317
|
sig { abstract.returns(T::Array[Entry::Signature]) }
|
359
318
|
def signatures; end
|
360
319
|
|
361
|
-
|
320
|
+
#: -> String
|
362
321
|
def decorated_parameters
|
363
322
|
first_signature = signatures.first
|
364
323
|
return "()" unless first_signature
|
@@ -366,7 +325,7 @@ module RubyIndexer
|
|
366
325
|
"(#{first_signature.format})"
|
367
326
|
end
|
368
327
|
|
369
|
-
|
328
|
+
#: -> String
|
370
329
|
def formatted_signatures
|
371
330
|
overloads_count = signatures.size
|
372
331
|
case overloads_count
|
@@ -381,9 +340,8 @@ module RubyIndexer
|
|
381
340
|
end
|
382
341
|
|
383
342
|
class Accessor < Member
|
384
|
-
|
385
|
-
|
386
|
-
sig { override.returns(T::Array[Signature]) }
|
343
|
+
# @override
|
344
|
+
#: -> Array[Signature]
|
387
345
|
def signatures
|
388
346
|
@signatures ||= T.let(
|
389
347
|
begin
|
@@ -397,27 +355,14 @@ module RubyIndexer
|
|
397
355
|
end
|
398
356
|
|
399
357
|
class Method < Member
|
400
|
-
|
401
|
-
|
402
|
-
sig { override.returns(T::Array[Signature]) }
|
358
|
+
#: Array[Signature]
|
403
359
|
attr_reader :signatures
|
404
360
|
|
405
361
|
# Returns the location of the method name, excluding parameters or the body
|
406
|
-
|
362
|
+
#: Location
|
407
363
|
attr_reader :name_location
|
408
364
|
|
409
|
-
|
410
|
-
params(
|
411
|
-
name: String,
|
412
|
-
uri: URI::Generic,
|
413
|
-
location: Location,
|
414
|
-
name_location: Location,
|
415
|
-
comments: T.nilable(String),
|
416
|
-
signatures: T::Array[Signature],
|
417
|
-
visibility: Visibility,
|
418
|
-
owner: T.nilable(Entry::Namespace),
|
419
|
-
).void
|
420
|
-
end
|
365
|
+
#: (String name, URI::Generic uri, Location location, Location name_location, String? comments, Array[Signature] signatures, Visibility visibility, Entry::Namespace? owner) -> void
|
421
366
|
def initialize(name, uri, location, name_location, comments, signatures, visibility, owner) # rubocop:disable Metrics/ParameterLists
|
422
367
|
super(name, uri, location, comments, visibility, owner)
|
423
368
|
@signatures = signatures
|
@@ -436,24 +381,13 @@ module RubyIndexer
|
|
436
381
|
# target in [rdoc-ref:Index#resolve]. If the right hand side contains a constant that doesn't exist, then it's not
|
437
382
|
# possible to resolve the alias and it will remain an UnresolvedAlias until the right hand side constant exists
|
438
383
|
class UnresolvedConstantAlias < Entry
|
439
|
-
|
440
|
-
|
441
|
-
sig { returns(String) }
|
384
|
+
#: String
|
442
385
|
attr_reader :target
|
443
386
|
|
444
|
-
|
387
|
+
#: Array[String]
|
445
388
|
attr_reader :nesting
|
446
389
|
|
447
|
-
|
448
|
-
params(
|
449
|
-
target: String,
|
450
|
-
nesting: T::Array[String],
|
451
|
-
name: String,
|
452
|
-
uri: URI::Generic,
|
453
|
-
location: Location,
|
454
|
-
comments: T.nilable(String),
|
455
|
-
).void
|
456
|
-
end
|
390
|
+
#: (String target, Array[String] nesting, String name, URI::Generic uri, Location location, String? comments) -> void
|
457
391
|
def initialize(target, nesting, name, uri, location, comments) # rubocop:disable Metrics/ParameterLists
|
458
392
|
super(name, uri, location, comments)
|
459
393
|
|
@@ -464,12 +398,10 @@ module RubyIndexer
|
|
464
398
|
|
465
399
|
# Alias represents a resolved alias, which points to an existing constant target
|
466
400
|
class ConstantAlias < Entry
|
467
|
-
|
468
|
-
|
469
|
-
sig { returns(String) }
|
401
|
+
#: String
|
470
402
|
attr_reader :target
|
471
403
|
|
472
|
-
|
404
|
+
#: (String target, UnresolvedConstantAlias unresolved_alias) -> void
|
473
405
|
def initialize(target, unresolved_alias)
|
474
406
|
super(
|
475
407
|
unresolved_alias.name,
|
@@ -488,18 +420,10 @@ module RubyIndexer
|
|
488
420
|
|
489
421
|
# Represents a class variable e.g.: @@a = 1
|
490
422
|
class ClassVariable < Entry
|
491
|
-
|
423
|
+
#: Entry::Namespace?
|
492
424
|
attr_reader :owner
|
493
425
|
|
494
|
-
|
495
|
-
params(
|
496
|
-
name: String,
|
497
|
-
uri: URI::Generic,
|
498
|
-
location: Location,
|
499
|
-
comments: T.nilable(String),
|
500
|
-
owner: T.nilable(Entry::Namespace),
|
501
|
-
).void
|
502
|
-
end
|
426
|
+
#: (String name, URI::Generic uri, Location location, String? comments, Entry::Namespace? owner) -> void
|
503
427
|
def initialize(name, uri, location, comments, owner)
|
504
428
|
super(name, uri, location, comments)
|
505
429
|
@owner = owner
|
@@ -508,18 +432,10 @@ module RubyIndexer
|
|
508
432
|
|
509
433
|
# Represents an instance variable e.g.: @a = 1
|
510
434
|
class InstanceVariable < Entry
|
511
|
-
|
435
|
+
#: Entry::Namespace?
|
512
436
|
attr_reader :owner
|
513
437
|
|
514
|
-
|
515
|
-
params(
|
516
|
-
name: String,
|
517
|
-
uri: URI::Generic,
|
518
|
-
location: Location,
|
519
|
-
comments: T.nilable(String),
|
520
|
-
owner: T.nilable(Entry::Namespace),
|
521
|
-
).void
|
522
|
-
end
|
438
|
+
#: (String name, URI::Generic uri, Location location, String? comments, Entry::Namespace? owner) -> void
|
523
439
|
def initialize(name, uri, location, comments, owner)
|
524
440
|
super(name, uri, location, comments)
|
525
441
|
@owner = owner
|
@@ -530,24 +446,13 @@ module RubyIndexer
|
|
530
446
|
# example, if we have `alias a b`, we create an unresolved alias for `a` because we aren't sure immediate what `b`
|
531
447
|
# is referring to
|
532
448
|
class UnresolvedMethodAlias < Entry
|
533
|
-
|
534
|
-
|
535
|
-
sig { returns(String) }
|
449
|
+
#: String
|
536
450
|
attr_reader :new_name, :old_name
|
537
451
|
|
538
|
-
|
452
|
+
#: Entry::Namespace?
|
539
453
|
attr_reader :owner
|
540
454
|
|
541
|
-
|
542
|
-
params(
|
543
|
-
new_name: String,
|
544
|
-
old_name: String,
|
545
|
-
owner: T.nilable(Entry::Namespace),
|
546
|
-
uri: URI::Generic,
|
547
|
-
location: Location,
|
548
|
-
comments: T.nilable(String),
|
549
|
-
).void
|
550
|
-
end
|
455
|
+
#: (String new_name, String old_name, Entry::Namespace? owner, URI::Generic uri, Location location, String? comments) -> void
|
551
456
|
def initialize(new_name, old_name, owner, uri, location, comments) # rubocop:disable Metrics/ParameterLists
|
552
457
|
super(new_name, uri, location, comments)
|
553
458
|
|
@@ -559,17 +464,13 @@ module RubyIndexer
|
|
559
464
|
|
560
465
|
# A method alias is a resolved alias entry that points to the exact method target it refers to
|
561
466
|
class MethodAlias < Entry
|
562
|
-
|
563
|
-
|
564
|
-
sig { returns(T.any(Member, MethodAlias)) }
|
467
|
+
#: (Member | MethodAlias)
|
565
468
|
attr_reader :target
|
566
469
|
|
567
|
-
|
470
|
+
#: Entry::Namespace?
|
568
471
|
attr_reader :owner
|
569
472
|
|
570
|
-
|
571
|
-
params(target: T.any(Member, MethodAlias), unresolved_alias: UnresolvedMethodAlias).void
|
572
|
-
end
|
473
|
+
#: ((Member | MethodAlias) target, UnresolvedMethodAlias unresolved_alias) -> void
|
573
474
|
def initialize(target, unresolved_alias)
|
574
475
|
full_comments = +"Alias for #{target.name}\n"
|
575
476
|
full_comments << "#{unresolved_alias.comments}\n"
|
@@ -586,17 +487,17 @@ module RubyIndexer
|
|
586
487
|
@owner = T.let(unresolved_alias.owner, T.nilable(Entry::Namespace))
|
587
488
|
end
|
588
489
|
|
589
|
-
|
490
|
+
#: -> String
|
590
491
|
def decorated_parameters
|
591
492
|
@target.decorated_parameters
|
592
493
|
end
|
593
494
|
|
594
|
-
|
495
|
+
#: -> String
|
595
496
|
def formatted_signatures
|
596
497
|
@target.formatted_signatures
|
597
498
|
end
|
598
499
|
|
599
|
-
|
500
|
+
#: -> Array[Signature]
|
600
501
|
def signatures
|
601
502
|
@target.signatures
|
602
503
|
end
|
@@ -606,18 +507,16 @@ module RubyIndexer
|
|
606
507
|
# However RBS can represent the concept of method overloading, with different return types based on the arguments
|
607
508
|
# passed, so we need to store all the signatures.
|
608
509
|
class Signature
|
609
|
-
|
610
|
-
|
611
|
-
sig { returns(T::Array[Parameter]) }
|
510
|
+
#: Array[Parameter]
|
612
511
|
attr_reader :parameters
|
613
512
|
|
614
|
-
|
513
|
+
#: (Array[Parameter] parameters) -> void
|
615
514
|
def initialize(parameters)
|
616
515
|
@parameters = parameters
|
617
516
|
end
|
618
517
|
|
619
518
|
# Returns a string with the decorated names of the parameters of this member. E.g.: `(a, b = 1, c: 2)`
|
620
|
-
|
519
|
+
#: -> String
|
621
520
|
def format
|
622
521
|
@parameters.map(&:decorated_name).join(", ")
|
623
522
|
end
|
@@ -637,7 +536,7 @@ module RubyIndexer
|
|
637
536
|
# foo(1)
|
638
537
|
# foo(1, 2)
|
639
538
|
# ```
|
640
|
-
|
539
|
+
#: (Array[Prism::Node] arguments) -> bool
|
641
540
|
def matches?(arguments)
|
642
541
|
min_pos = 0
|
643
542
|
max_pos = T.let(0, T.any(Integer, Float))
|
@@ -688,15 +587,7 @@ module RubyIndexer
|
|
688
587
|
)
|
689
588
|
end
|
690
589
|
|
691
|
-
|
692
|
-
params(
|
693
|
-
positional_args: T::Array[Prism::Node],
|
694
|
-
forwarding_arguments: T::Array[Prism::Node],
|
695
|
-
keyword_args: T.nilable(T::Array[Prism::Node]),
|
696
|
-
min_pos: Integer,
|
697
|
-
max_pos: T.any(Integer, Float),
|
698
|
-
).returns(T::Boolean)
|
699
|
-
end
|
590
|
+
#: (Array[Prism::Node] positional_args, Array[Prism::Node] forwarding_arguments, Array[Prism::Node]? keyword_args, Integer min_pos, (Integer | Float) max_pos) -> bool
|
700
591
|
def positional_arguments_match?(positional_args, forwarding_arguments, keyword_args, min_pos, max_pos)
|
701
592
|
# If the method accepts at least one positional argument and a splat has been passed
|
702
593
|
(min_pos > 0 && positional_args.any? { |arg| arg.is_a?(Prism::SplatNode) }) ||
|
@@ -709,7 +600,7 @@ module RubyIndexer
|
|
709
600
|
(min_pos == 0 && positional_args.empty?)
|
710
601
|
end
|
711
602
|
|
712
|
-
|
603
|
+
#: (Array[Prism::Node]? args, Array[Symbol] names) -> bool
|
713
604
|
def keyword_arguments_match?(args, names)
|
714
605
|
return true unless args
|
715
606
|
return true if args.any? { |arg| arg.is_a?(Prism::AssocSplatNode) }
|