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