ruby-lsp 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/exe/ruby-lsp +2 -1
  4. data/exe/ruby-lsp-doctor +16 -0
  5. data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +5 -1
  6. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +205 -0
  7. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +23 -106
  8. data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +6 -6
  9. data/lib/ruby_indexer/lib/ruby_indexer/visitor.rb +101 -49
  10. data/lib/ruby_indexer/ruby_indexer.rb +1 -0
  11. data/lib/ruby_indexer/test/classes_and_modules_test.rb +49 -16
  12. data/lib/ruby_indexer/test/constant_test.rb +99 -36
  13. data/lib/ruby_indexer/test/index_test.rb +1 -1
  14. data/lib/ruby_indexer/test/method_test.rb +73 -0
  15. data/lib/ruby_indexer/test/test_case.rb +5 -1
  16. data/lib/ruby_lsp/addon.rb +8 -8
  17. data/lib/ruby_lsp/document.rb +14 -14
  18. data/lib/ruby_lsp/executor.rb +89 -53
  19. data/lib/ruby_lsp/internal.rb +7 -2
  20. data/lib/ruby_lsp/listener.rb +6 -6
  21. data/lib/ruby_lsp/requests/base_request.rb +1 -9
  22. data/lib/ruby_lsp/requests/code_action_resolve.rb +3 -3
  23. data/lib/ruby_lsp/requests/code_lens.rb +30 -30
  24. data/lib/ruby_lsp/requests/completion.rb +83 -32
  25. data/lib/ruby_lsp/requests/definition.rb +21 -15
  26. data/lib/ruby_lsp/requests/diagnostics.rb +1 -1
  27. data/lib/ruby_lsp/requests/document_highlight.rb +508 -31
  28. data/lib/ruby_lsp/requests/document_link.rb +24 -17
  29. data/lib/ruby_lsp/requests/document_symbol.rb +42 -42
  30. data/lib/ruby_lsp/requests/folding_ranges.rb +83 -77
  31. data/lib/ruby_lsp/requests/hover.rb +22 -17
  32. data/lib/ruby_lsp/requests/inlay_hints.rb +6 -6
  33. data/lib/ruby_lsp/requests/selection_ranges.rb +13 -105
  34. data/lib/ruby_lsp/requests/semantic_highlighting.rb +92 -92
  35. data/lib/ruby_lsp/requests/support/annotation.rb +3 -3
  36. data/lib/ruby_lsp/requests/support/common.rb +5 -5
  37. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +12 -0
  38. data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +10 -7
  39. data/lib/ruby_lsp/requests/support/sorbet.rb +28 -28
  40. data/lib/ruby_lsp/requests/workspace_symbol.rb +4 -4
  41. data/lib/ruby_lsp/requests.rb +0 -1
  42. data/lib/ruby_lsp/setup_bundler.rb +8 -5
  43. metadata +19 -17
  44. data/lib/ruby_lsp/event_emitter.rb +0 -351
  45. data/lib/ruby_lsp/requests/support/highlight_target.rb +0 -118
@@ -14,8 +14,8 @@ module RubyIndexer
14
14
  end
15
15
  RUBY
16
16
 
17
- assert_entry("FOO", Index::Entry::Constant, "/fake/path/foo.rb:0-0:0-7")
18
- assert_entry("Bar::FOO", Index::Entry::Constant, "/fake/path/foo.rb:3-2:3-9")
17
+ assert_entry("FOO", Entry::Constant, "/fake/path/foo.rb:0-0:0-7")
18
+ assert_entry("Bar::FOO", Entry::Constant, "/fake/path/foo.rb:3-2:3-9")
19
19
  end
20
20
 
21
21
  def test_constant_or_writes
@@ -27,8 +27,8 @@ module RubyIndexer
27
27
  end
28
28
  RUBY
29
29
 
