ruby-lsp 0.11.2 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/exe/ruby-lsp +11 -2
  4. data/exe/ruby-lsp-check +2 -1
  5. data/exe/ruby-lsp-doctor +15 -0
  6. data/lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb +125 -0
  7. data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +10 -2
  8. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +205 -0
  9. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +23 -106
  10. data/lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb +1 -1
  11. data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +6 -6
  12. data/lib/ruby_indexer/lib/ruby_indexer/visitor.rb +101 -49
  13. data/lib/ruby_indexer/ruby_indexer.rb +4 -3
  14. data/lib/ruby_indexer/test/classes_and_modules_test.rb +49 -16
  15. data/lib/ruby_indexer/test/constant_test.rb +99 -36
  16. data/lib/ruby_indexer/test/index_test.rb +1 -1
  17. data/lib/ruby_indexer/test/method_test.rb +73 -0
  18. data/lib/ruby_indexer/test/test_case.rb +5 -1
  19. data/lib/ruby_lsp/addon.rb +8 -8
  20. data/lib/ruby_lsp/document.rb +14 -14
  21. data/lib/ruby_lsp/executor.rb +89 -53
  22. data/lib/ruby_lsp/internal.rb +7 -2
  23. data/lib/ruby_lsp/listener.rb +6 -6
  24. data/lib/ruby_lsp/requests/base_request.rb +1 -9
  25. data/lib/ruby_lsp/requests/code_action_resolve.rb +3 -3
  26. data/lib/ruby_lsp/requests/code_lens.rb +47 -31
  27. data/lib/ruby_lsp/requests/completion.rb +83 -32
  28. data/lib/ruby_lsp/requests/definition.rb +21 -15
  29. data/lib/ruby_lsp/requests/diagnostics.rb +1 -1
  30. data/lib/ruby_lsp/requests/document_highlight.rb +508 -31
  31. data/lib/ruby_lsp/requests/document_link.rb +24 -17
  32. data/lib/ruby_lsp/requests/document_symbol.rb +42 -42
  33. data/lib/ruby_lsp/requests/folding_ranges.rb +83 -77
  34. data/lib/ruby_lsp/requests/hover.rb +22 -17
  35. data/lib/ruby_lsp/requests/inlay_hints.rb +6 -6
  36. data/lib/ruby_lsp/requests/selection_ranges.rb +13 -105
  37. data/lib/ruby_lsp/requests/semantic_highlighting.rb +92 -92
  38. data/lib/ruby_lsp/requests/support/annotation.rb +3 -3
  39. data/lib/ruby_lsp/requests/support/common.rb +5 -5
  40. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +21 -7
  41. data/lib/ruby_lsp/requests/support/rubocop_runner.rb +19 -0
  42. data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +10 -7
  43. data/lib/ruby_lsp/requests/support/sorbet.rb +28 -28
  44. data/lib/ruby_lsp/requests/workspace_symbol.rb +4 -4
  45. data/lib/ruby_lsp/requests.rb +0 -1
  46. data/lib/ruby_lsp/setup_bundler.rb +26 -17
  47. metadata +20 -17
  48. data/lib/ruby_lsp/event_emitter.rb +0 -351
  49. data/lib/ruby_lsp/requests/support/highlight_target.rb +0 -118
@@ -32,7 +32,7 @@ module RubyLsp
32
32
 
33
33
  ResponseType = type_member { { fixed: T::Array[Interface::DocumentSymbol] } }
34
34
 
35
- ATTR_ACCESSORS = T.let(["attr_reader", "attr_writer", "attr_accessor"].freeze, T::Array[String])
35
+ ATTR_ACCESSORS = T.let([:attr_reader, :attr_writer, :attr_accessor].freeze, T::Array[Symbol])
36
36
 
37
37
  class SymbolHierarchyRoot
38
38
  extend T::Sig
@@ -49,8 +49,8 @@ module RubyLsp
49
49
  sig { override.returns(T::Array[Interface::DocumentSymbol]) }
