ruby-lsp 0.17.4 → 0.17.13

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -2
  3. data/VERSION +1 -1
  4. data/exe/ruby-lsp +26 -1
  5. data/exe/ruby-lsp-check +1 -1
  6. data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +74 -43
  7. data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +26 -0
  8. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +147 -29
  9. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +383 -79
  10. data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +195 -61
  11. data/lib/ruby_indexer/ruby_indexer.rb +1 -8
  12. data/lib/ruby_indexer/test/classes_and_modules_test.rb +71 -3
  13. data/lib/ruby_indexer/test/configuration_test.rb +1 -1
  14. data/lib/ruby_indexer/test/constant_test.rb +17 -17
  15. data/lib/ruby_indexer/test/enhancements_test.rb +197 -0
  16. data/lib/ruby_indexer/test/index_test.rb +367 -17
  17. data/lib/ruby_indexer/test/method_test.rb +58 -25
  18. data/lib/ruby_indexer/test/rbs_indexer_test.rb +297 -0
  19. data/lib/ruby_indexer/test/test_case.rb +1 -5
  20. data/lib/ruby_lsp/addon.rb +22 -5
  21. data/lib/ruby_lsp/base_server.rb +8 -3
  22. data/lib/ruby_lsp/document.rb +27 -46
  23. data/lib/ruby_lsp/erb_document.rb +125 -0
  24. data/lib/ruby_lsp/global_state.rb +47 -19
  25. data/lib/ruby_lsp/internal.rb +2 -0
  26. data/lib/ruby_lsp/listeners/completion.rb +161 -57
  27. data/lib/ruby_lsp/listeners/definition.rb +91 -27
  28. data/lib/ruby_lsp/listeners/document_highlight.rb +5 -1
  29. data/lib/ruby_lsp/listeners/hover.rb +61 -19
  30. data/lib/ruby_lsp/listeners/signature_help.rb +13 -6
  31. data/lib/ruby_lsp/node_context.rb +65 -5
  32. data/lib/ruby_lsp/requests/code_action_resolve.rb +107 -9
  33. data/lib/ruby_lsp/requests/code_actions.rb +11 -2
  34. data/lib/ruby_lsp/requests/completion.rb +4 -4
  35. data/lib/ruby_lsp/requests/completion_resolve.rb +14 -9
  36. data/lib/ruby_lsp/requests/definition.rb +18 -8
  37. data/lib/ruby_lsp/requests/diagnostics.rb +6 -5
  38. data/lib/ruby_lsp/requests/document_symbol.rb +2 -7
  39. data/lib/ruby_lsp/requests/folding_ranges.rb +6 -2
  40. data/lib/ruby_lsp/requests/formatting.rb +15 -0
  41. data/lib/ruby_lsp/requests/hover.rb +5 -5
  42. data/lib/ruby_lsp/requests/on_type_formatting.rb +6 -4
  43. data/lib/ruby_lsp/requests/selection_ranges.rb +1 -1
  44. data/lib/ruby_lsp/requests/show_syntax_tree.rb +3 -2
  45. data/lib/ruby_lsp/requests/signature_help.rb +3 -3
  46. data/lib/ruby_lsp/requests/support/common.rb +11 -2
  47. data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +2 -6
  48. data/lib/ruby_lsp/ruby_document.rb +74 -0
  49. data/lib/ruby_lsp/server.rb +129 -54
  50. data/lib/ruby_lsp/store.rb +33 -9
  51. data/lib/ruby_lsp/test_helper.rb +3 -1
  52. data/lib/ruby_lsp/type_inferrer.rb +61 -25
  53. data/lib/ruby_lsp/utils.rb +13 -0
  54. metadata +9 -8
  55. data/exe/ruby-lsp-doctor +0 -23
@@ -15,62 +15,65 @@ module RubyIndexer
15
15
  loader = RBS::EnvironmentLoader.new
16
16
  RBS::Environment.from_loader(loader).resolve_type_names
17
17
 
18
- loader.each_signature do |source, pathname, _buffer, declarations, _directives|
19
- process_signature(source, pathname, declarations)
18
+ loader.each_signature do |_source, pathname, _buffer, declarations, _directives|
19
+ process_signature(pathname, declarations)
20
20
  end
21
21
  end