30
- assert_entry("FOO", Index::Entry::Constant, "/fake/path/foo.rb:0-0:0-9")
31
- assert_entry("Bar::FOO", Index::Entry::Constant, "/fake/path/foo.rb:3-2:3-11")
30
+ assert_entry("FOO", Entry::Constant, "/fake/path/foo.rb:0-0:0-9")
31
+ assert_entry("Bar::FOO", Entry::Constant, "/fake/path/foo.rb:3-2:3-11")
32
32
  end
33
33
 
34
34
  def test_constant_path_writes
@@ -45,10 +45,10 @@ module RubyIndexer
45
45
  A::BAZ = 1
46
46
  RUBY
47
47
 
48
- assert_entry("A::FOO", Index::Entry::Constant, "/fake/path/foo.rb:1-2:1-9")
49
- assert_entry("BAR", Index::Entry::Constant, "/fake/path/foo.rb:2-2:2-11")
50
- assert_entry("A::B::FOO", Index::Entry::Constant, "/fake/path/foo.rb:5-4:5-11")
51
- assert_entry("A::BAZ", Index::Entry::Constant, "/fake/path/foo.rb:9-0:9-10")
48
+ assert_entry("A::FOO", Entry::Constant, "/fake/path/foo.rb:1-2:1-9")
49
+ assert_entry("BAR", Entry::Constant, "/fake/path/foo.rb:2-2:2-11")
50
+ assert_entry("A::B::FOO", Entry::Constant, "/fake/path/foo.rb:5-4:5-11")
51
+ assert_entry("A::BAZ", Entry::Constant, "/fake/path/foo.rb:9-0:9-10")
52
52
  end
53
53
 
54
54
  def test_constant_path_or_writes
@@ -61,9 +61,9 @@ module RubyIndexer
61
61
  A::BAZ ||= 1
62
62
  RUBY
63
63
 
64
- assert_entry("A::FOO", Index::Entry::Constant, "/fake/path/foo.rb:1-2:1-11")
65
- assert_entry("BAR", Index::Entry::Constant, "/fake/path/foo.rb:2-2:2-13")
66
- assert_entry("A::BAZ", Index::Entry::Constant, "/fake/path/foo.rb:5-0:5-12")
64
+ assert_entry("A::FOO", Entry::Constant, "/fake/path/foo.rb:1-2:1-11")
65
+ assert_entry("BAR", Entry::Constant, "/fake/path/foo.rb:2-2:2-13")
66
+ assert_entry("A::BAZ", Entry::Constant, "/fake/path/foo.rb:5-0:5-12")
67
67
  end
68
68
 
69
69
  def test_comments_for_constants
@@ -102,7 +102,7 @@ module RubyIndexer
102
102
  self.class::FOO = 1
103
103
  RUBY
104
104
 
105
- assert_no_entry
105
+ assert_no_entries
106
106
  end
107
107
 
108
108
  def test_private_constant_indexing
@@ -197,12 +197,12 @@ module RubyIndexer
197
197
  RUBY
198
198
 
199
199
  unresolve_entry = @index["A::FIRST"].first
200
- assert_instance_of(Index::Entry::UnresolvedAlias, unresolve_entry)
200
+ assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
201
201
  assert_equal(["A"], unresolve_entry.nesting)
202
202
  assert_equal("B::C", unresolve_entry.target)
203
203
 
204
204
  resolved_entry = @index.resolve("A::FIRST", []).first
205
- assert_instance_of(Index::Entry::Alias, resolved_entry)
205
+ assert_instance_of(Entry::Alias, resolved_entry)
206
206
  assert_equal("A::B::C", resolved_entry.target)
207
207
  end
208
208
 
@@ -223,25 +223,25 @@ module RubyIndexer
223
223
  RUBY
224
224
 
225
225
  unresolve_entry = @index["A::ALIAS"].first
226
- assert_instance_of(Index::Entry::UnresolvedAlias, unresolve_entry)
226
+ assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
227
227
  assert_equal(["A"], unresolve_entry.nesting)
228
228
  assert_equal("B", unresolve_entry.target)
229
229
 
230
230
  resolved_entry = @index.resolve("ALIAS", ["A"]).first
