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) ⇒ DocumentHighlight

Returns a new instance of DocumentHighlight.



119
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
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 119

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

  @_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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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