22
22
 
23
- private
24
-
25
- sig { params(source: T.untyped, pathname: Pathname, declarations: T::Array[RBS::AST::Declarations::Base]).void }
26
- def process_signature(source, pathname, declarations)
23
+ sig do
24
+ params(
25
+ pathname: Pathname,
26
+ declarations: T::Array[RBS::AST::Declarations::Base],
27
+ ).void
28
+ end
29
+ def process_signature(pathname, declarations)
27
30
  declarations.each do |declaration|
28
31
  process_declaration(declaration, pathname)
29
32
  end
30
33
  end
31
34
 
35
+ private
36
+
32
37
  sig { params(declaration: RBS::AST::Declarations::Base, pathname: Pathname).void }
33
38
  def process_declaration(declaration, pathname)
34
39
  case declaration
35
- when RBS::AST::Declarations::Class
36
- handle_class_declaration(declaration, pathname)
37
- when RBS::AST::Declarations::Module
38
- handle_module_declaration(declaration, pathname)
40
+ when RBS::AST::Declarations::Class, RBS::AST::Declarations::Module
41
+ handle_class_or_module_declaration(declaration, pathname)
42
+ when RBS::AST::Declarations::Constant
43
+ namespace_nesting = declaration.name.namespace.path.map(&:to_s)
44
+ handle_constant(declaration, namespace_nesting, pathname.to_s)
39
45
  else # rubocop:disable Style/EmptyElse
40
46
  # Other kinds not yet handled
41
47
  end
42
48
  end
43
49
 
44
- sig { params(declaration: RBS::AST::Declarations::Class, pathname: Pathname).void }
45
- def handle_class_declaration(declaration, pathname)
46
- nesting = [declaration.name.name.to_s]
47
- file_path = pathname.to_s
48
- location = to_ruby_indexer_location(declaration.location)
49
- comments = Array(declaration.comment&.string)
50
- parent_class = declaration.super_class&.name&.name&.to_s
51
- class_entry = Entry::Class.new(nesting, file_path, location, comments, parent_class)
52
- add_declaration_mixins_to_entry(declaration, class_entry)
53
- @index.add(class_entry)
54
- declaration.members.each do |member|
55
- next unless member.is_a?(RBS::AST::Members::MethodDefinition)
56
-
57
- handle_method(member, class_entry)
58
- end
50
+ sig do
51
+ params(declaration: T.any(RBS::AST::Declarations::Class, RBS::AST::Declarations::Module), pathname: Pathname).void
59
52
  end
60
-
61
- sig { params(declaration: RBS::AST::Declarations::Module, pathname: Pathname).void }
62
- def handle_module_declaration(declaration, pathname)
53
+ def handle_class_or_module_declaration(declaration, pathname)
63
54
  nesting = [declaration.name.name.to_s]
64
55
  file_path = pathname.to_s
65
56
  location = to_ruby_indexer_location(declaration.location)
66
- comments = Array(declaration.comment&.string)
67
- module_entry = Entry::Module.new(nesting, file_path, location, comments)
68
- add_declaration_mixins_to_entry(declaration, module_entry)
69
- @index.add(module_entry)
57
+ comments = comments_to_string(declaration)
58
+ entry = if declaration.is_a?(RBS::AST::Declarations::Class)
59
+ parent_class = declaration.super_class&.name&.name&.to_s
60
+ Entry::Class.new(nesting, file_path, location, location, comments, parent_class)
61
+ else
62
+ Entry::Module.new(nesting, file_path, location, location, comments)
63
+ end
64
+ add_declaration_mixins_to_entry(declaration, entry)
65
+ @index.add(entry)
70
66
  declaration.members.each do |member|
71
- next unless member.is_a?(RBS::AST::Members::MethodDefinition)
72
-
73
- handle_method(member, module_entry)
67
+ case member
68
+ when RBS::AST::Members::MethodDefinition
69
+ handle_method(member, entry)
70
+ when RBS::AST::Declarations::Constant
71
+ handle_constant(member, nesting, file_path)
72
+ when RBS::AST::Members::Alias
73
+ # In RBS, an alias means that two methods have the same signature.
74
+ # It does not mean the same thing as a Ruby alias.
75
+ handle_signature_alias(member, entry)
76
+ end
74
77
  end