231
- assert_instance_of(Index::Entry::Alias, resolved_entry)
231
+ assert_instance_of(Entry::Alias, resolved_entry)
232
232
  assert_equal("A::B", resolved_entry.target)
233
233
 
234
234
  resolved_entry = @index.resolve("ALIAS::C", ["A"]).first
235
- assert_instance_of(Index::Entry::Module, resolved_entry)
235
+ assert_instance_of(Entry::Module, resolved_entry)
236
236
  assert_equal("A::B::C", resolved_entry.name)
237
237
 
238
238
  unresolve_entry = @index["Other::ONE_MORE"].first
239
- assert_instance_of(Index::Entry::UnresolvedAlias, unresolve_entry)
239
+ assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
240
240
  assert_equal(["Other"], unresolve_entry.nesting)
241
241
  assert_equal("A::ALIAS", unresolve_entry.target)
242
242
 
243
243
  resolved_entry = @index.resolve("Other::ONE_MORE::C", []).first
244
- assert_instance_of(Index::Entry::Module, resolved_entry)
244
+ assert_instance_of(Entry::Module, resolved_entry)
245
245
  end
246
246
 
247
247
  def test_indexing_same_line_constant_aliases
@@ -256,55 +256,55 @@ module RubyIndexer
256
256
 
257
257
  # B and C
258
258
  unresolve_entry = @index["A::B"].first
259
- assert_instance_of(Index::Entry::UnresolvedAlias, unresolve_entry)
259
+ assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
260
260
  assert_equal(["A"], unresolve_entry.nesting)
261
261
  assert_equal("C", unresolve_entry.target)
262
262
 
263
263
  resolved_entry = @index.resolve("A::B", []).first
264
- assert_instance_of(Index::Entry::Alias, resolved_entry)
264
+ assert_instance_of(Entry::Alias, resolved_entry)
265
265
  assert_equal("A::C", resolved_entry.target)
266
266
 
267
267
  constant = @index["A::C"].first
268
- assert_instance_of(Index::Entry::Constant, constant)
268
+ assert_instance_of(Entry::Constant, constant)
269
269
 
270
270
  # D and E
271
271
  unresolve_entry = @index["A::D"].first
272
- assert_instance_of(Index::Entry::UnresolvedAlias, unresolve_entry)
272
+ assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
273
273
  assert_equal(["A"], unresolve_entry.nesting)
274
274
  assert_equal("E", unresolve_entry.target)
275
275
 
276
276
  resolved_entry = @index.resolve("A::D", []).first
277
- assert_instance_of(Index::Entry::Alias, resolved_entry)
277
+ assert_instance_of(Entry::Alias, resolved_entry)
278
278
  assert_equal("A::E", resolved_entry.target)
279
279
 
280
280
  # F and G::H
281
281
  unresolve_entry = @index["A::F"].first
282
- assert_instance_of(Index::Entry::UnresolvedAlias, unresolve_entry)
282
+ assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
283
283
  assert_equal(["A"], unresolve_entry.nesting)
284
284
  assert_equal("G::H", unresolve_entry.target)
285
285
 
286
286
  resolved_entry = @index.resolve("A::F", []).first
287
- assert_instance_of(Index::Entry::Alias, resolved_entry)
287
+ assert_instance_of(Entry::Alias, resolved_entry)
288
288
  assert_equal("A::G::H", resolved_entry.target)
289
289
 
290
290
  # I::J, K::L and M
291
291
  unresolve_entry = @index["A::I::J"].first
292
- assert_instance_of(Index::Entry::UnresolvedAlias, unresolve_entry)
292
+ assert_instance_of(Entry::UnresolvedAlias, unresolve_entry)
293
293
  assert_equal(["A"], unresolve_entry.nesting)
294
294
  assert_equal("K::L", unresolve_entry.target)
295
295
 
296
296
  resolved_entry = @index.resolve("A::I::J", []).first
297
- assert_instance_of(Index::Entry::Alias, resolved_entry)
297
+ assert_instance_of(Entry::Alias, resolved_entry)
298
298
  assert_equal("A::K::L", resolved_entry.target)
