ruby-lsp 0.23.14 → 0.23.15
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/VERSION +1 -1
- data/exe/ruby-lsp-launcher +9 -1
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +6 -3
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +4 -2
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +59 -29
- data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +5 -4
- data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +5 -1
- data/lib/ruby_indexer/test/class_variables_test.rb +14 -14
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +65 -40
- data/lib/ruby_indexer/test/configuration_test.rb +6 -4
- data/lib/ruby_indexer/test/constant_test.rb +34 -34
- data/lib/ruby_indexer/test/enhancements_test.rb +1 -1
- data/lib/ruby_indexer/test/index_test.rb +139 -135
- data/lib/ruby_indexer/test/instance_variables_test.rb +37 -37
- data/lib/ruby_indexer/test/method_test.rb +118 -118
- data/lib/ruby_indexer/test/prefix_tree_test.rb +13 -13
- data/lib/ruby_indexer/test/rbs_indexer_test.rb +64 -70
- data/lib/ruby_indexer/test/test_case.rb +2 -2
- data/lib/ruby_lsp/erb_document.rb +12 -4
- data/lib/ruby_lsp/global_state.rb +1 -1
- data/lib/ruby_lsp/listeners/code_lens.rb +3 -3
- data/lib/ruby_lsp/listeners/completion.rb +24 -11
- data/lib/ruby_lsp/listeners/definition.rb +1 -1
- data/lib/ruby_lsp/listeners/document_link.rb +3 -1
- data/lib/ruby_lsp/listeners/document_symbol.rb +3 -3
- data/lib/ruby_lsp/listeners/folding_ranges.rb +8 -4
- data/lib/ruby_lsp/listeners/hover.rb +2 -2
- data/lib/ruby_lsp/listeners/semantic_highlighting.rb +12 -5
- data/lib/ruby_lsp/listeners/signature_help.rb +5 -1
- data/lib/ruby_lsp/listeners/spec_style.rb +1 -1
- data/lib/ruby_lsp/listeners/test_style.rb +3 -3
- data/lib/ruby_lsp/requests/code_action_resolve.rb +4 -3
- data/lib/ruby_lsp/requests/completion_resolve.rb +1 -1
- data/lib/ruby_lsp/requests/hover.rb +2 -2
- data/lib/ruby_lsp/requests/on_type_formatting.rb +4 -2
- data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +1 -2
- data/lib/ruby_lsp/requests/references.rb +2 -1
- data/lib/ruby_lsp/requests/rename.rb +8 -5
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +4 -4
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +1 -1
- data/lib/ruby_lsp/requests/support/common.rb +3 -1
- data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +2 -2
- data/lib/ruby_lsp/requests/support/source_uri.rb +1 -1
- data/lib/ruby_lsp/response_builders/document_symbol.rb +3 -2
- data/lib/ruby_lsp/response_builders/hover.rb +1 -1
- data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +1 -1
- data/lib/ruby_lsp/scripts/compose_bundle.rb +6 -4
- data/lib/ruby_lsp/server.rb +12 -4
- data/lib/ruby_lsp/setup_bundler.rb +5 -2
- data/lib/ruby_lsp/static_docs.rb +8 -1
- data/lib/ruby_lsp/store.rb +3 -2
- data/lib/ruby_lsp/test_reporters/lsp_reporter.rb +152 -0
- data/lib/ruby_lsp/test_reporters/minitest_reporter.rb +105 -0
- data/lib/ruby_lsp/test_reporters/test_unit_reporter.rb +94 -0
- data/lib/ruby_lsp/type_inferrer.rb +4 -1
- metadata +6 -6
- data/lib/ruby_lsp/ruby_lsp_reporter_plugin.rb +0 -109
- data/lib/ruby_lsp/test_reporter.rb +0 -207
- data/lib/ruby_lsp/test_unit_test_runner.rb +0 -98
@@ -223,10 +223,12 @@ module RubyIndexer
|
|
223
223
|
class Bar; end
|
224
224
|
RUBY
|
225
225
|
|
226
|
-
foo_entry = @index["Foo"]
|
226
|
+
foo_entry = @index["Foo"] #: as !nil
|
227
|
+
.first #: as !nil
|
227
228
|
assert_equal("This is a Foo comment\nThis is another Foo comment", foo_entry.comments)
|
228
229
|
|
229
|
-
bar_entry = @index["Bar"]
|
230
|
+
bar_entry = @index["Bar"] #: as !nil
|
231
|
+
.first #: as !nil
|
230
232
|
assert_equal("This Bar comment has 1 line padding", bar_entry.comments)
|
231
233
|
end
|
232
234
|
|
@@ -236,7 +238,7 @@ module RubyIndexer
|
|
236
238
|
class Foo
|
237
239
|
end
|
238
240
|
RUBY
|
239
|
-
assert(@index["Foo"]
|
241
|
+
assert(@index["Foo"]&.first)
|
240
242
|
end
|
241
243
|
|
242
244
|
def test_comments_can_be_attached_to_a_namespaced_class
|
@@ -249,10 +251,12 @@ module RubyIndexer
|
|
249
251
|
end
|
250
252
|
RUBY
|
251
253
|
|
252
|
-
foo_entry = @index["Foo"]
|
254
|
+
foo_entry = @index["Foo"] #: as !nil
|
255
|
+
.first #: as !nil
|
253
256
|
assert_equal("This is a Foo comment\nThis is another Foo comment", foo_entry.comments)
|
254
257
|
|
255
|
-
bar_entry = @index["Foo::Bar"]
|
258
|
+
bar_entry = @index["Foo::Bar"] #: as !nil
|
259
|
+
.first #: as !nil
|
256
260
|
assert_equal("This is a Bar comment", bar_entry.comments)
|
257
261
|
end
|
258
262
|
|
@@ -265,11 +269,9 @@ module RubyIndexer
|
|
265
269
|
class Foo; end
|
266
270
|
RUBY
|
267
271
|
|
268
|
-
first_foo_entry = @index["Foo"]
|
269
|
-
assert_equal("This is a Foo comment", first_foo_entry
|
270
|
-
|
271
|
-
second_foo_entry = @index["Foo"][1]
|
272
|
-
assert_equal("This is another Foo comment", second_foo_entry.comments)
|
272
|
+
first_foo_entry, second_foo_entry = @index["Foo"] #: as !nil
|
273
|
+
assert_equal("This is a Foo comment", first_foo_entry&.comments)
|
274
|
+
assert_equal("This is another Foo comment", second_foo_entry&.comments)
|
273
275
|
end
|
274
276
|
|
275
277
|
def test_comments_removes_the_leading_pound_and_space
|
@@ -281,10 +283,12 @@ module RubyIndexer
|
|
281
283
|
class Bar; end
|
282
284
|
RUBY
|
283
285
|
|
284
|
-
first_foo_entry = @index["Foo"]
|
286
|
+
first_foo_entry = @index["Foo"] #: as !nil
|
287
|
+
.first #: as !nil
|
285
288
|
assert_equal("This is a Foo comment", first_foo_entry.comments)
|
286
289
|
|
287
|
-
second_foo_entry = @index["Bar"]
|
290
|
+
second_foo_entry = @index["Bar"] #: as !nil
|
291
|
+
.first #: as !nil
|
288
292
|
assert_equal("This is a Bar comment", second_foo_entry.comments)
|
289
293
|
end
|
290
294
|
|
@@ -301,14 +305,17 @@ module RubyIndexer
|
|
301
305
|
end
|
302
306
|
RUBY
|
303
307
|
|
304
|
-
b_const = @index["A::B"]
|
308
|
+
b_const = @index["A::B"] #: as !nil
|
309
|
+
.first
|
305
310
|
assert_predicate(b_const, :private?)
|
306
311
|
|
307
|
-
c_const = @index["A::C"]
|
312
|
+
c_const = @index["A::C"] #: as !nil
|
313
|
+
.first
|
308
314
|
assert_predicate(c_const, :private?)
|
309
315
|
|
310
|
-
d_const = @index["A::D"]
|
311
|
-
|
316
|
+
d_const = @index["A::D"] #: as !nil
|
317
|
+
.first
|
318
|
+
assert_predicate(d_const, :public?)
|
312
319
|
end
|
313
320
|
|
314
321
|
def test_keeping_track_of_super_classes
|
@@ -331,16 +338,20 @@ module RubyIndexer
|
|
331
338
|
end
|
332
339
|
RUBY
|
333
340
|
|
334
|
-
foo =
|
341
|
+
foo = @index["Foo"] #: as !nil
|
342
|
+
.first #: as Entry::Class
|
335
343
|
assert_equal("Bar", foo.parent_class)
|
336
344
|
|
337
|
-
baz =
|
345
|
+
baz = @index["Baz"] #: as !nil
|
346
|
+
.first #: as Entry::Class
|
338
347
|
assert_equal("::Object", baz.parent_class)
|
339
348
|
|
340
|
-
qux =
|
349
|
+
qux = @index["Something::Qux"] #: as !nil
|
350
|
+
.first #: as Entry::Class
|
341
351
|
assert_equal("::Baz", qux.parent_class)
|
342
352
|
|
343
|
-
final_thing =
|
353
|
+
final_thing = @index["FinalThing"] #: as !nil
|
354
|
+
.first #: as Entry::Class
|
344
355
|
assert_equal("Something::Baz", final_thing.parent_class)
|
345
356
|
end
|
346
357
|
|
@@ -380,13 +391,16 @@ module RubyIndexer
|
|
380
391
|
end
|
381
392
|
RUBY
|
382
393
|
|
383
|
-
foo =
|
394
|
+
foo = @index["Foo"] #: as !nil
|
395
|
+
.first #: as Entry::Class
|
384
396
|
assert_equal(["A1", "A2", "A3", "A4", "A5", "A6"], foo.mixin_operation_module_names)
|
385
397
|
|
386
|
-
qux =
|
398
|
+
qux = @index["Foo::Qux"] #: as !nil
|
399
|
+
.first #: as Entry::Class
|
387
400
|
assert_equal(["Corge", "Corge", "Baz"], qux.mixin_operation_module_names)
|
388
401
|
|
389
|
-
constant_path_references =
|
402
|
+
constant_path_references = @index["ConstantPathReferences"] #: as !nil
|
403
|
+
.first #: as Entry::Class
|
390
404
|
assert_equal(["Foo::Bar", "Foo::Bar2"], constant_path_references.mixin_operation_module_names)
|
391
405
|
end
|
392
406
|
|
@@ -426,13 +440,16 @@ module RubyIndexer
|
|
426
440
|
end
|
427
441
|
RUBY
|
428
442
|
|
429
|
-
foo =
|
443
|
+
foo = @index["Foo"] #: as !nil
|
444
|
+
.first #: as Entry::Class
|
430
445
|
assert_equal(["A1", "A2", "A3", "A4", "A5", "A6"], foo.mixin_operation_module_names)
|
431
446
|
|
432
|
-
qux =
|
447
|
+
qux = @index["Foo::Qux"] #: as !nil
|
448
|
+
.first #: as Entry::Class
|
433
449
|
assert_equal(["Corge", "Corge", "Baz"], qux.mixin_operation_module_names)
|
434
450
|
|
435
|
-
constant_path_references =
|
451
|
+
constant_path_references = @index["ConstantPathReferences"] #: as !nil
|
452
|
+
.first #: as Entry::Class
|
436
453
|
assert_equal(["Foo::Bar", "Foo::Bar2"], constant_path_references.mixin_operation_module_names)
|
437
454
|
end
|
438
455
|
|
@@ -472,13 +489,16 @@ module RubyIndexer
|
|
472
489
|
end
|
473
490
|
RUBY
|
474
491
|
|
475
|
-
foo =
|
492
|
+
foo = @index["Foo::<Class:Foo>"] #: as !nil
|
493
|
+
.first #: as Entry::Class
|
476
494
|
assert_equal(["A1", "A2", "A3", "A4", "A5", "A6"], foo.mixin_operation_module_names)
|
477
495
|
|
478
|
-
qux =
|
496
|
+
qux = @index["Foo::Qux::<Class:Qux>"] #: as !nil
|
497
|
+
.first #: as Entry::Class
|
479
498
|
assert_equal(["Corge", "Corge", "Baz"], qux.mixin_operation_module_names)
|
480
499
|
|
481
|
-
constant_path_references =
|
500
|
+
constant_path_references = @index["ConstantPathReferences::<Class:ConstantPathReferences>"] #: as !nil
|
501
|
+
.first #: as Entry::Class
|
482
502
|
assert_equal(["Foo::Bar", "Foo::Bar2"], constant_path_references.mixin_operation_module_names)
|
483
503
|
end
|
484
504
|
|
@@ -492,7 +512,8 @@ module RubyIndexer
|
|
492
512
|
end
|
493
513
|
RUBY
|
494
514
|
|
495
|
-
foo =
|
515
|
+
foo = @index["Foo::<Class:Foo>"] #: as !nil
|
516
|
+
.first #: as Entry::SingletonClass
|
496
517
|
assert_equal(4, foo.location.start_line)
|
497
518
|
assert_equal("Some extra comments", foo.comments)
|
498
519
|
end
|
@@ -506,7 +527,8 @@ module RubyIndexer
|
|
506
527
|
end
|
507
528
|
RUBY
|
508
529
|
|
509
|
-
singleton =
|
530
|
+
singleton = @index["Foo::<Class:bar>"] #: as !nil
|
531
|
+
.first #: as Entry::SingletonClass
|
510
532
|
|
511
533
|
# Even though this is not correct, we consider any dynamic singleton class block as a regular singleton class.
|
512
534
|
# That pattern cannot be properly analyzed statically and assuming that it's always a regular singleton simplifies
|
@@ -539,7 +561,8 @@ module RubyIndexer
|
|
539
561
|
end
|
540
562
|
RUBY
|
541
563
|
|
542
|
-
foo =
|
564
|
+
foo = @index["Foo"] #: as !nil
|
565
|
+
.first #: as Entry::Class
|
543
566
|
refute_equal(foo.location, foo.name_location)
|
544
567
|
|
545
568
|
name_location = foo.name_location
|
@@ -548,7 +571,8 @@ module RubyIndexer
|
|
548
571
|
assert_equal(6, name_location.start_column)
|
549
572
|
assert_equal(9, name_location.end_column)
|
550
573
|
|
551
|
-
bar =
|
574
|
+
bar = @index["Bar"] #: as !nil
|
575
|
+
.first #: as Entry::Module
|
552
576
|
refute_equal(bar.location, bar.name_location)
|
553
577
|
|
554
578
|
name_location = bar.name_location
|
@@ -625,7 +649,8 @@ module RubyIndexer
|
|
625
649
|
|
626
650
|
@index.index_file(uri, collect_comments: false)
|
627
651
|
|
628
|
-
entry = @index["RubyLsp::NodeContext"]
|
652
|
+
entry = @index["RubyLsp::NodeContext"] #: as !nil
|
653
|
+
.first #: as !nil
|
629
654
|
|
630
655
|
assert_equal(<<~COMMENTS.chomp, entry.comments)
|
631
656
|
This class allows listeners to access contextual information about a node in the AST, such as its parent,
|
@@ -644,7 +669,7 @@ module RubyIndexer
|
|
644
669
|
end
|
645
670
|
RUBY
|
646
671
|
|
647
|
-
entry = @index["Foo"]
|
672
|
+
entry = @index["Foo"]&.first #: as !nil
|
648
673
|
assert_empty(entry.comments)
|
649
674
|
end
|
650
675
|
|
@@ -663,8 +688,8 @@ module RubyIndexer
|
|
663
688
|
# Verify we indexed the correct name
|
664
689
|
assert_entry("Foo::Bar::<Class:Bar>", Entry::SingletonClass, "/fake/path/foo.rb:1-2:3-5")
|
665
690
|
|
666
|
-
method = @index["baz"]&.first
|
667
|
-
assert_equal("Foo::Bar::<Class:Bar>", method.owner
|
691
|
+
method = @index["baz"]&.first #: as Entry::Method
|
692
|
+
assert_equal("Foo::Bar::<Class:Bar>", method.owner&.name)
|
668
693
|
end
|
669
694
|
|
670
695
|
def test_lazy_comments_with_spaces_are_properly_attributed
|
@@ -681,7 +706,7 @@ module RubyIndexer
|
|
681
706
|
File.write(path, source)
|
682
707
|
@index.index_single(URI::Generic.from_path(path: path), source, collect_comments: false)
|
683
708
|
|
684
|
-
entry = @index["Foo"]
|
709
|
+
entry = @index["Foo"]&.first #: as !nil
|
685
710
|
|
686
711
|
begin
|
687
712
|
assert_equal(<<~COMMENTS.chomp, entry.comments)
|
@@ -706,7 +731,7 @@ module RubyIndexer
|
|
706
731
|
File.write(path, source)
|
707
732
|
@index.index_single(URI::Generic.from_path(path: path), source, collect_comments: false)
|
708
733
|
|
709
|
-
entry = @index["Foo"]
|
734
|
+
entry = @index["Foo"]&.first #: as !nil
|
710
735
|
|
711
736
|
begin
|
712
737
|
assert_equal(<<~COMMENTS.chomp, entry.comments)
|
@@ -733,7 +758,7 @@ module RubyIndexer
|
|
733
758
|
File.write(path, source)
|
734
759
|
@index.index_single(URI::Generic.from_path(path: path), source, collect_comments: false)
|
735
760
|
|
736
|
-
entry = @index["Foo"]
|
761
|
+
entry = @index["Foo"]&.first #: as !nil
|
737
762
|
|
738
763
|
begin
|
739
764
|
assert_empty(entry.comments)
|
@@ -97,10 +97,12 @@ module RubyIndexer
|
|
97
97
|
path = Pathname.new(RbConfig::CONFIG["rubylibdir"]).join("extra_file.txt").to_s
|
98
98
|
FileUtils.touch(path)
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
begin
|
101
|
+
uris = @config.indexable_uris
|
102
|
+
assert(uris.none? { |uri| uri.full_path == path })
|
103
|
+
ensure
|
104
|
+
FileUtils.rm(path)
|
105
|
+
end
|
104
106
|
end
|
105
107
|
|
106
108
|
def test_paths_are_unique
|
@@ -94,17 +94,17 @@ module RubyIndexer
|
|
94
94
|
A::BAZ = 1
|
95
95
|
RUBY
|
96
96
|
|
97
|
-
|
98
|
-
assert_equal("FOO comment",
|
97
|
+
foo = @index["FOO"]&.first #: as !nil
|
98
|
+
assert_equal("FOO comment", foo.comments)
|
99
99
|
|
100
|
-
|
101
|
-
assert_equal("A::FOO comment",
|
100
|
+
a_foo = @index["A::FOO"]&.first #: as !nil
|
101
|
+
assert_equal("A::FOO comment", a_foo.comments)
|
102
102
|
|
103
|
-
|
104
|
-
assert_equal("::BAR comment",
|
103
|
+
bar = @index["BAR"]&.first #: as !nil
|
104
|
+
assert_equal("::BAR comment", bar.comments)
|
105
105
|
|
106
|
-
|
107
|
-
assert_equal("A::BAZ comment",
|
106
|
+
a_baz = @index["A::BAZ"]&.first #: as !nil
|
107
|
+
assert_equal("A::BAZ comment", a_baz.comments)
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_variable_path_constants_are_ignored
|
@@ -129,13 +129,13 @@ module RubyIndexer
|
|
129
129
|
end
|
130
130
|
RUBY
|
131
131
|
|
132
|
-
b_const = @index["A::B"]
|
132
|
+
b_const = @index["A::B"]&.first #: as !nil
|
133
133
|
assert_predicate(b_const, :private?)
|
134
134
|
|
135
|
-
c_const = @index["A::C"]
|
135
|
+
c_const = @index["A::C"]&.first #: as !nil
|
136
136
|
assert_predicate(c_const, :private?)
|
137
137
|
|
138
|
-
d_const = @index["A::D"]
|
138
|
+
d_const = @index["A::D"]&.first #: as !nil
|
139
139
|
assert_predicate(d_const, :public?)
|
140
140
|
end
|
141
141
|
|
@@ -162,13 +162,13 @@ module RubyIndexer
|
|
162
162
|
end
|
163
163
|
RUBY
|
164
164
|
|
165
|
-
a_const = @index["A::B::CONST_A"]
|
165
|
+
a_const = @index["A::B::CONST_A"]&.first #: as !nil
|
166
166
|
assert_predicate(a_const, :private?)
|
167
167
|
|
168
|
-
b_const = @index["A::B::CONST_B"]
|
168
|
+
b_const = @index["A::B::CONST_B"]&.first #: as !nil
|
169
169
|
assert_predicate(b_const, :private?)
|
170
170
|
|
171
|
-
c_const = @index["A::B::CONST_C"]
|
171
|
+
c_const = @index["A::B::CONST_C"]&.first #: as !nil
|
172
172
|
assert_predicate(c_const, :private?)
|
173
173
|
end
|
174
174
|
|
@@ -186,10 +186,10 @@ module RubyIndexer
|
|
186
186
|
A::B.private_constant(:CONST_B)
|
187
187
|
RUBY
|
188
188
|
|
189
|
-
a_const = @index["A::B::CONST_A"]
|
189
|
+
a_const = @index["A::B::CONST_A"]&.first #: as !nil
|
190
190
|
assert_predicate(a_const, :private?)
|
191
191
|
|
192
|
-
b_const = @index["A::B::CONST_B"]
|
192
|
+
b_const = @index["A::B::CONST_B"]&.first #: as !nil
|
193
193
|
assert_predicate(b_const, :private?)
|
194
194
|
end
|
195
195
|
|
@@ -207,12 +207,12 @@ module RubyIndexer
|
|
207
207
|
SECOND = A::FIRST
|
208
208
|
RUBY
|
209
209
|
|
210
|
-
unresolve_entry = @index["A::FIRST"]
|
210
|
+
unresolve_entry = @index["A::FIRST"]&.first #: as Entry::UnresolvedConstantAlias
|
211
211
|
assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
|
212
212
|
assert_equal(["A"], unresolve_entry.nesting)
|
213
213
|
assert_equal("B::C", unresolve_entry.target)
|
214
214
|
|
215
|
-
resolved_entry = @index.resolve("A::FIRST", [])
|
215
|
+
resolved_entry = @index.resolve("A::FIRST", [])&.first #: as Entry::ConstantAlias
|
216
216
|
assert_instance_of(Entry::ConstantAlias, resolved_entry)
|
217
217
|
assert_equal("A::B::C", resolved_entry.target)
|
218
218
|
end
|
@@ -233,25 +233,25 @@ module RubyIndexer
|
|
233
233
|
end
|
234
234
|
RUBY
|
235
235
|
|
236
|
-
unresolve_entry = @index["A::ALIAS"]
|
236
|
+
unresolve_entry = @index["A::ALIAS"]&.first #: as Entry::UnresolvedConstantAlias
|
237
237
|
assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
|
238
238
|
assert_equal(["A"], unresolve_entry.nesting)
|
239
239
|
assert_equal("B", unresolve_entry.target)
|
240
240
|
|
241
|
-
resolved_entry = @index.resolve("ALIAS", ["A"])
|
241
|
+
resolved_entry = @index.resolve("ALIAS", ["A"])&.first #: as Entry::ConstantAlias
|
242
242
|
assert_instance_of(Entry::ConstantAlias, resolved_entry)
|
243
243
|
assert_equal("A::B", resolved_entry.target)
|
244
244
|
|
245
|
-
resolved_entry = @index.resolve("ALIAS::C", ["A"])
|
245
|
+
resolved_entry = @index.resolve("ALIAS::C", ["A"])&.first #: as Entry::Module
|
246
246
|
assert_instance_of(Entry::Module, resolved_entry)
|
247
247
|
assert_equal("A::B::C", resolved_entry.name)
|
248
248
|
|
249
|
-
unresolve_entry = @index["Other::ONE_MORE"]
|
249
|
+
unresolve_entry = @index["Other::ONE_MORE"]&.first #: as Entry::UnresolvedConstantAlias
|
250
250
|
assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
|
251
251
|
assert_equal(["Other"], unresolve_entry.nesting)
|
252
252
|
assert_equal("A::ALIAS", unresolve_entry.target)
|
253
253
|
|
254
|
-
resolved_entry = @index.resolve("Other::ONE_MORE::C", [])
|
254
|
+
resolved_entry = @index.resolve("Other::ONE_MORE::C", [])&.first
|
255
255
|
assert_instance_of(Entry::Module, resolved_entry)
|
256
256
|
end
|
257
257
|
|
@@ -266,55 +266,55 @@ module RubyIndexer
|
|
266
266
|
RUBY
|
267
267
|
|
268
268
|
# B and C
|
269
|
-
unresolve_entry = @index["A::B"]
|
269
|
+
unresolve_entry = @index["A::B"]&.first #: as Entry::UnresolvedConstantAlias
|
270
270
|
assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
|
271
271
|
assert_equal(["A"], unresolve_entry.nesting)
|
272
272
|
assert_equal("C", unresolve_entry.target)
|
273
273
|
|
274
|
-
resolved_entry = @index.resolve("A::B", [])
|
274
|
+
resolved_entry = @index.resolve("A::B", [])&.first #: as Entry::ConstantAlias
|
275
275
|
assert_instance_of(Entry::ConstantAlias, resolved_entry)
|
276
276
|
assert_equal("A::C", resolved_entry.target)
|
277
277
|
|
278
|
-
constant = @index["A::C"]
|
278
|
+
constant = @index["A::C"]&.first #: as Entry::Constant
|
279
279
|
assert_instance_of(Entry::Constant, constant)
|
280
280
|
|
281
281
|
# D and E
|
282
|
-
unresolve_entry = @index["A::D"]
|
282
|
+
unresolve_entry = @index["A::D"]&.first #: as Entry::UnresolvedConstantAlias
|
283
283
|
assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
|
284
284
|
assert_equal(["A"], unresolve_entry.nesting)
|
285
285
|
assert_equal("E", unresolve_entry.target)
|
286
286
|
|
287
|
-
resolved_entry = @index.resolve("A::D", [])
|
287
|
+
resolved_entry = @index.resolve("A::D", [])&.first #: as Entry::ConstantAlias
|
288
288
|
assert_instance_of(Entry::ConstantAlias, resolved_entry)
|
289
289
|
assert_equal("A::E", resolved_entry.target)
|
290
290
|
|
291
291
|
# F and G::H
|
292
|
-
unresolve_entry = @index["A::F"]
|
292
|
+
unresolve_entry = @index["A::F"]&.first #: as Entry::UnresolvedConstantAlias
|
293
293
|
assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
|
294
294
|
assert_equal(["A"], unresolve_entry.nesting)
|
295
295
|
assert_equal("G::H", unresolve_entry.target)
|
296
296
|
|
297
|
-
resolved_entry = @index.resolve("A::F", [])
|
297
|
+
resolved_entry = @index.resolve("A::F", [])&.first #: as Entry::ConstantAlias
|
298
298
|
assert_instance_of(Entry::ConstantAlias, resolved_entry)
|
299
299
|
assert_equal("A::G::H", resolved_entry.target)
|
300
300
|
|
301
301
|
# I::J, K::L and M
|
302
|
-
unresolve_entry = @index["A::I::J"]
|
302
|
+
unresolve_entry = @index["A::I::J"]&.first #: as Entry::UnresolvedConstantAlias
|
303
303
|
assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
|
304
304
|
assert_equal(["A"], unresolve_entry.nesting)
|
305
305
|
assert_equal("K::L", unresolve_entry.target)
|
306
306
|
|
307
|
-
resolved_entry = @index.resolve("A::I::J", [])
|
307
|
+
resolved_entry = @index.resolve("A::I::J", [])&.first #: as Entry::ConstantAlias
|
308
308
|
assert_instance_of(Entry::ConstantAlias, resolved_entry)
|
309
309
|
assert_equal("A::K::L", resolved_entry.target)
|
310
310
|
|
311
311
|
# When we are resolving A::I::J, we invoke `resolve("K::L", ["A"])`, which recursively resolves A::K::L too.
|
312
312
|
# Therefore, both A::I::J and A::K::L point to A::M by the end of the previous resolve invocation
|
313
|
-
resolved_entry = @index["A::K::L"]
|
313
|
+
resolved_entry = @index["A::K::L"]&.first #: as Entry::ConstantAlias
|
314
314
|
assert_instance_of(Entry::ConstantAlias, resolved_entry)
|
315
315
|
assert_equal("A::M", resolved_entry.target)
|
316
316
|
|
317
|
-
constant = @index["A::M"]
|
317
|
+
constant = @index["A::M"]&.first
|
318
318
|
assert_instance_of(Entry::Constant, constant)
|
319
319
|
end
|
320
320
|
|