75
78
  end
76
79
 
@@ -93,16 +96,15 @@ module RubyIndexer
93
96
  def add_declaration_mixins_to_entry(declaration, entry)
94
97
  declaration.each_mixin do |mixin|
95
98
  name = mixin.name.name.to_s
96
- mixin_operation =
97
- case mixin
98
- when RBS::AST::Members::Include
99
- Entry::Include.new(name)
100
- when RBS::AST::Members::Extend
101
- Entry::Extend.new(name)
102
- when RBS::AST::Members::Prepend
103
- Entry::Prepend.new(name)
104
- end
105
- entry.mixin_operations << mixin_operation if mixin_operation
99
+ case mixin
100
+ when RBS::AST::Members::Include
101
+ entry.mixin_operations << Entry::Include.new(name)
102
+ when RBS::AST::Members::Prepend
103
+ entry.mixin_operations << Entry::Prepend.new(name)
104
+ when RBS::AST::Members::Extend
105
+ singleton = @index.existing_or_new_singleton_class(entry.name)
106
+ singleton.mixin_operations << Entry::Include.new(name)
107
+ end
106
108
  end
107
109
  end
108
110
 
@@ -111,7 +113,7 @@ module RubyIndexer
111
113
  name = member.name.name
112
114
  file_path = member.location.buffer.name
113
115
  location = to_ruby_indexer_location(member.location)
114
- comments = Array(member.comment&.string)
116
+ comments = comments_to_string(member)
115
117
 
116
118
  visibility = case member.visibility
117
119
  when :private
@@ -122,26 +124,158 @@ module RubyIndexer
122
124
  Entry::Visibility::PUBLIC
123
125
  end
124
126
 
125
- real_owner = member.singleton? ? existing_or_new_singleton_klass(owner) : owner
126
- @index.add(Entry::Method.new(name, file_path, location, comments, [], visibility, real_owner))
127
+ real_owner = member.singleton? ? @index.existing_or_new_singleton_class(owner.name) : owner
128
+ signatures = signatures(member)
129
+ @index.add(Entry::Method.new(name, file_path, location, location, comments, signatures, visibility, real_owner))
130
+ end
131
+
132
+ sig { params(member: RBS::AST::Members::MethodDefinition).returns(T::Array[Entry::Signature]) }
133
+ def signatures(member)
134
+ member.overloads.map do |overload|
135
+ parameters = process_overload(overload)
136
+ Entry::Signature.new(parameters)
137
+ end
127
138
  end
128
139
 
129
- sig { params(owner: Entry::Namespace).returns(T.nilable(Entry::Class)) }
130
- def existing_or_new_singleton_klass(owner)
131
- *_parts, name = owner.name.split("::")
140
+ sig { params(overload: RBS::AST::Members::MethodDefinition::Overload).returns(T::Array[Entry::Parameter]) }
141
+ def process_overload(overload)
142
+ function = T.cast(overload.method_type.type, RBS::Types::Function)
143
+ parameters = parse_arguments(function)
144
+
145
+ block = overload.method_type.block
146
+ parameters << Entry::BlockParameter.anonymous if block&.required
147
+
148
+ parameters
149
+ end
150
+
151
+ sig { params(function: RBS::Types::Function).returns(T::Array[Entry::Parameter]) }
152
+ def parse_arguments(function)
153
+ parameters = []
154
+ parameters.concat(process_required_and_optional_positionals(function))
155
+ parameters.concat(process_trailing_positionals(function)) if function.trailing_positionals
156
+ parameters << process_rest_positionals(function) if function.rest_positionals
157
+ parameters.concat(process_required_keywords(function)) if function.required_keywords
158
+ parameters.concat(process_optional_keywords(function)) if function.optional_keywords
159
+ parameters << process_rest_keywords(function) if function.rest_keywords
160
+ parameters
161
+ end
162
+
163
+ sig { params(function: RBS::Types::Function).returns(T::Array[Entry::RequiredParameter]) }
164
+ def process_required_and_optional_positionals(function)
165
+ argument_offset = 0
166
+
167
+ required = function.required_positionals.map.with_index(argument_offset) do |param, i|
168
+ # Some parameters don't have names, e.g.
169
+ # def self.try_convert: [U] (untyped) -> ::Array[U]?
170
+ name = param.name || :"arg#{i}"
171
+ argument_offset += 1
172
+
173
+ Entry::RequiredParameter.new(name: name)
174
+ end
132
175
 