299
299
 
300
300
  # When we are resolving A::I::J, we invoke `resolve("K::L", ["A"])`, which recursively resolves A::K::L too.
301
301
  # Therefore, both A::I::J and A::K::L point to A::M by the end of the previous resolve invocation
302
302
  resolved_entry = @index["A::K::L"].first
303
- assert_instance_of(Index::Entry::Alias, resolved_entry)
303
+ assert_instance_of(Entry::Alias, resolved_entry)
304
304
  assert_equal("A::M", resolved_entry.target)
305
305
 
306
306
  constant = @index["A::M"].first
307
- assert_instance_of(Index::Entry::Constant, constant)
307
+ assert_instance_of(Entry::Constant, constant)
308
308
  end
309
309
 
310
310
  def test_indexing_or_and_operator_nodes
@@ -317,12 +317,75 @@ module RubyIndexer
317
317
  H::I &= 6
318
318
  RUBY
319
319
 
320
- assert_entry("A", Index::Entry::Constant, "/fake/path/foo.rb:0-0:0-7")
321
- assert_entry("B", Index::Entry::Constant, "/fake/path/foo.rb:1-0:1-7")
322
- assert_entry("C", Index::Entry::Constant, "/fake/path/foo.rb:2-0:2-6")
323
- assert_entry("D::E", Index::Entry::Constant, "/fake/path/foo.rb:3-0:3-10")
324
- assert_entry("F::G", Index::Entry::Constant, "/fake/path/foo.rb:4-0:4-10")
325
- assert_entry("H::I", Index::Entry::Constant, "/fake/path/foo.rb:5-0:5-9")
320
+ assert_entry("A", Entry::Constant, "/fake/path/foo.rb:0-0:0-7")
321
+ assert_entry("B", Entry::Constant, "/fake/path/foo.rb:1-0:1-7")
322
+ assert_entry("C", Entry::Constant, "/fake/path/foo.rb:2-0:2-6")
323
+ assert_entry("D::E", Entry::Constant, "/fake/path/foo.rb:3-0:3-10")
324
+ assert_entry("F::G", Entry::Constant, "/fake/path/foo.rb:4-0:4-10")
325
+ assert_entry("H::I", Entry::Constant, "/fake/path/foo.rb:5-0:5-9")
326
+ end
327
+
328
+ def test_indexing_constant_targets
329
+ index(<<~RUBY)
330
+ module A
331
+ B, C = [1, Y]
332
+ D::E, F::G = [Z, 4]
333
+ H, I::J = [5, B]
334
+ K, L = C
335
+ end
336
+
337
+ module Real
338
+ Z = 1
339
+ Y = 2
340
+ end
341
+ RUBY
342
+
343
+ assert_entry("A::B", Entry::Constant, "/fake/path/foo.rb:1-2:1-3")
344
+ assert_entry("A::C", Entry::UnresolvedAlias, "/fake/path/foo.rb:1-5:1-6")
345
+ assert_entry("A::D::E", Entry::UnresolvedAlias, "/fake/path/foo.rb:2-2:2-6")
346
+ assert_entry("A::F::G", Entry::Constant, "/fake/path/foo.rb:2-8:2-12")
347
+ assert_entry("A::H", Entry::Constant, "/fake/path/foo.rb:3-2:3-3")
348
+ assert_entry("A::I::J", Entry::UnresolvedAlias, "/fake/path/foo.rb:3-5:3-9")
349
+ assert_entry("A::K", Entry::Constant, "/fake/path/foo.rb:4-2:4-3")
350
+ assert_entry("A::L", Entry::Constant, "/fake/path/foo.rb:4-5:4-6")
351
+ end
352
+
353
+ def test_indexing_constant_targets_with_splats
354
+ index(<<~RUBY)
355
+ A, *, B = baz
356
+ C, = bar
357
+ (D, E) = baz
358
+ F, G = *baz, qux
359
+ H, I = [baz, *qux]
360
+ J, L = [*something, String]
361
+ M = [String]
362
+ RUBY
363
+
364
+ assert_entry("A", Entry::Constant, "/fake/path/foo.rb:0-0:0-1")
365
+ assert_entry("B", Entry::Constant, "/fake/path/foo.rb:0-6:0-7")
366
+ assert_entry("D", Entry::Constant, "/fake/path/foo.rb:2-1:2-2")
367
+ assert_entry("E", Entry::Constant, "/fake/path/foo.rb:2-4:2-5")
368
+ assert_entry("F", Entry::Constant, "/fake/path/foo.rb:3-0:3-1")
369
+ assert_entry("G", Entry::Constant, "/fake/path/foo.rb:3-3:3-4")
370
+ assert_entry("H", Entry::Constant, "/fake/path/foo.rb:4-0:4-1")
371
+ assert_entry("I", Entry::Constant, "/fake/path/foo.rb:4-3:4-4")
372
+ assert_entry("J", Entry::Constant, "/fake/path/foo.rb:5-0:5-1")
373
+ assert_entry("L", Entry::Constant, "/fake/path/foo.rb:5-3:5-4")
374
+ assert_entry("M", Entry::Constant, "/fake/path/foo.rb:6-0:6-12")
375
+ end
376
+
377
+ def test_indexing_destructuring_an_array
378
+ index(<<~RUBY)
379
+ Baz = [1, 2]
380
+ Foo, Bar = Baz
381
+ This, That = foo, bar
382
+ RUBY
383
+
384
+ assert_entry("Baz", Entry::Constant, "/fake/path/foo.rb:0-0:0-12")
385
+ assert_entry("Foo", Entry::Constant, "/fake/path/foo.rb:1-0:1-3")
386
+ assert_entry("Bar", Entry::Constant, "/fake/path/foo.rb:1-5:1-8")
387
+ assert_entry("This", Entry::Constant, "/fake/path/foo.rb:2-0:2-4")
388
+ assert_entry("That", Entry::Constant, "/fake/path/foo.rb:2-6:2-10")
326
389
  end
