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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/exe/ruby-lsp-launcher +9 -1
  4. data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +1 -1
  5. data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +6 -3
  6. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +4 -2
  7. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +59 -29
  8. data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +5 -4
  9. data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +5 -1
  10. data/lib/ruby_indexer/test/class_variables_test.rb +14 -14
  11. data/lib/ruby_indexer/test/classes_and_modules_test.rb +65 -40
  12. data/lib/ruby_indexer/test/configuration_test.rb +6 -4
  13. data/lib/ruby_indexer/test/constant_test.rb +34 -34
  14. data/lib/ruby_indexer/test/enhancements_test.rb +1 -1
  15. data/lib/ruby_indexer/test/index_test.rb +139 -135
  16. data/lib/ruby_indexer/test/instance_variables_test.rb +37 -37
  17. data/lib/ruby_indexer/test/method_test.rb +118 -118
  18. data/lib/ruby_indexer/test/prefix_tree_test.rb +13 -13
  19. data/lib/ruby_indexer/test/rbs_indexer_test.rb +64 -70
  20. data/lib/ruby_indexer/test/test_case.rb +2 -2
  21. data/lib/ruby_lsp/erb_document.rb +12 -4
  22. data/lib/ruby_lsp/global_state.rb +1 -1
  23. data/lib/ruby_lsp/listeners/code_lens.rb +3 -3
  24. data/lib/ruby_lsp/listeners/completion.rb +24 -11
  25. data/lib/ruby_lsp/listeners/definition.rb +1 -1
  26. data/lib/ruby_lsp/listeners/document_link.rb +3 -1
  27. data/lib/ruby_lsp/listeners/document_symbol.rb +3 -3
  28. data/lib/ruby_lsp/listeners/folding_ranges.rb +8 -4
  29. data/lib/ruby_lsp/listeners/hover.rb +2 -2
  30. data/lib/ruby_lsp/listeners/semantic_highlighting.rb +12 -5
  31. data/lib/ruby_lsp/listeners/signature_help.rb +5 -1
  32. data/lib/ruby_lsp/listeners/spec_style.rb +1 -1
  33. data/lib/ruby_lsp/listeners/test_style.rb +3 -3
  34. data/lib/ruby_lsp/requests/code_action_resolve.rb +4 -3
  35. data/lib/ruby_lsp/requests/completion_resolve.rb +1 -1
  36. data/lib/ruby_lsp/requests/hover.rb +2 -2
  37. data/lib/ruby_lsp/requests/on_type_formatting.rb +4 -2
  38. data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +1 -2
  39. data/lib/ruby_lsp/requests/references.rb +2 -1
  40. data/lib/ruby_lsp/requests/rename.rb +8 -5
  41. data/lib/ruby_lsp/requests/semantic_highlighting.rb +4 -4
  42. data/lib/ruby_lsp/requests/show_syntax_tree.rb +1 -1
  43. data/lib/ruby_lsp/requests/support/common.rb +3 -1
  44. data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +2 -2
  45. data/lib/ruby_lsp/requests/support/source_uri.rb +1 -1
  46. data/lib/ruby_lsp/response_builders/document_symbol.rb +3 -2
  47. data/lib/ruby_lsp/response_builders/hover.rb +1 -1
  48. data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +1 -1
  49. data/lib/ruby_lsp/scripts/compose_bundle.rb +6 -4
  50. data/lib/ruby_lsp/server.rb +12 -4
  51. data/lib/ruby_lsp/setup_bundler.rb +5 -2
  52. data/lib/ruby_lsp/static_docs.rb +8 -1
  53. data/lib/ruby_lsp/store.rb +3 -2
  54. data/lib/ruby_lsp/test_reporters/lsp_reporter.rb +152 -0
  55. data/lib/ruby_lsp/test_reporters/minitest_reporter.rb +105 -0
  56. data/lib/ruby_lsp/test_reporters/test_unit_reporter.rb +94 -0
  57. data/lib/ruby_lsp/type_inferrer.rb +4 -1
  58. metadata +6 -6
  59. data/lib/ruby_lsp/ruby_lsp_reporter_plugin.rb +0 -109
  60. data/lib/ruby_lsp/test_reporter.rb +0 -207
  61. 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"].first
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"].first
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"].first)
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"].first
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"].first
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"][0]
269
- assert_equal("This is a Foo comment", first_foo_entry.comments)
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"][0]
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"][0]
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"].first
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"].first
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"].first
311
- assert_equal(Entry::Visibility::PUBLIC, d_const.visibility)
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 = T.must(@index["Foo"].first)
341
+ foo = @index["Foo"] #: as !nil
342
+ .first #: as Entry::Class
335
343
  assert_equal("Bar", foo.parent_class)