133
- # Return the existing singleton class if available
134
- singleton_entries = T.cast(
135
- @index["#{owner.name}::<Class:#{name}>"],
136
- T.nilable(T::Array[Entry::SingletonClass]),
176
+ optional = function.optional_positionals.map.with_index(argument_offset) do |param, i|
177
+ # Optional positionals may be unnamed, e.g.
178
+ # def self.polar: (Numeric, ?Numeric) -> Complex
179
+ name = param.name || :"arg#{i}"
180
+
181
+ Entry::OptionalParameter.new(name: name)
182
+ end
183
+
184
+ required + optional
185
+ end
186
+
187
+ sig { params(function: RBS::Types::Function).returns(T::Array[Entry::OptionalParameter]) }
188
+ def process_trailing_positionals(function)
189
+ function.trailing_positionals.map do |param|
190
+ Entry::OptionalParameter.new(name: param.name)
191
+ end
192
+ end
193
+
194
+ sig { params(function: RBS::Types::Function).returns(Entry::RestParameter) }
195
+ def process_rest_positionals(function)
196
+ rest = function.rest_positionals
197
+
198
+ rest_name = rest.name || Entry::RestParameter::DEFAULT_NAME
199
+
200
+ Entry::RestParameter.new(name: rest_name)
201
+ end
202
+
203
+ sig { params(function: RBS::Types::Function).returns(T::Array[Entry::KeywordParameter]) }
204
+ def process_required_keywords(function)
205
+ function.required_keywords.map do |name, _param|
206
+ Entry::KeywordParameter.new(name: name)
207
+ end
208
+ end
209
+
210
+ sig { params(function: RBS::Types::Function).returns(T::Array[Entry::OptionalKeywordParameter]) }
211
+ def process_optional_keywords(function)
212
+ function.optional_keywords.map do |name, _param|
213
+ Entry::OptionalKeywordParameter.new(name: name)
214
+ end
215
+ end
216
+
217
+ sig { params(function: RBS::Types::Function).returns(Entry::KeywordRestParameter) }
218
+ def process_rest_keywords(function)
219
+ param = function.rest_keywords
220
+
221
+ name = param.name || Entry::KeywordRestParameter::DEFAULT_NAME
222
+
223
+ Entry::KeywordRestParameter.new(name: name)
224
+ end
225
+
226
+ # RBS treats constant definitions differently depend on where they are defined.
227
+ # When constants' rbs are defined inside a class/module block, they are treated as
228
+ # members of the class/module.
229
+ #
230
+ # module Encoding
231
+ # US_ASCII = ... # US_ASCII is a member of Encoding
232
+ # end
233
+ #
234
+ # When constants' rbs are defined outside a class/module block, they are treated as
235
+ # top-level constants.
236
+ #
237
+ # Complex::I = ... # Complex::I is a top-level constant
238
+ #
239
+ # And we need to handle their nesting differently.
240
+ sig { params(declaration: RBS::AST::Declarations::Constant, nesting: T::Array[String], file_path: String).void }
241
+ def handle_constant(declaration, nesting, file_path)
242
+ fully_qualified_name = [*nesting, declaration.name.name.to_s].join("::")
243
+ @index.add(Entry::Constant.new(
244
+ fully_qualified_name,
245
+ file_path,
246
+ to_ruby_indexer_location(declaration.location),
247
+ comments_to_string(declaration),
248
+ ))
249
+ end
250
+
251
+ sig { params(member: RBS::AST::Members::Alias, owner_entry: Entry::Namespace).void }
252
+ def handle_signature_alias(member, owner_entry)
253
+ file_path = member.location.buffer.name
254
+ comments = comments_to_string(member)
255
+
256
+ entry = Entry::UnresolvedMethodAlias.new(
257
+ member.new_name.to_s,
258
+ member.old_name.to_s,
259
+ owner_entry,
260
+ file_path,
261
+ to_ruby_indexer_location(member.location),
262
+ comments,
137
263
  )
138
- return singleton_entries.first if singleton_entries
139
264
 
140
- # If not available, create the singleton class lazily
141
- nesting = owner.nesting + ["<Class:#{name}>"]
142
- entry = Entry::SingletonClass.new(nesting, owner.file_path, owner.location, [], nil)
143
- @index.add(entry, skip_prefix_tree: true)
144
- entry
265
+ @index.add(entry)
266
+ end
267
+
268
+ sig do
269
+ params(declaration: T.any(
270
+ RBS::AST::Declarations::Class,
271
+ RBS::AST::Declarations::Module,
272
+ RBS::AST::Declarations::Constant,
273
+ RBS::AST::Members::MethodDefinition,
274
+ RBS::AST::Members::Alias,
275
+ )).returns(T::Array[String])
276
+ end
277
+ def comments_to_string(declaration)
278
+ Array(declaration.comment&.string)
145
279
  end
146
280
  end
147
281
  end
@@ -6,6 +6,7 @@ require "did_you_mean"
6
6
 
7
7
  require "ruby_indexer/lib/ruby_indexer/indexable_path"
8
8
  require "ruby_indexer/lib/ruby_indexer/declaration_listener"
9
+ require "ruby_indexer/lib/ruby_indexer/enhancement"
9
10
  require "ruby_indexer/lib/ruby_indexer/index"
10
11
  require "ruby_indexer/lib/ruby_indexer/entry"
11
12
  require "ruby_indexer/lib/ruby_indexer/configuration"
@@ -14,12 +15,4 @@ require "ruby_indexer/lib/ruby_indexer/location"
14
15
  require "ruby_indexer/lib/ruby_indexer/rbs_indexer"
15
16
 
16
17
  module RubyIndexer
17
- @configuration = T.let(Configuration.new, Configuration)
18
-
19
- class << self
20
- extend T::Sig
21
-
22
- sig { returns(Configuration) }
23
- attr_reader :configuration
24
- end
25
18
  end
@@ -461,13 +461,13 @@ module RubyIndexer
461
461
  end
462
462
  RUBY
463
463
 
464
- foo = T.must(@index["Foo"][0])
464
+ foo = T.must(@index["Foo::<Class:Foo>"][0])
465
465
  assert_equal(["A1", "A2", "A3", "A4", "A5", "A6"], foo.mixin_operation_module_names)
466
466
 
467
- qux = T.must(@index["Foo::Qux"][0])
467
+ qux = T.must(@index["Foo::Qux::<Class:Qux>"][0])
468
468
  assert_equal(["Corge", "Corge", "Baz"], qux.mixin_operation_module_names)
469
469
 
470
- constant_path_references = T.must(@index["ConstantPathReferences"][0])
470
+ constant_path_references = T.must(@index["ConstantPathReferences::<Class:ConstantPathReferences>"][0])
471
471
  assert_equal(["Foo::Bar", "Foo::Bar2"], constant_path_references.mixin_operation_module_names)
472
472
  end
473
473
 
@@ -516,5 +516,73 @@ module RubyIndexer
516
516
 
517
517
  assert_entry("Foo::<Class:Foo>::Bar", Entry::Class, "/fake/path/foo.rb:2-4:3-7")
518
518
  end
519
+
520
+ def test_name_location_points_to_constant_path_location
521
+ index(<<~RUBY)
522
+ class Foo
523
+ def foo; end
524
+ end
525
+
526
+ module Bar
527
+ def bar; end
528
+ end
529
+ RUBY
530
+
531
+ foo = T.must(@index["Foo"].first)
532
+ refute_equal(foo.location, foo.name_location)
533
+
534
+ name_location = foo.name_location
535
+ assert_equal(1, name_location.start_line)
536
+ assert_equal(1, name_location.end_line)
537
+ assert_equal(6, name_location.start_column)
538
+ assert_equal(9, name_location.end_column)
539
+
540
+ bar = T.must(@index["Bar"].first)
541
+ refute_equal(bar.location, bar.name_location)
542
+
543
+ name_location = bar.name_location
544
+ assert_equal(5, name_location.start_line)
545
+ assert_equal(5, name_location.end_line)
546
+ assert_equal(7, name_location.start_column)
547
+ assert_equal(10, name_location.end_column)
548
+ end
549
+
550
+ def test_indexing_namespaces_inside_top_level_references
551
+ index(<<~RUBY)
552
+ module ::Foo
553
+ class Bar
554
+ end
555
+ end
556
+ RUBY
557
+
558
+ # We want to explicitly verify that we didn't introduce the leading `::` by accident, but `Index#[]` deletes the
559
+ # prefix when we use `refute_entry`
560
+ entries = @index.instance_variable_get(:@entries)
561
+ refute(entries.key?("::Foo"))
562
+ refute(entries.key?("::Foo::Bar"))
563
+ assert_entry("Foo", Entry::Module, "/fake/path/foo.rb:0-0:3-3")
564
+ assert_entry("Foo::Bar", Entry::Class, "/fake/path/foo.rb:1-2:2-5")
565
+ end
566
+
567
+ def test_indexing_namespaces_inside_nested_top_level_references
568
+ index(<<~RUBY)
569
+ class Baz
570
+ module ::Foo
571
+ class Bar
572
+ end
573
+
574
+ class ::Qux
575
+ end
576
+ end
577
+ end
578
+ RUBY
579
+
580
+ refute_entry("Baz::Foo")
581
+ refute_entry("Baz::Foo::Bar")
582
+ assert_entry("Baz", Entry::Class, "/fake/path/foo.rb:0-0:8-3")
583
+ assert_entry("Foo", Entry::Module, "/fake/path/foo.rb:1-2:7-5")
584
+ assert_entry("Foo::Bar", Entry::Class, "/fake/path/foo.rb:2-4:3-7")
585
+ assert_entry("Qux", Entry::Class, "/fake/path/foo.rb:5-4:6-7")
586
+ end
519
587
  end
520
588
  end
@@ -108,7 +108,7 @@ module RubyIndexer
108
108
  end
109
109
 
110
110
  def test_magic_comments_regex
111
- regex = RubyIndexer.configuration.magic_comment_regex
111
+ regex = @config.magic_comment_regex
112
112
 
113
113
  [
114
114
  "# frozen_string_literal:",
@@ -200,12 +200,12 @@ module RubyIndexer
200
200
  RUBY
201
201
 
202
202
  unresolve_entry = @index["A::FIRST"].first
203
- assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
203
+ assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
204
204
  assert_equal(["A"], unresolve_entry.nesting)
205
205
  assert_equal("B::C", unresolve_entry.target)
206
206
 
207
207
  resolved_entry = @index.resolve("A::FIRST", []).first
208
- assert_instance_of(Entry::Alias, resolved_entry)
208
+ assert_instance_of(Entry::ConstantAlias, resolved_entry)
209
209
  assert_equal("A::B::C", resolved_entry.target)
210
210
  end
211
211
 
@@ -226,12 +226,12 @@ module RubyIndexer
226
226
  RUBY
227
227
 
228
228
  unresolve_entry = @index["A::ALIAS"].first
229
- assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
229
+ assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
230
230
  assert_equal(["A"], unresolve_entry.nesting)
231
231
  assert_equal("B", unresolve_entry.target)
232
232
 
233
233
  resolved_entry = @index.resolve("ALIAS", ["A"]).first
234
- assert_instance_of(Entry::Alias, resolved_entry)
234
+ assert_instance_of(Entry::ConstantAlias, resolved_entry)
235
235
  assert_equal("A::B", resolved_entry.target)
236
236
 
237
237
  resolved_entry = @index.resolve("ALIAS::C", ["A"]).first
@@ -239,7 +239,7 @@ module RubyIndexer
239
239
  assert_equal("A::B::C", resolved_entry.name)
240
240
 
241
241
  unresolve_entry = @index["Other::ONE_MORE"].first
242
- assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
242
+ assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
243
243
  assert_equal(["Other"], unresolve_entry.nesting)
244
244
  assert_equal("A::ALIAS", unresolve_entry.target)
245
245
 
@@ -259,12 +259,12 @@ module RubyIndexer
259
259
 
260
260
  # B and C
261
261
  unresolve_entry = @index["A::B"].first
262
- assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
262
+ assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
263
263
  assert_equal(["A"], unresolve_entry.nesting)
264
264
  assert_equal("C", unresolve_entry.target)
265
265
 
266
266
  resolved_entry = @index.resolve("A::B", []).first
267
- assert_instance_of(Entry::Alias, resolved_entry)
267
+ assert_instance_of(Entry::ConstantAlias, resolved_entry)
268
268
  assert_equal("A::C", resolved_entry.target)
269
269
 
270
270
  constant = @index["A::C"].first
@@ -272,38 +272,38 @@ module RubyIndexer
272
272
 
273
273
  # D and E
274
274
  unresolve_entry = @index["A::D"].first
275
- assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
275
+ assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
276
276
  assert_equal(["A"], unresolve_entry.nesting)
277
277
  assert_equal("E", unresolve_entry.target)
278
278
 
279
279
  resolved_entry = @index.resolve("A::D", []).first
280
- assert_instance_of(Entry::Alias, resolved_entry)
280
+ assert_instance_of(Entry::ConstantAlias, resolved_entry)
281
281
  assert_equal("A::E", resolved_entry.target)
282
282
 
283
283
  # F and G::H
284
284
  unresolve_entry = @index["A::F"].first
285
- assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
285
+ assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
286
286
  assert_equal(["A"], unresolve_entry.nesting)
287
287
  assert_equal("G::H", unresolve_entry.target)
288
288
 
289
289
  resolved_entry = @index.resolve("A::F", []).first
290
- assert_instance_of(Entry::Alias, resolved_entry)
290
+ assert_instance_of(Entry::ConstantAlias, resolved_entry)
291
291
  assert_equal("A::G::H", resolved_entry.target)
292
292
 
293
293
  # I::J, K::L and M
294
294
  unresolve_entry = @index["A::I::J"].first
295
- assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
295
+ assert_instance_of(Entry::UnresolvedConstantAlias, unresolve_entry)
296
296
  assert_equal(["A"], unresolve_entry.nesting)
297
297
  assert_equal("K::L", unresolve_entry.target)
298
298
 
299
299
  resolved_entry = @index.resolve("A::I::J", []).first
300
- assert_instance_of(Entry::Alias, resolved_entry)
300
+ assert_instance_of(Entry::ConstantAlias, resolved_entry)
301
301
  assert_equal("A::K::L", resolved_entry.target)
302
302
 
303
303
  # When we are resolving A::I::J, we invoke `resolve("K::L", ["A"])`, which recursively resolves A::K::L too.
304
304
  # Therefore, both A::I::J and A::K::L point to A::M by the end of the previous resolve invocation
305
305
  resolved_entry = @index["A::K::L"].first
306
- assert_instance_of(Entry::Alias, resolved_entry)
306
+ assert_instance_of(Entry::ConstantAlias, resolved_entry)
307
307
  assert_equal("A::M", resolved_entry.target)
308
308
 
309
309
  constant = @index["A::M"].first
@@ -344,11 +344,11 @@ module RubyIndexer
344
344
  RUBY
345
345
 
346
346
  assert_entry("A::B", Entry::Constant, "/fake/path/foo.rb:1-2:1-3")
347
- assert_entry("A::C", Entry::UnresolvedAlias, "/fake/path/foo.rb:1-5:1-6")
348
- assert_entry("A::D::E", Entry::UnresolvedAlias, "/fake/path/foo.rb:2-2:2-6")
347
+ assert_entry("A::C", Entry::UnresolvedConstantAlias, "/fake/path/foo.rb:1-5:1-6")
348
+ assert_entry("A::D::E", Entry::UnresolvedConstantAlias, "/fake/path/foo.rb:2-2:2-6")
349
349
  assert_entry("A::F::G", Entry::Constant, "/fake/path/foo.rb:2-8:2-12")
350
350
  assert_entry("A::H", Entry::Constant, "/fake/path/foo.rb:3-2:3-3")
351
- assert_entry("A::I::J", Entry::UnresolvedAlias, "/fake/path/foo.rb:3-5:3-9")
351
+ assert_entry("A::I::J", Entry::UnresolvedConstantAlias, "/fake/path/foo.rb:3-5:3-9")
352
352
  assert_entry("A::K", Entry::Constant, "/fake/path/foo.rb:4-2:4-3")
353
353
  assert_entry("A::L", Entry::Constant, "/fake/path/foo.rb:4-5:4-6")
354
354
  end