327
390
  end
328
391
  end
@@ -191,7 +191,7 @@ module RubyIndexer
191
191
  entry = @index.resolve("INFINITY", ["Foo", "Float"]).first
192
192
  refute_nil(entry)
193
193
 
194
- assert_instance_of(Index::Entry::UnresolvedAlias, entry)
194
+ assert_instance_of(Entry::UnresolvedAlias, entry)
195
195
  end
196
196
  end
197
197
  end
@@ -0,0 +1,73 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "test_case"
5
+
6
+ module RubyIndexer
7
+ class MethodTest < TestCase
8
+ def test_method_with_no_parameters
9
+ index(<<~RUBY)
10
+ class Foo
11
+ def bar
12
+ end
13
+ end
14
+ RUBY
15
+
16
+ assert_entry("bar", Entry::InstanceMethod, "/fake/path/foo.rb:1-2:2-5")
17
+ end
18
+
19
+ def test_singleton_method_using_self_receiver
20
+ index(<<~RUBY)
21
+ class Foo
22
+ def self.bar
23
+ end
24
+ end
25
+ RUBY
26
+
27
+ assert_entry("bar", Entry::SingletonMethod, "/fake/path/foo.rb:1-2:2-5")
28
+ end
29
+
30
+ def test_singleton_method_using_other_receiver_is_not_indexed
31
+ index(<<~RUBY)
32
+ class Foo
33
+ def String.bar
34
+ end
35
+ end
36
+ RUBY
37
+
38
+ assert_no_entry("bar")
39
+ end
40
+
41
+ def test_method_with_parameters
42
+ index(<<~RUBY)
43
+ class Foo
44
+ def bar(a)
45
+ end
46
+ end
47
+ RUBY
48
+
49
+ assert_entry("bar", Entry::InstanceMethod, "/fake/path/foo.rb:1-2:2-5")
50
+ entry = T.must(@index["bar"].first)
51
+ assert_equal(1, entry.parameters.length)
52
+ parameter = entry.parameters.first
53
+ assert_equal(:a, parameter.name)
54
+ assert_instance_of(Entry::RequiredParameter, parameter)
55
+ end
56
+
57
+ def test_method_with_destructed_parameters
58
+ index(<<~RUBY)
59
+ class Foo
60
+ def bar((a, (b, )))
61
+ end
62
+ end
63
+ RUBY
64
+
65
+ assert_entry("bar", Entry::InstanceMethod, "/fake/path/foo.rb:1-2:2-5")
66
+ entry = T.must(@index["bar"].first)
67
+ assert_equal(1, entry.parameters.length)
68
+ parameter = entry.parameters.first
69
+ assert_equal(:"(a, (b, ))", parameter.name)
70
+ assert_instance_of(Entry::RequiredParameter, parameter)
71
+ end
72
+ end
73
+ end
@@ -35,8 +35,12 @@ module RubyIndexer
35
35
  assert_nil(entries, "Expected #{expected_name} to not be indexed")
