ruby-lsp 0.23.11 → 0.23.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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -1
- data/exe/ruby-lsp-launcher +12 -11
- data/lib/rubocop/cop/ruby_lsp/use_language_server_aliases.rb +1 -1
- data/lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb +3 -5
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +81 -115
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +117 -166
- data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +9 -7
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +88 -200
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +56 -192
- data/lib/ruby_indexer/lib/ruby_indexer/location.rb +4 -27
- data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +14 -16
- data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +22 -45
- data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +42 -60
- data/lib/ruby_indexer/lib/ruby_indexer/uri.rb +9 -16
- data/lib/ruby_indexer/lib/ruby_indexer/visibility_scope.rb +5 -9
- data/lib/ruby_indexer/test/configuration_test.rb +42 -3
- data/lib/ruby_indexer/test/method_test.rb +28 -2
- data/lib/ruby_indexer/test/rbs_indexer_test.rb +1 -1
- data/lib/ruby_lsp/addon.rb +44 -71
- data/lib/ruby_lsp/base_server.rb +29 -32
- data/lib/ruby_lsp/client_capabilities.rb +10 -12
- data/lib/ruby_lsp/document.rb +34 -45
- data/lib/ruby_lsp/erb_document.rb +24 -36
- data/lib/ruby_lsp/global_state.rb +51 -56
- data/lib/ruby_lsp/internal.rb +2 -0
- data/lib/ruby_lsp/listeners/code_lens.rb +81 -88
- data/lib/ruby_lsp/listeners/completion.rb +36 -55
- data/lib/ruby_lsp/listeners/definition.rb +37 -51
- data/lib/ruby_lsp/listeners/document_highlight.rb +123 -150
- data/lib/ruby_lsp/listeners/document_link.rb +43 -62
- data/lib/ruby_lsp/listeners/document_symbol.rb +35 -49
- data/lib/ruby_lsp/listeners/folding_ranges.rb +32 -39
- data/lib/ruby_lsp/listeners/hover.rb +81 -100
- data/lib/ruby_lsp/listeners/inlay_hints.rb +4 -11
- data/lib/ruby_lsp/listeners/semantic_highlighting.rb +42 -51
- data/lib/ruby_lsp/listeners/signature_help.rb +6 -25
- data/lib/ruby_lsp/listeners/spec_style.rb +155 -0
- data/lib/ruby_lsp/listeners/test_discovery.rb +89 -0
- data/lib/ruby_lsp/listeners/test_style.rb +160 -88
- data/lib/ruby_lsp/node_context.rb +12 -39
- data/lib/ruby_lsp/rbs_document.rb +8 -6
- data/lib/ruby_lsp/requests/code_action_resolve.rb +10 -10
- data/lib/ruby_lsp/requests/code_actions.rb +14 -26
- data/lib/ruby_lsp/requests/code_lens.rb +6 -17
- data/lib/ruby_lsp/requests/completion.rb +7 -20
- data/lib/ruby_lsp/requests/completion_resolve.rb +5 -5
- data/lib/ruby_lsp/requests/definition.rb +8 -17
- data/lib/ruby_lsp/requests/diagnostics.rb +8 -11
- data/lib/ruby_lsp/requests/discover_tests.rb +18 -5
- data/lib/ruby_lsp/requests/document_highlight.rb +5 -15
- data/lib/ruby_lsp/requests/document_link.rb +6 -17
- data/lib/ruby_lsp/requests/document_symbol.rb +5 -8
- data/lib/ruby_lsp/requests/folding_ranges.rb +7 -15
- data/lib/ruby_lsp/requests/formatting.rb +6 -9
- data/lib/ruby_lsp/requests/go_to_relevant_file.rb +87 -0
- data/lib/ruby_lsp/requests/hover.rb +8 -18
- data/lib/ruby_lsp/requests/inlay_hints.rb +6 -17
- data/lib/ruby_lsp/requests/on_type_formatting.rb +28 -38
- data/lib/ruby_lsp/requests/prepare_rename.rb +4 -9
- data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +4 -13
- data/lib/ruby_lsp/requests/range_formatting.rb +5 -6
- data/lib/ruby_lsp/requests/references.rb +6 -36
- data/lib/ruby_lsp/requests/rename.rb +11 -37
- data/lib/ruby_lsp/requests/request.rb +7 -19
- data/lib/ruby_lsp/requests/selection_ranges.rb +5 -5
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +12 -31
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +5 -6
- data/lib/ruby_lsp/requests/signature_help.rb +8 -26
- data/lib/ruby_lsp/requests/support/annotation.rb +4 -10
- data/lib/ruby_lsp/requests/support/common.rb +13 -50
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +27 -35
- data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +9 -12
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +22 -34
- data/lib/ruby_lsp/requests/support/selection_range.rb +1 -3
- data/lib/ruby_lsp/requests/support/sorbet.rb +29 -38
- data/lib/ruby_lsp/requests/support/source_uri.rb +16 -30
- data/lib/ruby_lsp/requests/support/syntax_tree_formatter.rb +12 -19
- data/lib/ruby_lsp/requests/support/test_item.rb +10 -14
- data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +5 -6
- data/lib/ruby_lsp/requests/workspace_symbol.rb +4 -4
- data/lib/ruby_lsp/response_builders/collection_response_builder.rb +5 -5
- data/lib/ruby_lsp/response_builders/document_symbol.rb +10 -16
- data/lib/ruby_lsp/response_builders/hover.rb +10 -13
- data/lib/ruby_lsp/response_builders/response_builder.rb +1 -1
- data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +59 -87
- data/lib/ruby_lsp/response_builders/signature_help.rb +5 -6
- data/lib/ruby_lsp/response_builders/test_collection.rb +6 -10
- data/lib/ruby_lsp/ruby_document.rb +22 -60
- data/lib/ruby_lsp/ruby_lsp_reporter_plugin.rb +109 -0
- data/lib/ruby_lsp/scope.rb +7 -11
- data/lib/ruby_lsp/server.rb +133 -74
- data/lib/ruby_lsp/setup_bundler.rb +58 -57
- data/lib/ruby_lsp/static_docs.rb +4 -7
- data/lib/ruby_lsp/store.rb +21 -40
- data/lib/ruby_lsp/test_helper.rb +3 -12
- data/lib/ruby_lsp/test_reporter.rb +207 -0
- data/lib/ruby_lsp/test_unit_test_runner.rb +98 -0
- data/lib/ruby_lsp/type_inferrer.rb +9 -13
- data/lib/ruby_lsp/utils.rb +37 -81
- metadata +9 -3
@@ -4,97 +4,70 @@
|
|
4
4
|
module RubyLsp
|
5
5
|
module Listeners
|
6
6
|
class DocumentHighlight
|
7
|
-
extend T::Sig
|
8
7
|
include Requests::Support::Common
|
9
8
|
|
10
|
-
GLOBAL_VARIABLE_NODES =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
Prism::LocalVariableAndWriteNode,
|
73
|
-
Prism::LocalVariableOperatorWriteNode,
|
74
|
-
Prism::LocalVariableOrWriteNode,
|
75
|
-
Prism::LocalVariableReadNode,
|
76
|
-
Prism::LocalVariableTargetNode,
|
77
|
-
Prism::LocalVariableWriteNode,
|
78
|
-
Prism::BlockParameterNode,
|
79
|
-
Prism::RequiredParameterNode,
|
80
|
-
Prism::RequiredKeywordParameterNode,
|
81
|
-
Prism::OptionalKeywordParameterNode,
|
82
|
-
Prism::RestParameterNode,
|
83
|
-
Prism::OptionalParameterNode,
|
84
|
-
Prism::KeywordRestParameterNode,
|
85
|
-
],
|
86
|
-
T::Array[T.class_of(Prism::Node)],
|
87
|
-
)
|
88
|
-
|
89
|
-
sig do
|
90
|
-
params(
|
91
|
-
response_builder: ResponseBuilders::CollectionResponseBuilder[Interface::DocumentHighlight],
|
92
|
-
target: T.nilable(Prism::Node),
|
93
|
-
parent: T.nilable(Prism::Node),
|
94
|
-
dispatcher: Prism::Dispatcher,
|
95
|
-
position: T::Hash[Symbol, T.untyped],
|
96
|
-
).void
|
97
|
-
end
|
9
|
+
GLOBAL_VARIABLE_NODES = [
|
10
|
+
Prism::GlobalVariableAndWriteNode,
|
11
|
+
Prism::GlobalVariableOperatorWriteNode,
|
12
|
+
Prism::GlobalVariableOrWriteNode,
|
13
|
+
Prism::GlobalVariableReadNode,
|
14
|
+
Prism::GlobalVariableTargetNode,
|
15
|
+
Prism::GlobalVariableWriteNode,
|
16
|
+
] #: Array[singleton(Prism::Node)]
|
17
|
+
|
18
|
+
INSTANCE_VARIABLE_NODES = [
|
19
|
+
Prism::InstanceVariableAndWriteNode,
|
20
|
+
Prism::InstanceVariableOperatorWriteNode,
|
21
|
+
Prism::InstanceVariableOrWriteNode,
|
22
|
+
Prism::InstanceVariableReadNode,
|
23
|
+
Prism::InstanceVariableTargetNode,
|
24
|
+
Prism::InstanceVariableWriteNode,
|
25
|
+
] #: Array[singleton(Prism::Node)]
|
26
|
+
|
27
|
+
CONSTANT_NODES = [
|
28
|
+
Prism::ConstantAndWriteNode,
|
29
|
+
Prism::ConstantOperatorWriteNode,
|
30
|
+
Prism::ConstantOrWriteNode,
|
31
|
+
Prism::ConstantReadNode,
|
32
|
+
Prism::ConstantTargetNode,
|
33
|
+
Prism::ConstantWriteNode,
|
34
|
+
] #: Array[singleton(Prism::Node)]
|
35
|
+
|
36
|
+
CONSTANT_PATH_NODES = [
|
37
|
+
Prism::ConstantPathAndWriteNode,
|
38
|
+
Prism::ConstantPathNode,
|
39
|
+
Prism::ConstantPathOperatorWriteNode,
|
40
|
+
Prism::ConstantPathOrWriteNode,
|
41
|
+
Prism::ConstantPathTargetNode,
|
42
|
+
Prism::ConstantPathWriteNode,
|
43
|
+
] #: Array[singleton(Prism::Node)]
|
44
|
+
|
45
|
+
CLASS_VARIABLE_NODES = [
|
46
|
+
Prism::ClassVariableAndWriteNode,
|
47
|
+
Prism::ClassVariableOperatorWriteNode,
|
48
|
+
Prism::ClassVariableOrWriteNode,
|
49
|
+
Prism::ClassVariableReadNode,
|
50
|
+
Prism::ClassVariableTargetNode,
|
51
|
+
Prism::ClassVariableWriteNode,
|
52
|
+
] #: Array[singleton(Prism::Node)]
|
53
|
+
|
54
|
+
LOCAL_NODES = [
|
55
|
+
Prism::LocalVariableAndWriteNode,
|
56
|
+
Prism::LocalVariableOperatorWriteNode,
|
57
|
+
Prism::LocalVariableOrWriteNode,
|
58
|
+
Prism::LocalVariableReadNode,
|
59
|
+
Prism::LocalVariableTargetNode,
|
60
|
+
Prism::LocalVariableWriteNode,
|
61
|
+
Prism::BlockParameterNode,
|
62
|
+
Prism::RequiredParameterNode,
|
63
|
+
Prism::RequiredKeywordParameterNode,
|
64
|
+
Prism::OptionalKeywordParameterNode,
|
65
|
+
Prism::RestParameterNode,
|
66
|
+
Prism::OptionalParameterNode,
|
67
|
+
Prism::KeywordRestParameterNode,
|
68
|
+
] #: Array[singleton(Prism::Node)]
|
69
|
+
|
70
|
+
#: (ResponseBuilders::CollectionResponseBuilder[Interface::DocumentHighlight] response_builder, Prism::Node? target, Prism::Node? parent, Prism::Dispatcher dispatcher, Hash[Symbol, untyped] position) -> void
|
98
71
|
def initialize(response_builder, target, parent, dispatcher, position)
|
99
72
|
@response_builder = response_builder
|
100
73
|
|
@@ -123,8 +96,8 @@ module RubyLsp
|
|
123
96
|
[target, nil]
|
124
97
|
end
|
125
98
|
|
126
|
-
@target =
|
127
|
-
@target_value =
|
99
|
+
@target = highlight_target #: Prism::Node?
|
100
|
+
@target_value = highlight_target_value #: String?
|
128
101
|
@target_position = position
|
129
102
|
|
130
103
|
if @target
|
@@ -188,7 +161,7 @@ module RubyLsp
|
|
188
161
|
end
|
189
162
|
end
|
190
163
|
|
191
|
-
|
164
|
+
#: (Prism::CallNode node) -> void
|
192
165
|
def on_call_node_enter(node)
|
193
166
|
return unless matches?(node, [Prism::CallNode, Prism::DefNode])
|
194
167
|
|
@@ -199,7 +172,7 @@ module RubyLsp
|
|
199
172
|
add_highlight(Constant::DocumentHighlightKind::READ, loc)
|
200
173
|
end
|
201
174
|
|
202
|
-
|
175
|
+
#: (Prism::DefNode node) -> void
|
203
176
|
def on_def_node_enter(node)
|
204
177
|
add_matching_end_highlights(node.def_keyword_loc, node.end_keyword_loc) if @target.is_a?(Prism::DefNode)
|
205
178
|
|
@@ -208,63 +181,63 @@ module RubyLsp
|
|
208
181
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
209
182
|
end
|
210
183
|
|
211
|
-
|
184
|
+
#: (Prism::GlobalVariableTargetNode node) -> void
|
212
185
|
def on_global_variable_target_node_enter(node)
|
213
186
|
return unless matches?(node, GLOBAL_VARIABLE_NODES)
|
214
187
|
|
215
188
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
|
216
189
|
end
|
217
190
|
|
218
|
-
|
191
|
+
#: (Prism::InstanceVariableTargetNode node) -> void
|
219
192
|
def on_instance_variable_target_node_enter(node)
|
220
193
|
return unless matches?(node, INSTANCE_VARIABLE_NODES)
|
221
194
|
|
222
195
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
|
223
196
|
end
|
224
197
|
|
225
|
-
|
198
|
+
#: (Prism::ConstantPathTargetNode node) -> void
|
226
199
|
def on_constant_path_target_node_enter(node)
|
227
200
|
return unless matches?(node, CONSTANT_PATH_NODES)
|
228
201
|
|
229
202
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
|
230
203
|
end
|
231
204
|
|
232
|
-
|
205
|
+
#: (Prism::ConstantTargetNode node) -> void
|
233
206
|
def on_constant_target_node_enter(node)
|
234
207
|
return unless matches?(node, CONSTANT_NODES)
|
235
208
|
|
236
209
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
|
237
210
|
end
|
238
211
|
|
239
|
-
|
212
|
+
#: (Prism::ClassVariableTargetNode node) -> void
|
240
213
|
def on_class_variable_target_node_enter(node)
|
241
214
|
return unless matches?(node, CLASS_VARIABLE_NODES)
|
242
215
|
|
243
216
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
|
244
217
|
end
|
245
218
|
|
246
|
-
|
219
|
+
#: (Prism::LocalVariableTargetNode node) -> void
|
247
220
|
def on_local_variable_target_node_enter(node)
|
248
221
|
return unless matches?(node, LOCAL_NODES)
|
249
222
|
|
250
223
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
|
251
224
|
end
|
252
225
|
|
253
|
-
|
226
|
+
#: (Prism::BlockParameterNode node) -> void
|
254
227
|
def on_block_parameter_node_enter(node)
|
255
228
|
return unless matches?(node, LOCAL_NODES)
|
256
229
|
|
257
230
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
|
258
231
|
end
|
259
232
|
|
260
|
-
|
233
|
+
#: (Prism::RequiredParameterNode node) -> void
|
261
234
|
def on_required_parameter_node_enter(node)
|
262
235
|
return unless matches?(node, LOCAL_NODES)
|
263
236
|
|
264
237
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
|
265
238
|
end
|
266
239
|
|
267
|
-
|
240
|
+
#: (Prism::ClassNode node) -> void
|
268
241
|
def on_class_node_enter(node)
|
269
242
|
add_matching_end_highlights(node.class_keyword_loc, node.end_keyword_loc) if @target.is_a?(Prism::ClassNode)
|
270
243
|
|
@@ -273,7 +246,7 @@ module RubyLsp
|
|
273
246
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.constant_path.location)
|
274
247
|
end
|
275
248
|
|
276
|
-
|
249
|
+
#: (Prism::ModuleNode node) -> void
|
277
250
|
def on_module_node_enter(node)
|
278
251
|
add_matching_end_highlights(node.module_keyword_loc, node.end_keyword_loc) if @target.is_a?(Prism::ModuleNode)
|
279
252
|
|
@@ -282,98 +255,98 @@ module RubyLsp
|
|
282
255
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.constant_path.location)
|
283
256
|
end
|
284
257
|
|
285
|
-
|
258
|
+
#: (Prism::LocalVariableReadNode node) -> void
|
286
259
|
def on_local_variable_read_node_enter(node)
|
287
260
|
return unless matches?(node, LOCAL_NODES)
|
288
261
|
|
289
262
|
add_highlight(Constant::DocumentHighlightKind::READ, node.location)
|
290
263
|
end
|
291
264
|
|
292
|
-
|
265
|
+
#: (Prism::ConstantPathNode node) -> void
|
293
266
|
def on_constant_path_node_enter(node)
|
294
267
|
return unless matches?(node, CONSTANT_PATH_NODES)
|
295
268
|
|
296
269
|
add_highlight(Constant::DocumentHighlightKind::READ, node.name_loc)
|
297
270
|
end
|
298
271
|
|
299
|
-
|
272
|
+
#: (Prism::ConstantReadNode node) -> void
|
300
273
|
def on_constant_read_node_enter(node)
|
301
274
|
return unless matches?(node, CONSTANT_NODES)
|
302
275
|
|
303
276
|
add_highlight(Constant::DocumentHighlightKind::READ, node.location)
|
304
277
|
end
|
305
278
|
|
306
|
-
|
279
|
+
#: (Prism::InstanceVariableReadNode node) -> void
|
307
280
|
def on_instance_variable_read_node_enter(node)
|
308
281
|
return unless matches?(node, INSTANCE_VARIABLE_NODES)
|
309
282
|
|
310
283
|
add_highlight(Constant::DocumentHighlightKind::READ, node.location)
|
311
284
|
end
|
312
285
|
|
313
|
-
|
286
|
+
#: (Prism::ClassVariableReadNode node) -> void
|
314
287
|
def on_class_variable_read_node_enter(node)
|
315
288
|
return unless matches?(node, CLASS_VARIABLE_NODES)
|
316
289
|
|
317
290
|
add_highlight(Constant::DocumentHighlightKind::READ, node.location)
|
318
291
|
end
|
319
292
|
|
320
|
-
|
293
|
+
#: (Prism::GlobalVariableReadNode node) -> void
|
321
294
|
def on_global_variable_read_node_enter(node)
|
322
295
|
return unless matches?(node, GLOBAL_VARIABLE_NODES)
|
323
296
|
|
324
297
|
add_highlight(Constant::DocumentHighlightKind::READ, node.location)
|
325
298
|
end
|
326
299
|
|
327
|
-
|
300
|
+
#: (Prism::ConstantPathWriteNode node) -> void
|
328
301
|
def on_constant_path_write_node_enter(node)
|
329
302
|
return unless matches?(node, CONSTANT_PATH_NODES)
|
330
303
|
|
331
304
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.target.location)
|
332
305
|
end
|
333
306
|
|
334
|
-
|
307
|
+
#: (Prism::ConstantPathOrWriteNode node) -> void
|
335
308
|
def on_constant_path_or_write_node_enter(node)
|
336
309
|
return unless matches?(node, CONSTANT_PATH_NODES)
|
337
310
|
|
338
311
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.target.location)
|
339
312
|
end
|
340
313
|
|
341
|
-
|
314
|
+
#: (Prism::ConstantPathAndWriteNode node) -> void
|
342
315
|
def on_constant_path_and_write_node_enter(node)
|
343
316
|
return unless matches?(node, CONSTANT_PATH_NODES)
|
344
317
|
|
345
318
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.target.location)
|
346
319
|
end
|
347
320
|
|
348
|
-
|
321
|
+
#: (Prism::ConstantPathOperatorWriteNode node) -> void
|
349
322
|
def on_constant_path_operator_write_node_enter(node)
|
350
323
|
return unless matches?(node, CONSTANT_PATH_NODES)
|
351
324
|
|
352
325
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.target.location)
|
353
326
|
end
|
354
327
|
|
355
|
-
|
328
|
+
#: (Prism::LocalVariableWriteNode node) -> void
|
356
329
|
def on_local_variable_write_node_enter(node)
|
357
330
|
return unless matches?(node, LOCAL_NODES)
|
358
331
|
|
359
332
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
360
333
|
end
|
361
334
|
|
362
|
-
|
335
|
+
#: (Prism::RequiredKeywordParameterNode node) -> void
|
363
336
|
def on_required_keyword_parameter_node_enter(node)
|
364
337
|
return unless matches?(node, LOCAL_NODES)
|
365
338
|
|
366
339
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
367
340
|
end
|
368
341
|
|
369
|
-
|
342
|
+
#: (Prism::OptionalKeywordParameterNode node) -> void
|
370
343
|
def on_optional_keyword_parameter_node_enter(node)
|
371
344
|
return unless matches?(node, LOCAL_NODES)
|
372
345
|
|
373
346
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
374
347
|
end
|
375
348
|
|
376
|
-
|
349
|
+
#: (Prism::RestParameterNode node) -> void
|
377
350
|
def on_rest_parameter_node_enter(node)
|
378
351
|
return unless matches?(node, LOCAL_NODES)
|
379
352
|
|
@@ -381,14 +354,14 @@ module RubyLsp
|
|
381
354
|
add_highlight(Constant::DocumentHighlightKind::WRITE, name_loc) if name_loc
|
382
355
|
end
|
383
356
|
|
384
|
-
|
357
|
+
#: (Prism::OptionalParameterNode node) -> void
|
385
358
|
def on_optional_parameter_node_enter(node)
|
386
359
|
return unless matches?(node, LOCAL_NODES)
|
387
360
|
|
388
361
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
389
362
|
end
|
390
363
|
|
391
|
-
|
364
|
+
#: (Prism::KeywordRestParameterNode node) -> void
|
392
365
|
def on_keyword_rest_parameter_node_enter(node)
|
393
366
|
return unless matches?(node, LOCAL_NODES)
|
394
367
|
|
@@ -396,182 +369,182 @@ module RubyLsp
|
|
396
369
|
add_highlight(Constant::DocumentHighlightKind::WRITE, name_loc) if name_loc
|
397
370
|
end
|
398
371
|
|
399
|
-
|
372
|
+
#: (Prism::LocalVariableAndWriteNode node) -> void
|
400
373
|
def on_local_variable_and_write_node_enter(node)
|
401
374
|
return unless matches?(node, LOCAL_NODES)
|
402
375
|
|
403
376
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
404
377
|
end
|
405
378
|
|
406
|
-
|
379
|
+
#: (Prism::LocalVariableOperatorWriteNode node) -> void
|
407
380
|
def on_local_variable_operator_write_node_enter(node)
|
408
381
|
return unless matches?(node, LOCAL_NODES)
|
409
382
|
|
410
383
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
411
384
|
end
|
412
385
|
|
413
|
-
|
386
|
+
#: (Prism::LocalVariableOrWriteNode node) -> void
|
414
387
|
def on_local_variable_or_write_node_enter(node)
|
415
388
|
return unless matches?(node, LOCAL_NODES)
|
416
389
|
|
417
390
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
418
391
|
end
|
419
392
|
|
420
|
-
|
393
|
+
#: (Prism::ClassVariableWriteNode node) -> void
|
421
394
|
def on_class_variable_write_node_enter(node)
|
422
395
|
return unless matches?(node, CLASS_VARIABLE_NODES)
|
423
396
|
|
424
397
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
425
398
|
end
|
426
399
|
|
427
|
-
|
400
|
+
#: (Prism::ClassVariableOrWriteNode node) -> void
|
428
401
|
def on_class_variable_or_write_node_enter(node)
|
429
402
|
return unless matches?(node, CLASS_VARIABLE_NODES)
|
430
403
|
|
431
404
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
432
405
|
end
|
433
406
|
|
434
|
-
|
407
|
+
#: (Prism::ClassVariableOperatorWriteNode node) -> void
|
435
408
|
def on_class_variable_operator_write_node_enter(node)
|
436
409
|
return unless matches?(node, CLASS_VARIABLE_NODES)
|
437
410
|
|
438
411
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
439
412
|
end
|
440
413
|
|
441
|
-
|
414
|
+
#: (Prism::ClassVariableAndWriteNode node) -> void
|
442
415
|
def on_class_variable_and_write_node_enter(node)
|
443
416
|
return unless matches?(node, CLASS_VARIABLE_NODES)
|
444
417
|
|
445
418
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
446
419
|
end
|
447
420
|
|
448
|
-
|
421
|
+
#: (Prism::ConstantWriteNode node) -> void
|
449
422
|
def on_constant_write_node_enter(node)
|
450
423
|
return unless matches?(node, CONSTANT_NODES)
|
451
424
|
|
452
425
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
453
426
|
end
|
454
427
|
|
455
|
-
|
428
|
+
#: (Prism::ConstantOrWriteNode node) -> void
|
456
429
|
def on_constant_or_write_node_enter(node)
|
457
430
|
return unless matches?(node, CONSTANT_NODES)
|
458
431
|
|
459
432
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
460
433
|
end
|
461
434
|
|
462
|
-
|
435
|
+
#: (Prism::ConstantOperatorWriteNode node) -> void
|
463
436
|
def on_constant_operator_write_node_enter(node)
|
464
437
|
return unless matches?(node, CONSTANT_NODES)
|
465
438
|
|
466
439
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
467
440
|
end
|
468
441
|
|
469
|
-
|
442
|
+
#: (Prism::InstanceVariableWriteNode node) -> void
|
470
443
|
def on_instance_variable_write_node_enter(node)
|
471
444
|
return unless matches?(node, INSTANCE_VARIABLE_NODES)
|
472
445
|
|
473
446
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
474
447
|
end
|
475
448
|
|
476
|
-
|
449
|
+
#: (Prism::InstanceVariableOrWriteNode node) -> void
|
477
450
|
def on_instance_variable_or_write_node_enter(node)
|
478
451
|
return unless matches?(node, INSTANCE_VARIABLE_NODES)
|
479
452
|
|
480
453
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
481
454
|
end
|
482
455
|
|
483
|
-
|
456
|
+
#: (Prism::InstanceVariableAndWriteNode node) -> void
|
484
457
|
def on_instance_variable_and_write_node_enter(node)
|
485
458
|
return unless matches?(node, INSTANCE_VARIABLE_NODES)
|
486
459
|
|
487
460
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
488
461
|
end
|
489
462
|
|
490
|
-
|
463
|
+
#: (Prism::InstanceVariableOperatorWriteNode node) -> void
|
491
464
|
def on_instance_variable_operator_write_node_enter(node)
|
492
465
|
return unless matches?(node, INSTANCE_VARIABLE_NODES)
|
493
466
|
|
494
467
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
495
468
|
end
|
496
469
|
|
497
|
-
|
470
|
+
#: (Prism::ConstantAndWriteNode node) -> void
|
498
471
|
def on_constant_and_write_node_enter(node)
|
499
472
|
return unless matches?(node, CONSTANT_NODES)
|
500
473
|
|
501
474
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
502
475
|
end
|
503
476
|
|
504
|
-
|
477
|
+
#: (Prism::GlobalVariableWriteNode node) -> void
|
505
478
|
def on_global_variable_write_node_enter(node)
|
506
479
|
return unless matches?(node, GLOBAL_VARIABLE_NODES)
|
507
480
|
|
508
481
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
509
482
|
end
|
510
483
|
|
511
|
-
|
484
|
+
#: (Prism::GlobalVariableOrWriteNode node) -> void
|
512
485
|
def on_global_variable_or_write_node_enter(node)
|
513
486
|
return unless matches?(node, GLOBAL_VARIABLE_NODES)
|
514
487
|
|
515
488
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
516
489
|
end
|
517
490
|
|
518
|
-
|
491
|
+
#: (Prism::GlobalVariableAndWriteNode node) -> void
|
519
492
|
def on_global_variable_and_write_node_enter(node)
|
520
493
|
return unless matches?(node, GLOBAL_VARIABLE_NODES)
|
521
494
|
|
522
495
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
523
496
|
end
|
524
497
|
|
525
|
-
|
498
|
+
#: (Prism::GlobalVariableOperatorWriteNode node) -> void
|
526
499
|
def on_global_variable_operator_write_node_enter(node)
|
527
500
|
return unless matches?(node, GLOBAL_VARIABLE_NODES)
|
528
501
|
|
529
502
|
add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
|
530
503
|
end
|
531
504
|
|
532
|
-
|
505
|
+
#: (Prism::SingletonClassNode node) -> void
|
533
506
|
def on_singleton_class_node_enter(node)
|
534
507
|
return unless @target.is_a?(Prism::SingletonClassNode)
|
535
508
|
|
536
509
|
add_matching_end_highlights(node.class_keyword_loc, node.end_keyword_loc)
|
537
510
|
end
|
538
511
|
|
539
|
-
|
512
|
+
#: (Prism::CaseNode node) -> void
|
540
513
|
def on_case_node_enter(node)
|
541
514
|
return unless @target.is_a?(Prism::CaseNode)
|
542
515
|
|
543
516
|
add_matching_end_highlights(node.case_keyword_loc, node.end_keyword_loc)
|
544
517
|
end
|
545
518
|
|
546
|
-
|
519
|
+
#: (Prism::WhileNode node) -> void
|
547
520
|
def on_while_node_enter(node)
|
548
521
|
return unless @target.is_a?(Prism::WhileNode)
|
549
522
|
|
550
523
|
add_matching_end_highlights(node.keyword_loc, node.closing_loc)
|
551
524
|
end
|
552
525
|
|
553
|
-
|
526
|
+
#: (Prism::UntilNode node) -> void
|
554
527
|
def on_until_node_enter(node)
|
555
528
|
return unless @target.is_a?(Prism::UntilNode)
|
556
529
|
|
557
530
|
add_matching_end_highlights(node.keyword_loc, node.closing_loc)
|
558
531
|
end
|
559
532
|
|
560
|
-
|
533
|
+
#: (Prism::ForNode node) -> void
|
561
534
|
def on_for_node_enter(node)
|
562
535
|
return unless @target.is_a?(Prism::ForNode)
|
563
536
|
|
564
537
|
add_matching_end_highlights(node.for_keyword_loc, node.end_keyword_loc)
|
565
538
|
end
|
566
539
|
|
567
|
-
|
540
|
+
#: (Prism::IfNode node) -> void
|
568
541
|
def on_if_node_enter(node)
|
569
542
|
return unless @target.is_a?(Prism::IfNode)
|
570
543
|
|
571
544
|
add_matching_end_highlights(node.if_keyword_loc, node.end_keyword_loc)
|
572
545
|
end
|
573
546
|
|
574
|
-
|
547
|
+
#: (Prism::UnlessNode node) -> void
|
575
548
|
def on_unless_node_enter(node)
|
576
549
|
return unless @target.is_a?(Prism::UnlessNode)
|
577
550
|
|
@@ -580,17 +553,17 @@ module RubyLsp
|
|
580
553
|
|
581
554
|
private
|
582
555
|
|
583
|
-
|
556
|
+
#: (Prism::Node node, Array[singleton(Prism::Node)] classes) -> bool?
|
584
557
|
def matches?(node, classes)
|
585
558
|
classes.any? { |klass| @target.is_a?(klass) } && @target_value == node_value(node)
|
586
559
|
end
|
587
560
|
|
588
|
-
|
561
|
+
#: (Integer kind, Prism::Location location) -> void
|
589
562
|
def add_highlight(kind, location)
|
590
563
|
@response_builder << Interface::DocumentHighlight.new(range: range_from_location(location), kind: kind)
|
591
564
|
end
|
592
565
|
|
593
|
-
|
566
|
+
#: (Prism::Node? node) -> String?
|
594
567
|
def node_value(node)
|
595
568
|
case node
|
596
569
|
when Prism::ConstantReadNode, Prism::ConstantPathNode, Prism::BlockArgumentNode, Prism::ConstantTargetNode,
|
@@ -618,7 +591,7 @@ module RubyLsp
|
|
618
591
|
end
|
619
592
|
end
|
620
593
|
|
621
|
-
|
594
|
+
#: (Prism::Location? keyword_loc, Prism::Location? end_loc) -> void
|
622
595
|
def add_matching_end_highlights(keyword_loc, end_loc)
|
623
596
|
return unless keyword_loc && end_loc
|
624
597
|
return unless end_loc.length.positive?
|
@@ -628,7 +601,7 @@ module RubyLsp
|
|
628
601
|
add_highlight(Constant::DocumentHighlightKind::TEXT, end_loc)
|
629
602
|
end
|
630
603
|
|
631
|
-
|
604
|
+
#: (Prism::Location location) -> bool
|
632
605
|
def covers_target_position?(location)
|
633
606
|
start_line = location.start_line - 1
|
634
607
|
end_line = location.end_line - 1
|