336
344
 
337
- baz = T.must(@index["Baz"].first)
345
+ baz = @index["Baz"] #: as !nil
346
+ .first #: as Entry::Class
338
347
  assert_equal("::Object", baz.parent_class)
339
348
 
340
- qux = T.must(@index["Something::Qux"].first)
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 = T.must(@index["FinalThing"].first)
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 = T.must(@index["Foo"][0])
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 = T.must(@index["Foo::Qux"][0])
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 = T.must(@index["ConstantPathReferences"][0])
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 = T.must(@index["Foo"][0])
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 = T.must(@index["Foo::Qux"][0])
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 = T.must(@index["ConstantPathReferences"][0])
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 = T.must(@index["Foo::<Class:Foo>"][0])
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 = T.must(@index["Foo::Qux::<Class:Qux>"][0])
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 = T.must(@index["ConstantPathReferences::<Class:ConstantPathReferences>"][0])
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 = T.must(@index["Foo::<Class:Foo>"].first)
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 = T.must(@index["Foo::<Class:bar>"].first)
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 = T.must(@index["Foo"].first)
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 = T.must(@index["Bar"].first)
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"].first
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"].first
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.name)
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"].first
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"].first
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"].first
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
- uris = @config.indexable_uris
101
- assert(uris.none? { |uri| uri.full_path == path })
102
- ensure
103
- FileUtils.rm(T.must(path))
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
- foo_comment = @index["FOO"].first.comments
98
- assert_equal("FOO comment", foo_comment)
97
+ foo = @index["FOO"]&.first #: as !nil
98
+ assert_equal("FOO comment", foo.comments)
99
99
 
100
- a_foo_comment = @index["A::FOO"].first.comments
101
- assert_equal("A::FOO comment", a_foo_comment)
100
+ a_foo = @index["A::FOO"]&.first #: as !nil
101
+ assert_equal("A::FOO comment", a_foo.comments)
102
102
 
103
- bar_comment = @index["BAR"].first.comments
104
- assert_equal("::BAR comment", bar_comment)
103
+ bar = @index["BAR"]&.first #: as !nil
104
+ assert_equal("::BAR comment", bar.comments)
105
105
 
106
- a_baz_comment = @index["A::BAZ"].first.comments
107
- assert_equal("A::BAZ comment", 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"].first
132
+ b_const = @index["A::B"]&.first #: as !nil
133
133
  assert_predicate(b_const, :private?)
134
134
 
135
- c_const = @index["A::C"].first
135
+ c_const = @index["A::C"]&.first #: as !nil
136
136
  assert_predicate(c_const, :private?)
137
137
 
138
- d_const = @index["A::D"].first
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"].first
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"].first
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"].first
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"].first
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"].first
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"].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", []).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"].first
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"]).first
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"]).first
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"].first
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", []).first
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"].first
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", []).first
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"].first
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"].first
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", []).first
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"].first
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", []).first
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"].first
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", []).first
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"].first
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"].first
317
+ constant = @index["A::M"]&.first
318
318
  assert_instance_of(Entry::Constant, constant)
319
319
  end
320
320
 
@@ -108,7 +108,7 @@ module RubyIndexer
108
108
  return unless association_name.is_a?(Prism::SymbolNode)
109
109
 
110
110
  @listener.add_method(
111
- T.must(association_name.value),
111
+ association_name.value, #: as !nil
112
112
  association_name.location,
113
113
  [],
114
114
  )