50
50
  attr_reader :_response
51
51
 
52
- sig { params(emitter: EventEmitter, message_queue: Thread::Queue).void }
53
- def initialize(emitter, message_queue)
52
+ sig { params(dispatcher: Prism::Dispatcher, message_queue: Thread::Queue).void }
53
+ def initialize(dispatcher, message_queue)
54
54
  @root = T.let(SymbolHierarchyRoot.new, SymbolHierarchyRoot)
55
55
  @_response = T.let(@root.children, T::Array[Interface::DocumentSymbol])
56
56
  @stack = T.let(
@@ -60,25 +60,25 @@ module RubyLsp
60
60
 
61
61
  super
62
62
 
63
- emitter.register(
63
+ dispatcher.register(
64
64
  self,
65
- :on_class,
66
- :after_class,
67
- :on_call,
68
- :on_constant_path_write,
69
- :on_constant_write,
70
- :on_def,
71
- :after_def,
72
- :on_module,
73
- :after_module,
74
- :on_instance_variable_write,
75
- :on_class_variable_write,
65
+ :on_class_node_enter,
66
+ :on_class_node_leave,
67
+ :on_call_node_enter,
68
+ :on_constant_path_write_node_enter,
69
+ :on_constant_write_node_enter,
70
+ :on_def_node_enter,
71
+ :on_def_node_leave,
72
+ :on_module_node_enter,
73
+ :on_module_node_leave,
74
+ :on_instance_variable_write_node_enter,
75
+ :on_class_variable_write_node_enter,
76
76
  )
77
77
  end
78
78
 
79
79
  sig { override.params(addon: Addon).returns(T.nilable(Listener[ResponseType])) }
80
80
  def initialize_external_listener(addon)
81
- addon.create_document_symbol_listener(@emitter, @message_queue)
81
+ addon.create_document_symbol_listener(@dispatcher, @message_queue)
82
82
  end
83
83
 
84
84
  # Merges responses from other listeners
@@ -88,8 +88,8 @@ module RubyLsp
88
88
  self
89
89
  end
90
90
 
91
- sig { params(node: YARP::ClassNode).void }
92
- def on_class(node)
91
+ sig { params(node: Prism::ClassNode).void }
92
+ def on_class_node_enter(node)
93
93
  @stack << create_document_symbol(
94
94
  name: node.constant_path.location.slice,
95
95
  kind: Constant::SymbolKind::CLASS,
@@ -98,20 +98,20 @@ module RubyLsp
98
98
  )
99
99
  end
100
100
 
101
- sig { params(node: YARP::ClassNode).void }
102
- def after_class(node)
101
+ sig { params(node: Prism::ClassNode).void }
102
+ def on_class_node_leave(node)
103
103
  @stack.pop
104
104
  end
105
105
 
106
- sig { params(node: YARP::CallNode).void }
107
- def on_call(node)
106
+ sig { params(node: Prism::CallNode).void }
107
+ def on_call_node_enter(node)
108
108
  return unless ATTR_ACCESSORS.include?(node.name) && node.receiver.nil?
109
109
 
110
110
  arguments = node.arguments
111
111
  return unless arguments
112
112
 
113
113
  arguments.arguments.each do |argument|
114
- next unless argument.is_a?(YARP::SymbolNode)
114
+ next unless argument.is_a?(Prism::SymbolNode)
115
115
 
116
116
  name = argument.value
117
117
  next unless name
@@ -125,8 +125,8 @@ module RubyLsp
125
125
  end
126
126
  end
127
127
 
128
- sig { params(node: YARP::ConstantPathWriteNode).void }
129
- def on_constant_path_write(node)
128
+ sig { params(node: Prism::ConstantPathWriteNode).void }
129
+ def on_constant_path_write_node_enter(node)
130
130
  create_document_symbol(
131
131
  name: node.target.location.slice,
132
132
  kind: Constant::SymbolKind::CONSTANT,
@@ -135,8 +135,8 @@ module RubyLsp
135
135
  )
136
136
  end
137
137
 
138
- sig { params(node: YARP::ConstantWriteNode).void }
139
- def on_constant_write(node)
138
+ sig { params(node: Prism::ConstantWriteNode).void }
139
+ def on_constant_write_node_enter(node)
140
140
  create_document_symbol(
141
141
  name: node.name.to_s,
142
142
  kind: Constant::SymbolKind::CONSTANT,
@@ -145,13 +145,13 @@ module RubyLsp
145
145
  )
146
146
  end
147
147
 
148
- sig { params(node: YARP::DefNode).void }
149
- def after_def(node)
148
+ sig { params(node: Prism::DefNode).void }
149
+ def on_def_node_leave(node)
150
150
  @stack.pop
151
151
  end
152
152
 
153
- sig { params(node: YARP::ModuleNode).void }
154
- def on_module(node)
153
+ sig { params(node: Prism::ModuleNode).void }
154
+ def on_module_node_enter(node)
155
155
  @stack << create_document_symbol(
156
156
  name: node.constant_path.location.slice,
157
157
  kind: Constant::SymbolKind::MODULE,
@@ -160,11 +160,11 @@ module RubyLsp
160
160
  )
161
161
  end
162
162
 
163
- sig { params(node: YARP::DefNode).void }
164
- def on_def(node)
163
+ sig { params(node: Prism::DefNode).void }
164
+ def on_def_node_enter(node)
165
165
  receiver = node.receiver
166
166
 
167
- if receiver.is_a?(YARP::SelfNode)
167
+ if receiver.is_a?(Prism::SelfNode)
168
168
  name = "self.#{node.name}"
169
169
  kind = Constant::SymbolKind::METHOD
170
170
  else
@@ -182,13 +182,13 @@ module RubyLsp
182
182
  @stack << symbol
183
183
  end
184
184
 
185
- sig { params(node: YARP::ModuleNode).void }
186
- def after_module(node)
185
+ sig { params(node: Prism::ModuleNode).void }
186
+ def on_module_node_leave(node)
187
187
  @stack.pop
188
188
  end
189
189
 
190
- sig { params(node: YARP::InstanceVariableWriteNode).void }
191
- def on_instance_variable_write(node)
190
+ sig { params(node: Prism::InstanceVariableWriteNode).void }
191
+ def on_instance_variable_write_node_enter(node)
192
192
  create_document_symbol(
193
193
  name: node.name.to_s,
194
194
  kind: Constant::SymbolKind::VARIABLE,
@@ -197,8 +197,8 @@ module RubyLsp
197
197
  )
198
198
  end
199
199
 
200
- sig { params(node: YARP::ClassVariableWriteNode).void }
201
- def on_class_variable_write(node)
200
+ sig { params(node: Prism::ClassVariableWriteNode).void }
201
+ def on_class_variable_write_node_enter(node)
202
202
  create_document_symbol(
203
203
  name: node.name.to_s,
204
204
  kind: Constant::SymbolKind::VARIABLE,
@@ -213,8 +213,8 @@ module RubyLsp
213
213
  params(
214
214
  name: String,
215
215
  kind: Integer,
216
- range_location: YARP::Location,
217
- selection_range_location: YARP::Location,
216
+ range_location: Prism::Location,
217
+ selection_range_location: Prism::Location,
218
218
  ).returns(Interface::DocumentSymbol)
219
219
  end
220
220
  def create_document_symbol(name:, kind:, range_location:, selection_range_location:)
@@ -21,39 +21,40 @@ module RubyLsp
21
21
 
22
22
  ResponseType = type_member { { fixed: T::Array[Interface::FoldingRange] } }
23
23
 
24
- sig { params(comments: T::Array[YARP::Comment], emitter: EventEmitter, queue: Thread::Queue).void }
25
- def initialize(comments, emitter, queue)
26
- super(emitter, queue)
24
+ sig { params(comments: T::Array[Prism::Comment], dispatcher: Prism::Dispatcher, queue: Thread::Queue).void }
25
+ def initialize(comments, dispatcher, queue)
26
+ super(dispatcher, queue)
27
27
 
28
28
  @_response = T.let([], ResponseType)
29
- @requires = T.let([], T::Array[YARP::CallNode])
29
+ @requires = T.let([], T::Array[Prism::CallNode])
30
30
  @finalized_response = T.let(false, T::Boolean)
31
31
  @comments = comments
32
32
 
33
- emitter.register(
33
+ dispatcher.register(
34
34
  self,
35
- :on_if,
36
- :on_in,
37
- :on_rescue,
38
- :on_when,
39
- :on_interpolated_string,
40
- :on_array,
41
- :on_block,
42
- :on_case,
43
- :on_class,
44
- :on_module,
45
- :on_for,
46
- :on_hash,
47
- :on_singleton_class,
48
- :on_unless,
49
- :on_until,
50
- :on_while,
51
- :on_else,
52
- :on_ensure,
53
- :on_begin,
54
- :on_string_concat,
55
- :on_def,
56
- :on_call,
35
+ :on_if_node_enter,
36
+ :on_in_node_enter,
37
+ :on_rescue_node_enter,
38
+ :on_when_node_enter,
39
+ :on_interpolated_string_node_enter,
40
+ :on_array_node_enter,
41
+ :on_block_node_enter,
42
+ :on_case_node_enter,
43
+ :on_class_node_enter,
44
+ :on_module_node_enter,
45
+ :on_for_node_enter,
46
+ :on_hash_node_enter,
47
+ :on_singleton_class_node_enter,
48
+ :on_unless_node_enter,
49
+ :on_until_node_enter,
50
+ :on_while_node_enter,
51
+ :on_else_node_enter,
52
+ :on_ensure_node_enter,
53
+ :on_begin_node_enter,
54
+ :on_string_concat_node_enter,
55
+ :on_def_node_enter,
56
+ :on_call_node_enter,
57
+ :on_lambda_node_enter,
57
58
  )
58
59
  end
59
60
 
@@ -68,114 +69,114 @@ module RubyLsp
68
69
  @_response
69
70
  end
70
71
 
71
- sig { params(node: YARP::IfNode).void }
72
- def on_if(node)
72
+ sig { params(node: Prism::IfNode).void }
73
+ def on_if_node_enter(node)
73
74
  add_statements_range(node)
74
75
  end
75
76
 
76
- sig { params(node: YARP::InNode).void }
77
- def on_in(node)
77
+ sig { params(node: Prism::InNode).void }
78
+ def on_in_node_enter(node)
78
79
  add_statements_range(node)
79
80
  end
80
81
 
81
- sig { params(node: YARP::RescueNode).void }
82
- def on_rescue(node)
82
+ sig { params(node: Prism::RescueNode).void }
83
+ def on_rescue_node_enter(node)
83
84
  add_statements_range(node)
84
85
  end
85
86
 
86
- sig { params(node: YARP::WhenNode).void }
87
- def on_when(node)
87
+ sig { params(node: Prism::WhenNode).void }
88
+ def on_when_node_enter(node)
88
89
  add_statements_range(node)
89
90
  end
90
91
 
91
- sig { params(node: YARP::InterpolatedStringNode).void }
92
- def on_interpolated_string(node)
92
+ sig { params(node: Prism::InterpolatedStringNode).void }
93
+ def on_interpolated_string_node_enter(node)
93
94
  opening_loc = node.opening_loc
94
95
  closing_loc = node.closing_loc
95
96
 
96
97
  add_lines_range(opening_loc.start_line, closing_loc.end_line - 1) if opening_loc && closing_loc
97
98
  end
98
99
 
99
- sig { params(node: YARP::ArrayNode).void }
100
- def on_array(node)
100
+ sig { params(node: Prism::ArrayNode).void }
101
+ def on_array_node_enter(node)
101
102
  add_simple_range(node)
102
103
  end
103
104
 
104
- sig { params(node: YARP::BlockNode).void }
105
- def on_block(node)
105
+ sig { params(node: Prism::BlockNode).void }
106
+ def on_block_node_enter(node)
106
107
  add_simple_range(node)
107
108
  end
108
109
 
109
- sig { params(node: YARP::CaseNode).void }
110
- def on_case(node)
110
+ sig { params(node: Prism::CaseNode).void }
111
+ def on_case_node_enter(node)
111
112
  add_simple_range(node)
112
113
  end
113
114
 
114
- sig { params(node: YARP::ClassNode).void }
115
- def on_class(node)
115
+ sig { params(node: Prism::ClassNode).void }
116
+ def on_class_node_enter(node)
116
117
  add_simple_range(node)
117
118
  end
118
119
 
119
- sig { params(node: YARP::ModuleNode).void }
120
- def on_module(node)
120
+ sig { params(node: Prism::ModuleNode).void }
121
+ def on_module_node_enter(node)
121
122
  add_simple_range(node)
122
123
  end
123
124
 
124
- sig { params(node: YARP::ForNode).void }
125
- def on_for(node)
125
+ sig { params(node: Prism::ForNode).void }
126
+ def on_for_node_enter(node)
126
127
  add_simple_range(node)
127
128
  end
128
129
 
129
- sig { params(node: YARP::HashNode).void }
130
- def on_hash(node)
130
+ sig { params(node: Prism::HashNode).void }
131
+ def on_hash_node_enter(node)
131
132
  add_simple_range(node)
132
133
  end
133
134
 
134
- sig { params(node: YARP::SingletonClassNode).void }
135
- def on_singleton_class(node)
135
+ sig { params(node: Prism::SingletonClassNode).void }
136
+ def on_singleton_class_node_enter(node)
136
137
  add_simple_range(node)
137
138
  end
138
139
 
139
- sig { params(node: YARP::UnlessNode).void }
140
- def on_unless(node)
140
+ sig { params(node: Prism::UnlessNode).void }
141
+ def on_unless_node_enter(node)
141
142
  add_simple_range(node)
142
143
  end
143
144
 
144
- sig { params(node: YARP::UntilNode).void }
145
- def on_until(node)
145
+ sig { params(node: Prism::UntilNode).void }
146
+ def on_until_node_enter(node)
146
147
  add_simple_range(node)
147
148
  end
148
149
 
149
- sig { params(node: YARP::WhileNode).void }
150
- def on_while(node)
150
+ sig { params(node: Prism::WhileNode).void }
151
+ def on_while_node_enter(node)
151
152
  add_simple_range(node)
152
153
  end
153
154
 
154
- sig { params(node: YARP::ElseNode).void }
155
- def on_else(node)
155
+ sig { params(node: Prism::ElseNode).void }
156
+ def on_else_node_enter(node)
156
157
  add_simple_range(node)
157
158
  end
158
159
 
159
- sig { params(node: YARP::EnsureNode).void }
160
- def on_ensure(node)
160
+ sig { params(node: Prism::EnsureNode).void }
161
+ def on_ensure_node_enter(node)
161
162
  add_simple_range(node)
162
163
  end
163
164
 
164
- sig { params(node: YARP::BeginNode).void }
165
- def on_begin(node)
165
+ sig { params(node: Prism::BeginNode).void }
166
+ def on_begin_node_enter(node)
166
167
  add_simple_range(node)
167
168
  end
168
169
 
169
- sig { params(node: YARP::StringConcatNode).void }
170
- def on_string_concat(node)
171
- left = T.let(node.left, YARP::Node)
172
- left = left.left while left.is_a?(YARP::StringConcatNode)
170
+ sig { params(node: Prism::StringConcatNode).void }
171
+ def on_string_concat_node_enter(node)
172
+ left = T.let(node.left, Prism::Node)
173
+ left = left.left while left.is_a?(Prism::StringConcatNode)
173
174
 
174
175
  add_lines_range(left.location.start_line, node.right.location.end_line - 1)
175
176
  end
176
177
 
177
- sig { params(node: YARP::DefNode).void }
178
- def on_def(node)
178
+ sig { params(node: Prism::DefNode).void }
179
+ def on_def_node_enter(node)
179
180
  params = node.parameters
180
181
  parameter_loc = params&.location
181
182
  location = node.location
@@ -189,8 +190,8 @@ module RubyLsp
189
190
  end
190
191
  end
191
192
 
192
- sig { params(node: YARP::CallNode).void }
193
- def on_call(node)
193
+ sig { params(node: Prism::CallNode).void }
194
+ def on_call_node_enter(node)
194
195
  # If we find a require, don't visit the child nodes (prevent `super`), so that we can keep accumulating into
195
196
  # the `@requires` array and then push the range whenever we find a node that isn't a CallNode
196
197
  if require?(node)
@@ -202,6 +203,11 @@ module RubyLsp
202
203
  add_lines_range(location.start_line, location.end_line - 1)
203
204
  end
204
205
 
206
+ sig { params(node: Prism::LambdaNode).void }
207
+ def on_lambda_node_enter(node)
208
+ add_simple_range(node)
209
+ end
210
+
205
211
  private
206
212
 
207
213
  sig { void }
@@ -233,7 +239,7 @@ module RubyLsp
233
239
  @requires.clear
234
240
  end
235
241
 
236
- sig { params(node: YARP::CallNode).returns(T::Boolean) }
242
+ sig { params(node: Prism::CallNode).returns(T::Boolean) }
237
243
  def require?(node)
238
244
  message = node.message
239
245
  return false unless message == "require" || message == "require_relative"
@@ -244,10 +250,10 @@ module RubyLsp
244
250
  arguments = node.arguments&.arguments
245
251
  return false unless arguments
246
252
 
247
- arguments.length == 1 && arguments.first.is_a?(YARP::StringNode)
253
+ arguments.length == 1 && arguments.first.is_a?(Prism::StringNode)
248
254
  end
249
255
 
250
- sig { params(node: T.any(YARP::IfNode, YARP::InNode, YARP::RescueNode, YARP::WhenNode)).void }
256
+ sig { params(node: T.any(Prism::IfNode, Prism::InNode, Prism::RescueNode, Prism::WhenNode)).void }
251
257
  def add_statements_range(node)
252
258
  statements = node.statements
253
259
  return unless statements
@@ -258,7 +264,7 @@ module RubyLsp
258
264
  add_lines_range(node.location.start_line, T.must(body.last).location.end_line)
259
265
  end
260
266
 
261
- sig { params(node: YARP::Node).void }
267
+ sig { params(node: Prism::Node).void }
262
268
  def add_simple_range(node)
263
269
  location = node.location
264
270
  add_lines_range(location.start_line, location.end_line - 1)
@@ -21,12 +21,12 @@ module RubyLsp
21
21
 
22
22
  ALLOWED_TARGETS = T.let(
23
23
  [
24
- YARP::CallNode,
25
- YARP::ConstantReadNode,
26
- YARP::ConstantWriteNode,
27
- YARP::ConstantPathNode,
24
+ Prism::CallNode,
25
+ Prism::ConstantReadNode,
26
+ Prism::ConstantWriteNode,
27
+ Prism::ConstantPathNode,
28
28
  ],
29
- T::Array[T.class_of(YARP::Node)],
29
+ T::Array[T.class_of(Prism::Node)],
30
30
  )
31
31
 
32
32
  sig { override.returns(ResponseType) }
@@ -36,22 +36,27 @@ module RubyLsp
36
36
  params(
37
37
  index: RubyIndexer::Index,
38
38
  nesting: T::Array[String],
39
- emitter: EventEmitter,
39
+ dispatcher: Prism::Dispatcher,
40
40
  message_queue: Thread::Queue,
41
41
  ).void
42
42
  end
43
- def initialize(index, nesting, emitter, message_queue)
43
+ def initialize(index, nesting, dispatcher, message_queue)
44
44
  @index = index
45
45
  @nesting = nesting
46
46
  @_response = T.let(nil, ResponseType)
47
47
 
48
- super(emitter, message_queue)
49
- emitter.register(self, :on_constant_read, :on_constant_write, :on_constant_path)
48
+ super(dispatcher, message_queue)
49
+ dispatcher.register(
50
+ self,
51
+ :on_constant_read_node_enter,
52
+ :on_constant_write_node_enter,
53
+ :on_constant_path_node_enter,
54
+ )
50
55
  end
51
56
 
52
57
  sig { override.params(addon: Addon).returns(T.nilable(Listener[ResponseType])) }
53
58
  def initialize_external_listener(addon)
54
- addon.create_hover_listener(@nesting, @index, @emitter, @message_queue)
59
+ addon.create_hover_listener(@nesting, @index, @dispatcher, @message_queue)
55
60
  end
56
61
 
57
62
  # Merges responses from other hover listeners
@@ -69,22 +74,22 @@ module RubyLsp
69
74
  self
70
75
  end
71
76
 
72
- sig { params(node: YARP::ConstantReadNode).void }
73
- def on_constant_read(node)
77
+ sig { params(node: Prism::ConstantReadNode).void }
78
+ def on_constant_read_node_enter(node)
74
79
  return if DependencyDetector.instance.typechecker
75
80
 
76
81
  generate_hover(node.slice, node.location)
77
82
  end
78
83
 
79
- sig { params(node: YARP::ConstantWriteNode).void }
80
- def on_constant_write(node)
84
+ sig { params(node: Prism::ConstantWriteNode).void }
85
+ def on_constant_write_node_enter(node)
81
86
  return if DependencyDetector.instance.typechecker
82
87
 
83
88
  generate_hover(node.name.to_s, node.name_loc)
84
89
  end
85
90
 
86
- sig { params(node: YARP::ConstantPathNode).void }
87
- def on_constant_path(node)
91
+ sig { params(node: Prism::ConstantPathNode).void }
92
+ def on_constant_path_node_enter(node)
88
93
  return if DependencyDetector.instance.typechecker
89
94
 
90
95
  generate_hover(node.slice, node.location)
@@ -92,7 +97,7 @@ module RubyLsp
92
97
 
93
98
  private
94
99
 
95
- sig { params(name: String, location: YARP::Location).void }
100
+ sig { params(name: String, location: Prism::Location).void }
96
101
  def generate_hover(name, location)
97
102
  entries = @index.resolve(name, @nesting)
98
103
  return unless entries
@@ -29,18 +29,18 @@ module RubyLsp
29
29
  sig { override.returns(ResponseType) }
30
30
  attr_reader :_response
31
31
 
32
- sig { params(range: T::Range[Integer], emitter: EventEmitter, message_queue: Thread::Queue).void }
33
- def initialize(range, emitter, message_queue)
34
- super(emitter, message_queue)
32
+ sig { params(range: T::Range[Integer], dispatcher: Prism::Dispatcher, message_queue: Thread::Queue).void }
33
+ def initialize(range, dispatcher, message_queue)
34
+ super(dispatcher, message_queue)
35
35
 
36
36
  @_response = T.let([], ResponseType)
37
37
  @range = range
38
38
 
39
- emitter.register(self, :on_rescue)
39
+ dispatcher.register(self, :on_rescue_node_enter)
40
40
  end
41
41
 
42
- sig { params(node: YARP::RescueNode).void }
43
- def on_rescue(node)
42
+ sig { params(node: Prism::RescueNode).void }
43
+ def on_rescue_node_enter(node)
44
44
  return unless node.exceptions.empty?
45
45
 
46
46
  loc = node.location