36
36
  end
37
37
 
38
- def assert_no_entry
38
+ def assert_no_entries
39
39
  assert_empty(@index.instance_variable_get(:@entries), "Expected nothing to be indexed")
40
40
  end
41
+
42
+ def assert_no_entry(entry)
43
+ refute(@index.instance_variable_get(:@entries).key?(entry), "Expected '#{entry}' to not be indexed")
44
+ end
41
45
  end
42
46
  end
@@ -110,31 +110,31 @@ module RubyLsp
110
110
  sig do
111
111
  overridable.params(
112
112
  uri: URI::Generic,
113
- emitter: EventEmitter,
113
+ dispatcher: Prism::Dispatcher,
114
114
  message_queue: Thread::Queue,
115
115
  ).returns(T.nilable(Listener[T::Array[Interface::CodeLens]]))
116
116
  end
117
- def create_code_lens_listener(uri, emitter, message_queue); end
117
+ def create_code_lens_listener(uri, dispatcher, message_queue); end
118
118
 
119
119
  # Creates a new Hover listener. This method is invoked on every Hover request
120
120
  sig do
121
121
  overridable.params(
122
122
  nesting: T::Array[String],
123
123
  index: RubyIndexer::Index,
124
- emitter: EventEmitter,
124
+ dispatcher: Prism::Dispatcher,
125
125
  message_queue: Thread::Queue,
126
126
  ).returns(T.nilable(Listener[T.nilable(Interface::Hover)]))
127
127
  end
128
- def create_hover_listener(nesting, index, emitter, message_queue); end
128
+ def create_hover_listener(nesting, index, dispatcher, message_queue); end
129
129
 
130
130
  # Creates a new DocumentSymbol listener. This method is invoked on every DocumentSymbol request
131
131
  sig do
132
132
  overridable.params(
133
- emitter: EventEmitter,
133
+ dispatcher: Prism::Dispatcher,
134
134
  message_queue: Thread::Queue,
135
135
  ).returns(T.nilable(Listener[T::Array[Interface::DocumentSymbol]]))
136
136
  end
137
- def create_document_symbol_listener(emitter, message_queue); end
137
+ def create_document_symbol_listener(dispatcher, message_queue); end
138
138
 
139
139
  # Creates a new Definition listener. This method is invoked on every Definition request
140
140
  sig do
@@ -142,10 +142,10 @@ module RubyLsp
142
142
  uri: URI::Generic,
143
143
  nesting: T::Array[String],
144
144
  index: RubyIndexer::Index,
145
- emitter: EventEmitter,
145
+ dispatcher: Prism::Dispatcher,
146
146
  message_queue: Thread::Queue,
147
147
  ).returns(T.nilable(Listener[T.nilable(T.any(T::Array[Interface::Location], Interface::Location))]))
148
148
  end
149
- def create_definition_listener(uri, nesting, index, emitter, message_queue); end
149
+ def create_definition_listener(uri, nesting, index, dispatcher, message_queue); end
150
150
  end
151
151
  end
@@ -9,7 +9,7 @@ module RubyLsp
9
9
  RangeShape = T.type_alias { { start: PositionShape, end: PositionShape } }
