Class: RubyLsp::Requests::DocumentHighlight

Inherits:
Listener
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/ruby_lsp/requests/document_highlight.rb

Overview

![Document highlight demo](../../document_highlight.gif)

The [document highlight](microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight) informs the editor all relevant elements of the currently pointed item for highlighting. For example, when the cursor is on the ‘F` of the constant `FOO`, the editor should identify other occurrences of `FOO` and highlight them.

For writable elements like constants or variables, their read/write occurrences should be highlighted differently. This is achieved by sending different “kind” attributes to the editor (2 for read and 3 for write).

# Example

“‘ruby FOO = 1 # should be highlighted as “write”

def foo

FOO # should be highlighted as "read"

end “‘

Constant Summary collapse

ResponseType =
type_member { { fixed: T::Array[Interface::DocumentHighlight] } }
GLOBAL_VARIABLE_NODES =
T.let(
  [
    Prism::GlobalVariableAndWriteNode,
    Prism::GlobalVariableOperatorWriteNode,
    Prism::GlobalVariableOrWriteNode,
    Prism::GlobalVariableReadNode,
    Prism::GlobalVariableTargetNode,
    Prism::GlobalVariableWriteNode,
  ],
  T::Array[T.class_of(Prism::Node)],
)
INSTANCE_VARIABLE_NODES =
T.let(
  [
    Prism::InstanceVariableAndWriteNode,
    Prism::InstanceVariableOperatorWriteNode,
    Prism::InstanceVariableOrWriteNode,
    Prism::InstanceVariableReadNode,
    Prism::InstanceVariableTargetNode,
    Prism::InstanceVariableWriteNode,
  ],
  T::Array[T.class_of(Prism::Node)],
)
CONSTANT_NODES =
T.let(
  [
    Prism::ConstantAndWriteNode,
    Prism::ConstantOperatorWriteNode,
    Prism::ConstantOrWriteNode,
    Prism::ConstantReadNode,
    Prism::ConstantTargetNode,
    Prism::ConstantWriteNode,
  ],
  T::Array[T.class_of(Prism::Node)],
)
CONSTANT_PATH_NODES =
T.let(
  [
    Prism::ConstantPathAndWriteNode,
    Prism::ConstantPathNode,
    Prism::ConstantPathOperatorWriteNode,
    Prism::ConstantPathOrWriteNode,
    Prism::ConstantPathTargetNode,
    Prism::ConstantPathWriteNode,
  ],
  T::Array[T.class_of(Prism::Node)],
)
CLASS_VARIABLE_NODES =
T.let(
  [
    Prism::ClassVariableAndWriteNode,
    Prism::ClassVariableOperatorWriteNode,
    Prism::ClassVariableOrWriteNode,
    Prism::ClassVariableReadNode,
    Prism::ClassVariableTargetNode,
    Prism::ClassVariableWriteNode,
  ],
  T::Array[T.class_of(Prism::Node)],
)
LOCAL_NODES =
T.let(
  [
    Prism::LocalVariableAndWriteNode,
    Prism::LocalVariableOperatorWriteNode,
    Prism::LocalVariableOrWriteNode,
    Prism::LocalVariableReadNode,
    Prism::LocalVariableTargetNode,
    Prism::LocalVariableWriteNode,
    Prism::BlockParameterNode,
    Prism::RequiredParameterNode,
    Prism::RequiredKeywordParameterNode,
    Prism::OptionalKeywordParameterNode,
    Prism::RestParameterNode,
    Prism::OptionalParameterNode,
    Prism::KeywordRestParameterNode,
  ],
  T::Array[T.class_of(Prism::Node)],
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Listener

#response

Methods included from Support::Common

#create_code_lens, #defined_in_gem?, #markdown_from_index_entries, #range_from_location, #range_from_node, #self_receiver?, #visible?

Constructor Details

#initialize(target, parent, dispatcher, message_queue) ⇒ DocumentHighlight

Returns a new instance of DocumentHighlight.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 120

def initialize(target, parent, dispatcher, message_queue)
  super(dispatcher, message_queue)

  @_response = T.let([], T::Array[Interface::DocumentHighlight])

  return unless target && parent

  highlight_target =
    case target
    when Prism::GlobalVariableReadNode, Prism::GlobalVariableAndWriteNode, Prism::GlobalVariableOperatorWriteNode,
      Prism::GlobalVariableOrWriteNode, Prism::GlobalVariableTargetNode, Prism::GlobalVariableWriteNode,
      Prism::InstanceVariableAndWriteNode, Prism::InstanceVariableOperatorWriteNode,
      Prism::InstanceVariableOrWriteNode, Prism::InstanceVariableReadNode, Prism::InstanceVariableTargetNode,
      Prism::InstanceVariableWriteNode, Prism::ConstantAndWriteNode, Prism::ConstantOperatorWriteNode,
      Prism::ConstantOrWriteNode, Prism::ConstantPathAndWriteNode, Prism::ConstantPathNode,
      Prism::ConstantPathOperatorWriteNode, Prism::ConstantPathOrWriteNode, Prism::ConstantPathTargetNode,
      Prism::ConstantPathWriteNode, Prism::ConstantReadNode, Prism::ConstantTargetNode, Prism::ConstantWriteNode,
      Prism::ClassVariableAndWriteNode, Prism::ClassVariableOperatorWriteNode, Prism::ClassVariableOrWriteNode,
      Prism::ClassVariableReadNode, Prism::ClassVariableTargetNode, Prism::ClassVariableWriteNode,
      Prism::LocalVariableAndWriteNode, Prism::LocalVariableOperatorWriteNode, Prism::LocalVariableOrWriteNode,
      Prism::LocalVariableReadNode, Prism::LocalVariableTargetNode, Prism::LocalVariableWriteNode,
      Prism::CallNode, Prism::BlockParameterNode, Prism::RequiredKeywordParameterNode,
      Prism::RequiredKeywordParameterNode, Prism::KeywordRestParameterNode, Prism::OptionalParameterNode,
      Prism::RequiredParameterNode, Prism::RestParameterNode
      target
    end

  @target = T.let(highlight_target, T.nilable(Prism::Node))
  @target_value = T.let(node_value(highlight_target), T.nilable(String))

  if @target && @target_value
    dispatcher.register(
      self,
      :on_call_node_enter,
      :on_def_node_enter,
      :on_global_variable_target_node_enter,
      :on_instance_variable_target_node_enter,
      :on_constant_path_target_node_enter,
      :on_constant_target_node_enter,
      :on_class_variable_target_node_enter,
      :on_local_variable_target_node_enter,
      :on_block_parameter_node_enter,
      :on_required_parameter_node_enter,
      :on_class_node_enter,
      :on_module_node_enter,
      :on_local_variable_read_node_enter,
      :on_constant_path_node_enter,
      :on_constant_read_node_enter,
      :on_instance_variable_read_node_enter,
      :on_class_variable_read_node_enter,
      :on_global_variable_read_node_enter,
      :on_constant_path_write_node_enter,
      :on_constant_path_or_write_node_enter,
      :on_constant_path_and_write_node_enter,
      :on_constant_path_operator_write_node_enter,
      :on_local_variable_write_node_enter,
      :on_required_keyword_parameter_node_enter,
      :on_optional_keyword_parameter_node_enter,
      :on_rest_parameter_node_enter,
      :on_optional_parameter_node_enter,
      :on_keyword_rest_parameter_node_enter,
      :on_local_variable_and_write_node_enter,
      :on_local_variable_operator_write_node_enter,
      :on_local_variable_or_write_node_enter,
      :on_class_variable_write_node_enter,
      :on_class_variable_or_write_node_enter,
      :on_class_variable_operator_write_node_enter,
      :on_class_variable_and_write_node_enter,
      :on_constant_write_node_enter,
      :on_constant_or_write_node_enter,
      :on_constant_operator_write_node_enter,
      :on_instance_variable_write_node_enter,
      :on_constant_and_write_node_enter,
      :on_instance_variable_or_write_node_enter,
      :on_instance_variable_and_write_node_enter,
      :on_instance_variable_operator_write_node_enter,
      :on_global_variable_write_node_enter,
      :on_global_variable_or_write_node_enter,
      :on_global_variable_and_write_node_enter,
      :on_global_variable_operator_write_node_enter,
    )
  end
end

Instance Attribute Details

#_responseObject (readonly)

Returns the value of attribute _response.



110
111
112
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 110

def _response
  @_response
end

Instance Method Details

#on_block_parameter_node_enter(node) ⇒ Object



261
262
263
264
265
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 261

def on_block_parameter_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
end

#on_call_node_enter(node) ⇒ Object



205
206
207
208
209
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 205

def on_call_node_enter(node)
  return unless matches?(node, [Prism::CallNode, Prism::DefNode])

  add_highlight(Constant::DocumentHighlightKind::READ, node.location)
end

#on_class_node_enter(node) ⇒ Object



275
276
277
278
279
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 275

def on_class_node_enter(node)
  return unless matches?(node, CONSTANT_NODES + CONSTANT_PATH_NODES + [Prism::ClassNode])

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.constant_path.location)
end

#on_class_variable_and_write_node_enter(node) ⇒ Object



445
446
447
448
449
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 445

def on_class_variable_and_write_node_enter(node)
  return unless matches?(node, CLASS_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_class_variable_operator_write_node_enter(node) ⇒ Object



438
439
440
441
442
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 438

def on_class_variable_operator_write_node_enter(node)
  return unless matches?(node, CLASS_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_class_variable_or_write_node_enter(node) ⇒ Object



431
432
433
434
435
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 431

def on_class_variable_or_write_node_enter(node)
  return unless matches?(node, CLASS_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_class_variable_read_node_enter(node) ⇒ Object



317
318
319
320
321
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 317

def on_class_variable_read_node_enter(node)
  return unless matches?(node, CLASS_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::READ, node.location)
end

#on_class_variable_target_node_enter(node) ⇒ Object



247
248
249
250
251
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 247

def on_class_variable_target_node_enter(node)
  return unless matches?(node, CLASS_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
end

#on_class_variable_write_node_enter(node) ⇒ Object



424
425
426
427
428
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 424

def on_class_variable_write_node_enter(node)
  return unless matches?(node, CLASS_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_constant_and_write_node_enter(node) ⇒ Object



501
502
503
504
505
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 501

def on_constant_and_write_node_enter(node)
  return unless matches?(node, CONSTANT_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_constant_operator_write_node_enter(node) ⇒ Object



466
467
468
469
470
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 466

def on_constant_operator_write_node_enter(node)
  return unless matches?(node, CONSTANT_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_constant_or_write_node_enter(node) ⇒ Object



459
460
461
462
463
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 459

def on_constant_or_write_node_enter(node)
  return unless matches?(node, CONSTANT_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_constant_path_and_write_node_enter(node) ⇒ Object



345
346
347
348
349
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 345

def on_constant_path_and_write_node_enter(node)
  return unless matches?(node, CONSTANT_PATH_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.target.location)
end

#on_constant_path_node_enter(node) ⇒ Object



296
297
298
299
300
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 296

def on_constant_path_node_enter(node)
  return unless matches?(node, CONSTANT_PATH_NODES)

  add_highlight(Constant::DocumentHighlightKind::READ, node.location)
end

#on_constant_path_operator_write_node_enter(node) ⇒ Object



352
353
354
355
356
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 352

def on_constant_path_operator_write_node_enter(node)
  return unless matches?(node, CONSTANT_PATH_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.target.location)
end

#on_constant_path_or_write_node_enter(node) ⇒ Object



338
339
340
341
342
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 338

def on_constant_path_or_write_node_enter(node)
  return unless matches?(node, CONSTANT_PATH_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.target.location)
end

#on_constant_path_target_node_enter(node) ⇒ Object



233
234
235
236
237
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 233

def on_constant_path_target_node_enter(node)
  return unless matches?(node, CONSTANT_PATH_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
end

#on_constant_path_write_node_enter(node) ⇒ Object



331
332
333
334
335
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 331

def on_constant_path_write_node_enter(node)
  return unless matches?(node, CONSTANT_PATH_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.target.location)
end

#on_constant_read_node_enter(node) ⇒ Object



303
304
305
306
307
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 303

def on_constant_read_node_enter(node)
  return unless matches?(node, CONSTANT_NODES)

  add_highlight(Constant::DocumentHighlightKind::READ, node.location)
end

#on_constant_target_node_enter(node) ⇒ Object



240
241
242
243
244
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 240

def on_constant_target_node_enter(node)
  return unless matches?(node, CONSTANT_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
end

#on_constant_write_node_enter(node) ⇒ Object



452
453
454
455
456
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 452

def on_constant_write_node_enter(node)
  return unless matches?(node, CONSTANT_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_def_node_enter(node) ⇒ Object



212
213
214
215
216
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 212

def on_def_node_enter(node)
  return unless matches?(node, [Prism::CallNode, Prism::DefNode])

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_global_variable_and_write_node_enter(node) ⇒ Object



522
523
524
525
526
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 522

def on_global_variable_and_write_node_enter(node)
  return unless matches?(node, GLOBAL_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_global_variable_operator_write_node_enter(node) ⇒ Object



529
530
531
532
533
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 529

def on_global_variable_operator_write_node_enter(node)
  return unless matches?(node, GLOBAL_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_global_variable_or_write_node_enter(node) ⇒ Object



515
516
517
518
519
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 515

def on_global_variable_or_write_node_enter(node)
  return unless matches?(node, GLOBAL_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_global_variable_read_node_enter(node) ⇒ Object



324
325
326
327
328
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 324

def on_global_variable_read_node_enter(node)
  return unless matches?(node, GLOBAL_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::READ, node.location)
end

#on_global_variable_target_node_enter(node) ⇒ Object



219
220
221
222
223
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 219

def on_global_variable_target_node_enter(node)
  return unless matches?(node, GLOBAL_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
end

#on_global_variable_write_node_enter(node) ⇒ Object



508
509
510
511
512
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 508

def on_global_variable_write_node_enter(node)
  return unless matches?(node, GLOBAL_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_instance_variable_and_write_node_enter(node) ⇒ Object



487
488
489
490
491
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 487

def on_instance_variable_and_write_node_enter(node)
  return unless matches?(node, INSTANCE_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_instance_variable_operator_write_node_enter(node) ⇒ Object



494
495
496
497
498
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 494

def on_instance_variable_operator_write_node_enter(node)
  return unless matches?(node, INSTANCE_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_instance_variable_or_write_node_enter(node) ⇒ Object



480
481
482
483
484
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 480

def on_instance_variable_or_write_node_enter(node)
  return unless matches?(node, INSTANCE_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_instance_variable_read_node_enter(node) ⇒ Object



310
311
312
313
314
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 310

def on_instance_variable_read_node_enter(node)
  return unless matches?(node, INSTANCE_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::READ, node.location)
end

#on_instance_variable_target_node_enter(node) ⇒ Object



226
227
228
229
230
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 226

def on_instance_variable_target_node_enter(node)
  return unless matches?(node, INSTANCE_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
end

#on_instance_variable_write_node_enter(node) ⇒ Object



473
474
475
476
477
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 473

def on_instance_variable_write_node_enter(node)
  return unless matches?(node, INSTANCE_VARIABLE_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_keyword_rest_parameter_node_enter(node) ⇒ Object



395
396
397
398
399
400
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 395

def on_keyword_rest_parameter_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  name_loc = node.name_loc
  add_highlight(Constant::DocumentHighlightKind::WRITE, name_loc) if name_loc
end

#on_local_variable_and_write_node_enter(node) ⇒ Object



403
404
405
406
407
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 403

def on_local_variable_and_write_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_local_variable_operator_write_node_enter(node) ⇒ Object



410
411
412
413
414
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 410

def on_local_variable_operator_write_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_local_variable_or_write_node_enter(node) ⇒ Object



417
418
419
420
421
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 417

def on_local_variable_or_write_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_local_variable_read_node_enter(node) ⇒ Object



289
290
291
292
293
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 289

def on_local_variable_read_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::READ, node.location)
end

#on_local_variable_target_node_enter(node) ⇒ Object



254
255
256
257
258
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 254

def on_local_variable_target_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
end

#on_local_variable_write_node_enter(node) ⇒ Object



359
360
361
362
363
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 359

def on_local_variable_write_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_module_node_enter(node) ⇒ Object



282
283
284
285
286
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 282

def on_module_node_enter(node)
  return unless matches?(node, CONSTANT_NODES + CONSTANT_PATH_NODES + [Prism::ModuleNode])

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.constant_path.location)
end

#on_optional_keyword_parameter_node_enter(node) ⇒ Object



373
374
375
376
377
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 373

def on_optional_keyword_parameter_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_optional_parameter_node_enter(node) ⇒ Object



388
389
390
391
392
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 388

def on_optional_parameter_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_required_keyword_parameter_node_enter(node) ⇒ Object



366
367
368
369
370
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 366

def on_required_keyword_parameter_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
end

#on_required_parameter_node_enter(node) ⇒ Object



268
269
270
271
272
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 268

def on_required_parameter_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  add_highlight(Constant::DocumentHighlightKind::WRITE, node.location)
end

#on_rest_parameter_node_enter(node) ⇒ Object



380
381
382
383
384
385
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 380

def on_rest_parameter_node_enter(node)
  return unless matches?(node, LOCAL_NODES)

  name_loc = node.name_loc
  add_highlight(Constant::DocumentHighlightKind::WRITE, name_loc) if name_loc
end