10
10
  EditShape = T.type_alias { { range: RangeShape, text: String } }
11
11
 
12
- sig { returns(YARP::ParseResult) }
12
+ sig { returns(Prism::ParseResult) }
13
13
  attr_reader :parse_result
14
14
 
15
15
  sig { returns(String) }
@@ -29,15 +29,15 @@ module RubyLsp
29
29
  @version = T.let(version, Integer)
30
30
  @uri = T.let(uri, URI::Generic)
31
31
  @needs_parsing = T.let(false, T::Boolean)
32
- @parse_result = T.let(YARP.parse(@source), YARP::ParseResult)
32
+ @parse_result = T.let(Prism.parse(@source), Prism::ParseResult)
33
33
  end
34
34
 
35
- sig { returns(YARP::ProgramNode) }
35
+ sig { returns(Prism::ProgramNode) }
36
36
  def tree
37
37
  @parse_result.value
38
38
  end
39
39
 
40
- sig { returns(T::Array[YARP::Comment]) }
40
+ sig { returns(T::Array[Prism::Comment]) }
41
41
  def comments
42
42
  @parse_result.comments
43
43
  end
@@ -96,7 +96,7 @@ module RubyLsp
96
96
  return unless @needs_parsing
97
97
 
98
98
  @needs_parsing = false
99
- @parse_result = YARP.parse(@source)
99
+ @parse_result = Prism.parse(@source)
100
100
  end
101
101
 
102
102
  sig { returns(T::Boolean) }
@@ -112,8 +112,8 @@ module RubyLsp
112
112
  sig do
113
113
  params(
114
114
  position: PositionShape,
115
- node_types: T::Array[T.class_of(YARP::Node)],
116
- ).returns([T.nilable(YARP::Node), T.nilable(YARP::Node), T::Array[String]])
115
+ node_types: T::Array[T.class_of(Prism::Node)],
116
+ ).returns([T.nilable(Prism::Node), T.nilable(Prism::Node), T::Array[String]])
117
117
  end
118
118
  def locate_node(position, node_types: [])
119
119
  locate(@parse_result.value, create_scanner.find_char_position(position), node_types: node_types)
@@ -121,16 +121,16 @@ module RubyLsp
121
121
 
122
122
  sig do
123
123
  params(
124
- node: YARP::Node,
124
+ node: Prism::Node,
125
125
  char_position: Integer,
126
- node_types: T::Array[T.class_of(YARP::Node)],
127
- ).returns([T.nilable(YARP::Node), T.nilable(YARP::Node), T::Array[String]])
126
+ node_types: T::Array[T.class_of(Prism::Node)],
127
+ ).returns([T.nilable(Prism::Node), T.nilable(Prism::Node), T::Array[String]])
128
128
  end
129
129
  def locate(node, char_position, node_types: [])
130
- queue = T.let(node.child_nodes.compact, T::Array[T.nilable(YARP::Node)])
130
+ queue = T.let(node.child_nodes.compact, T::Array[T.nilable(Prism::Node)])
131
131
  closest = node
132
- parent = T.let(nil, T.nilable(YARP::Node))
133
- nesting = T.let([], T::Array[T.any(YARP::ClassNode, YARP::ModuleNode)])
132
+ parent = T.let(nil, T.nilable(Prism::Node))
133
+ nesting = T.let([], T::Array[T.any(Prism::ClassNode, Prism::ModuleNode)])
134
134
 
135
135
  until queue.empty?
136
136
  candidate = queue.shift
@@ -158,7 +158,7 @@ module RubyLsp
158
158
 
159
159
  # Keep track of the nesting where we found the target. This is used to determine the fully qualified name of the
160
160
  # target when it is a constant
161
- if candidate.is_a?(YARP::ClassNode) || candidate.is_a?(YARP::ModuleNode)
161
+ if candidate.is_a?(Prism::ClassNode) || candidate.is_a?(Prism::ModuleNode)
162
162
  nesting << candidate
163
163
  end
164
164