ruby-lsp 0.11.2 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/exe/ruby-lsp +11 -2
- data/exe/ruby-lsp-check +2 -1
- data/exe/ruby-lsp-doctor +15 -0
- data/lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb +125 -0
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +10 -2
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +205 -0
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +23 -106
- data/lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +6 -6
- data/lib/ruby_indexer/lib/ruby_indexer/visitor.rb +101 -49
- data/lib/ruby_indexer/ruby_indexer.rb +4 -3
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +49 -16
- data/lib/ruby_indexer/test/constant_test.rb +99 -36
- data/lib/ruby_indexer/test/index_test.rb +1 -1
- data/lib/ruby_indexer/test/method_test.rb +73 -0
- data/lib/ruby_indexer/test/test_case.rb +5 -1
- data/lib/ruby_lsp/addon.rb +8 -8
- data/lib/ruby_lsp/document.rb +14 -14
- data/lib/ruby_lsp/executor.rb +89 -53
- data/lib/ruby_lsp/internal.rb +7 -2
- data/lib/ruby_lsp/listener.rb +6 -6
- data/lib/ruby_lsp/requests/base_request.rb +1 -9
- data/lib/ruby_lsp/requests/code_action_resolve.rb +3 -3
- data/lib/ruby_lsp/requests/code_lens.rb +47 -31
- data/lib/ruby_lsp/requests/completion.rb +83 -32
- data/lib/ruby_lsp/requests/definition.rb +21 -15
- data/lib/ruby_lsp/requests/diagnostics.rb +1 -1
- data/lib/ruby_lsp/requests/document_highlight.rb +508 -31
- data/lib/ruby_lsp/requests/document_link.rb +24 -17
- data/lib/ruby_lsp/requests/document_symbol.rb +42 -42
- data/lib/ruby_lsp/requests/folding_ranges.rb +83 -77
- data/lib/ruby_lsp/requests/hover.rb +22 -17
- data/lib/ruby_lsp/requests/inlay_hints.rb +6 -6
- data/lib/ruby_lsp/requests/selection_ranges.rb +13 -105
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +92 -92
- data/lib/ruby_lsp/requests/support/annotation.rb +3 -3
- data/lib/ruby_lsp/requests/support/common.rb +5 -5
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +21 -7
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +19 -0
- data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +10 -7
- data/lib/ruby_lsp/requests/support/sorbet.rb +28 -28
- data/lib/ruby_lsp/requests/workspace_symbol.rb +4 -4
- data/lib/ruby_lsp/requests.rb +0 -1
- data/lib/ruby_lsp/setup_bundler.rb +26 -17
- metadata +20 -17
- data/lib/ruby_lsp/event_emitter.rb +0 -351
- data/lib/ruby_lsp/requests/support/highlight_target.rb +0 -118
@@ -1,351 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module RubyLsp
|
5
|
-
# EventEmitter is an intermediary between our requests and YARP visitors. It's used to visit the document's AST
|
6
|
-
# and emit events that the requests can listen to for providing functionality. Usages:
|
7
|
-
#
|
8
|
-
# - For positional requests, locate the target node and use `emit_for_target` to fire events for each listener
|
9
|
-
# - For nonpositional requests, use `visit` to go through the AST, which will fire events for each listener as nodes
|
10
|
-
# are found
|
11
|
-
#
|
12
|
-
# # Example
|
13
|
-
#
|
14
|
-
# ```ruby
|
15
|
-
# target_node = document.locate_node(position)
|
16
|
-
# emitter = EventEmitter.new
|
17
|
-
# listener = Requests::Hover.new(emitter, @message_queue)
|
18
|
-
# emitter.emit_for_target(target_node)
|
19
|
-
# listener.response
|
20
|
-
# ```
|
21
|
-
class EventEmitter < YARP::Visitor
|
22
|
-
extend T::Sig
|
23
|
-
|
24
|
-
sig { void }
|
25
|
-
def initialize
|
26
|
-
@listeners = T.let(Hash.new { |h, k| h[k] = [] }, T::Hash[Symbol, T::Array[Listener[T.untyped]]])
|
27
|
-
super()
|
28
|
-
end
|
29
|
-
|
30
|
-
sig { params(listener: Listener[T.untyped], events: Symbol).void }
|
31
|
-
def register(listener, *events)
|
32
|
-
events.each { |event| T.must(@listeners[event]) << listener }
|
33
|
-
end
|
34
|
-
|
35
|
-
# Emit events for a specific node. This is similar to the regular `visit` method, but avoids going deeper into the
|
36
|
-
# tree for performance
|
37
|
-
sig { params(node: T.nilable(YARP::Node)).void }
|
38
|
-
def emit_for_target(node)
|
39
|
-
case node
|
40
|
-
when YARP::CallNode
|
41
|
-
@listeners[:on_call]&.each { |l| T.unsafe(l).on_call(node) }
|
42
|
-
when YARP::ConstantPathNode
|
43
|
-
@listeners[:on_constant_path]&.each { |l| T.unsafe(l).on_constant_path(node) }
|
44
|
-
when YARP::StringNode
|
45
|
-
@listeners[:on_string]&.each { |l| T.unsafe(l).on_string(node) }
|
46
|
-
when YARP::ClassNode
|
47
|
-
@listeners[:on_class]&.each { |l| T.unsafe(l).on_class(node) }
|
48
|
-
when YARP::ModuleNode
|
49
|
-
@listeners[:on_module]&.each { |l| T.unsafe(l).on_module(node) }
|
50
|
-
when YARP::ConstantWriteNode
|
51
|
-
@listeners[:on_constant_write]&.each { |l| T.unsafe(l).on_constant_write(node) }
|
52
|
-
when YARP::ConstantReadNode
|
53
|
-
@listeners[:on_constant_read]&.each { |l| T.unsafe(l).on_constant_read(node) }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Visit dispatchers are below. Notice that for nodes that create a new scope (e.g.: classes, modules, method defs)
|
58
|
-
# we need both an `on_*` and `after_*` event. This is because some requests must know when we exit the scope
|
59
|
-
sig { override.params(node: T.nilable(YARP::Node)).void }
|
60
|
-
def visit(node)
|
61
|
-
@listeners[:on_node]&.each { |l| T.unsafe(l).on_node(node) }
|
62
|
-
super
|
63
|
-
end
|
64
|
-
|
65
|
-
sig { params(nodes: T::Array[T.nilable(YARP::Node)]).void }
|
66
|
-
def visit_all(nodes)
|
67
|
-
nodes.each { |node| visit(node) }
|
68
|
-
end
|
69
|
-
|
70
|
-
sig { override.params(node: YARP::ClassNode).void }
|
71
|
-
def visit_class_node(node)
|
72
|
-
@listeners[:on_class]&.each { |l| T.unsafe(l).on_class(node) }
|
73
|
-
super
|
74
|
-
@listeners[:after_class]&.each { |l| T.unsafe(l).after_class(node) }
|
75
|
-
end
|
76
|
-
|
77
|
-
sig { override.params(node: YARP::ModuleNode).void }
|
78
|
-
def visit_module_node(node)
|
79
|
-
@listeners[:on_module]&.each { |l| T.unsafe(l).on_module(node) }
|
80
|
-
super
|
81
|
-
@listeners[:after_module]&.each { |l| T.unsafe(l).after_module(node) }
|
82
|
-
end
|
83
|
-
|
84
|
-
sig { override.params(node: YARP::CallNode).void }
|
85
|
-
def visit_call_node(node)
|
86
|
-
@listeners[:on_call]&.each { |l| T.unsafe(l).on_call(node) }
|
87
|
-
super
|
88
|
-
@listeners[:after_call]&.each { |l| T.unsafe(l).after_call(node) }
|
89
|
-
end
|
90
|
-
|
91
|
-
sig { override.params(node: YARP::InstanceVariableWriteNode).void }
|
92
|
-
def visit_instance_variable_write_node(node)
|
93
|
-
@listeners[:on_instance_variable_write]&.each { |l| T.unsafe(l).on_instance_variable_write(node) }
|
94
|
-
super
|
95
|
-
end
|
96
|
-
|
97
|
-
sig { override.params(node: YARP::ClassVariableWriteNode).void }
|
98
|
-
def visit_class_variable_write_node(node)
|
99
|
-
@listeners[:on_class_variable_write]&.each { |l| T.unsafe(l).on_class_variable_write(node) }
|
100
|
-
super
|
101
|
-
end
|
102
|
-
|
103
|
-
sig { override.params(node: YARP::DefNode).void }
|
104
|
-
def visit_def_node(node)
|
105
|
-
@listeners[:on_def]&.each { |l| T.unsafe(l).on_def(node) }
|
106
|
-
super
|
107
|
-
@listeners[:after_def]&.each { |l| T.unsafe(l).after_def(node) }
|
108
|
-
end
|
109
|
-
|
110
|
-
sig { override.params(node: YARP::BlockNode).void }
|
111
|
-
def visit_block_node(node)
|
112
|
-
@listeners[:on_block]&.each { |l| T.unsafe(l).on_block(node) }
|
113
|
-
super
|
114
|
-
@listeners[:after_block]&.each { |l| T.unsafe(l).after_block(node) }
|
115
|
-
end
|
116
|
-
|
117
|
-
sig { override.params(node: YARP::SelfNode).void }
|
118
|
-
def visit_self_node(node)
|
119
|
-
@listeners[:on_self]&.each { |l| T.unsafe(l).on_self(node) }
|
120
|
-
super
|
121
|
-
end
|
122
|
-
|
123
|
-
sig { override.params(node: YARP::RescueNode).void }
|
124
|
-
def visit_rescue_node(node)
|
125
|
-
@listeners[:on_rescue]&.each { |l| T.unsafe(l).on_rescue(node) }
|
126
|
-
super
|
127
|
-
end
|
128
|
-
|
129
|
-
sig { override.params(node: YARP::BlockParameterNode).void }
|
130
|
-
def visit_block_parameter_node(node)
|
131
|
-
@listeners[:on_block_parameter]&.each { |l| T.unsafe(l).on_block_parameter(node) }
|
132
|
-
super
|
133
|
-
end
|
134
|
-
|
135
|
-
sig { override.params(node: YARP::KeywordParameterNode).void }
|
136
|
-
def visit_keyword_parameter_node(node)
|
137
|
-
@listeners[:on_keyword_parameter]&.each { |l| T.unsafe(l).on_keyword_parameter(node) }
|
138
|
-
super
|
139
|
-
end
|
140
|
-
|
141
|
-
sig { override.params(node: YARP::KeywordRestParameterNode).void }
|
142
|
-
def visit_keyword_rest_parameter_node(node)
|
143
|
-
@listeners[:on_keyword_rest_parameter]&.each { |l| T.unsafe(l).on_keyword_rest_parameter(node) }
|
144
|
-
super
|
145
|
-
end
|
146
|
-
|
147
|
-
sig { override.params(node: YARP::OptionalParameterNode).void }
|
148
|
-
def visit_optional_parameter_node(node)
|
149
|
-
@listeners[:on_optional_parameter]&.each { |l| T.unsafe(l).on_optional_parameter(node) }
|
150
|
-
super
|
151
|
-
end
|
152
|
-
|
153
|
-
sig { override.params(node: YARP::RequiredParameterNode).void }
|
154
|
-
def visit_required_parameter_node(node)
|
155
|
-
@listeners[:on_required_parameter]&.each { |l| T.unsafe(l).on_required_parameter(node) }
|
156
|
-
super
|
157
|
-
end
|
158
|
-
|
159
|
-
sig { override.params(node: YARP::RestParameterNode).void }
|
160
|
-
def visit_rest_parameter_node(node)
|
161
|
-
@listeners[:on_rest_parameter]&.each { |l| T.unsafe(l).on_rest_parameter(node) }
|
162
|
-
super
|
163
|
-
end
|
164
|
-
|
165
|
-
sig { override.params(node: YARP::ConstantReadNode).void }
|
166
|
-
def visit_constant_read_node(node)
|
167
|
-
@listeners[:on_constant_read]&.each { |l| T.unsafe(l).on_constant_read(node) }
|
168
|
-
super
|
169
|
-
end
|
170
|
-
|
171
|
-
sig { override.params(node: YARP::ConstantPathNode).void }
|
172
|
-
def visit_constant_path_node(node)
|
173
|
-
@listeners[:on_constant_path]&.each { |l| T.unsafe(l).on_constant_path(node) }
|
174
|
-
super
|
175
|
-
end
|
176
|
-
|
177
|
-
sig { override.params(node: YARP::ConstantPathWriteNode).void }
|
178
|
-
def visit_constant_path_write_node(node)
|
179
|
-
@listeners[:on_constant_path_write]&.each { |l| T.unsafe(l).on_constant_path_write(node) }
|
180
|
-
super
|
181
|
-
end
|
182
|
-
|
183
|
-
sig { override.params(node: YARP::ConstantWriteNode).void }
|
184
|
-
def visit_constant_write_node(node)
|
185
|
-
@listeners[:on_constant_write]&.each { |l| T.unsafe(l).on_constant_write(node) }
|
186
|
-
super
|
187
|
-
end
|
188
|
-
|
189
|
-
sig { override.params(node: YARP::ConstantAndWriteNode).void }
|
190
|
-
def visit_constant_and_write_node(node)
|
191
|
-
@listeners[:on_constant_and_write]&.each { |l| T.unsafe(l).on_constant_and_write(node) }
|
192
|
-
super
|
193
|
-
end
|
194
|
-
|
195
|
-
sig { override.params(node: YARP::ConstantOperatorWriteNode).void }
|
196
|
-
def visit_constant_operator_write_node(node)
|
197
|
-
@listeners[:on_constant_operator_write]&.each { |l| T.unsafe(l).on_constant_operator_write(node) }
|
198
|
-
super
|
199
|
-
end
|
200
|
-
|
201
|
-
sig { override.params(node: YARP::ConstantOrWriteNode).void }
|
202
|
-
def visit_constant_or_write_node(node)
|
203
|
-
@listeners[:on_constant_or_write]&.each { |l| T.unsafe(l).on_constant_or_write(node) }
|
204
|
-
super
|
205
|
-
end
|
206
|
-
|
207
|
-
sig { override.params(node: YARP::ConstantTargetNode).void }
|
208
|
-
def visit_constant_target_node(node)
|
209
|
-
@listeners[:on_constant_target]&.each { |l| T.unsafe(l).on_constant_target(node) }
|
210
|
-
super
|
211
|
-
end
|
212
|
-
|
213
|
-
sig { override.params(node: YARP::LocalVariableWriteNode).void }
|
214
|
-
def visit_local_variable_write_node(node)
|
215
|
-
@listeners[:on_local_variable_write]&.each { |l| T.unsafe(l).on_local_variable_write(node) }
|
216
|
-
super
|
217
|
-
end
|
218
|
-
|
219
|
-
sig { override.params(node: YARP::LocalVariableReadNode).void }
|
220
|
-
def visit_local_variable_read_node(node)
|
221
|
-
@listeners[:on_local_variable_read]&.each { |l| T.unsafe(l).on_local_variable_read(node) }
|
222
|
-
super
|
223
|
-
end
|
224
|
-
|
225
|
-
sig { override.params(node: YARP::LocalVariableAndWriteNode).void }
|
226
|
-
def visit_local_variable_and_write_node(node)
|
227
|
-
@listeners[:on_local_variable_and_write]&.each { |l| T.unsafe(l).on_local_variable_and_write(node) }
|
228
|
-
super
|
229
|
-
end
|
230
|
-
|
231
|
-
sig { override.params(node: YARP::LocalVariableOperatorWriteNode).void }
|
232
|
-
def visit_local_variable_operator_write_node(node)
|
233
|
-
@listeners[:on_local_variable_operator_write]&.each { |l| T.unsafe(l).on_local_variable_operator_write(node) }
|
234
|
-
super
|
235
|
-
end
|
236
|
-
|
237
|
-
sig { override.params(node: YARP::LocalVariableOrWriteNode).void }
|
238
|
-
def visit_local_variable_or_write_node(node)
|
239
|
-
@listeners[:on_local_variable_or_write]&.each { |l| T.unsafe(l).on_local_variable_or_write(node) }
|
240
|
-
super
|
241
|
-
end
|
242
|
-
|
243
|
-
sig { override.params(node: YARP::LocalVariableTargetNode).void }
|
244
|
-
def visit_local_variable_target_node(node)
|
245
|
-
@listeners[:on_local_variable_target]&.each { |l| T.unsafe(l).on_local_variable_target(node) }
|
246
|
-
super
|
247
|
-
end
|
248
|
-
|
249
|
-
sig { override.params(node: YARP::BlockLocalVariableNode).void }
|
250
|
-
def visit_block_local_variable_node(node)
|
251
|
-
@listeners[:on_block_local_variable]&.each { |l| T.unsafe(l).on_block_local_variable(node) }
|
252
|
-
super
|
253
|
-
end
|
254
|
-
|
255
|
-
sig { override.params(node: YARP::IfNode).void }
|
256
|
-
def visit_if_node(node)
|
257
|
-
@listeners[:on_if]&.each { |l| T.unsafe(l).on_if(node) }
|
258
|
-
super
|
259
|
-
end
|
260
|
-
|
261
|
-
sig { override.params(node: YARP::InNode).void }
|
262
|
-
def visit_in_node(node)
|
263
|
-
@listeners[:on_in]&.each { |l| T.unsafe(l).on_in(node) }
|
264
|
-
super
|
265
|
-
end
|
266
|
-
|
267
|
-
sig { override.params(node: YARP::WhenNode).void }
|
268
|
-
def visit_when_node(node)
|
269
|
-
@listeners[:on_when]&.each { |l| T.unsafe(l).on_when(node) }
|
270
|
-
super
|
271
|
-
end
|
272
|
-
|
273
|
-
sig { override.params(node: YARP::InterpolatedStringNode).void }
|
274
|
-
def visit_interpolated_string_node(node)
|
275
|
-
@listeners[:on_interpolated_string]&.each { |l| T.unsafe(l).on_interpolated_string(node) }
|
276
|
-
super
|
277
|
-
end
|
278
|
-
|
279
|
-
sig { override.params(node: YARP::ArrayNode).void }
|
280
|
-
def visit_array_node(node)
|
281
|
-
@listeners[:on_array]&.each { |l| T.unsafe(l).on_array(node) }
|
282
|
-
super
|
283
|
-
end
|
284
|
-
|
285
|
-
sig { override.params(node: YARP::CaseNode).void }
|
286
|
-
def visit_case_node(node)
|
287
|
-
@listeners[:on_case]&.each { |l| T.unsafe(l).on_case(node) }
|
288
|
-
super
|
289
|
-
end
|
290
|
-
|
291
|
-
sig { override.params(node: YARP::ForNode).void }
|
292
|
-
def visit_for_node(node)
|
293
|
-
@listeners[:on_for]&.each { |l| T.unsafe(l).on_for(node) }
|
294
|
-
super
|
295
|
-
end
|
296
|
-
|
297
|
-
sig { override.params(node: YARP::HashNode).void }
|
298
|
-
def visit_hash_node(node)
|
299
|
-
@listeners[:on_hash]&.each { |l| T.unsafe(l).on_hash(node) }
|
300
|
-
super
|
301
|
-
end
|
302
|
-
|
303
|
-
sig { override.params(node: YARP::SingletonClassNode).void }
|
304
|
-
def visit_singleton_class_node(node)
|
305
|
-
@listeners[:on_singleton_class]&.each { |l| T.unsafe(l).on_singleton_class(node) }
|
306
|
-
super
|
307
|
-
end
|
308
|
-
|
309
|
-
sig { override.params(node: YARP::UnlessNode).void }
|
310
|
-
def visit_unless_node(node)
|
311
|
-
@listeners[:on_unless]&.each { |l| T.unsafe(l).on_unless(node) }
|
312
|
-
super
|
313
|
-
end
|
314
|
-
|
315
|
-
sig { override.params(node: YARP::UntilNode).void }
|
316
|
-
def visit_until_node(node)
|
317
|
-
@listeners[:on_until]&.each { |l| T.unsafe(l).on_until(node) }
|
318
|
-
super
|
319
|
-
end
|
320
|
-
|
321
|
-
sig { override.params(node: YARP::WhileNode).void }
|
322
|
-
def visit_while_node(node)
|
323
|
-
@listeners[:on_while]&.each { |l| T.unsafe(l).on_while(node) }
|
324
|
-
super
|
325
|
-
end
|
326
|
-
|
327
|
-
sig { override.params(node: YARP::ElseNode).void }
|
328
|
-
def visit_else_node(node)
|
329
|
-
@listeners[:on_else]&.each { |l| T.unsafe(l).on_else(node) }
|
330
|
-
super
|
331
|
-
end
|
332
|
-
|
333
|
-
sig { override.params(node: YARP::EnsureNode).void }
|
334
|
-
def visit_ensure_node(node)
|
335
|
-
@listeners[:on_ensure]&.each { |l| T.unsafe(l).on_ensure(node) }
|
336
|
-
super
|
337
|
-
end
|
338
|
-
|
339
|
-
sig { override.params(node: YARP::BeginNode).void }
|
340
|
-
def visit_begin_node(node)
|
341
|
-
@listeners[:on_begin]&.each { |l| T.unsafe(l).on_begin(node) }
|
342
|
-
super
|
343
|
-
end
|
344
|
-
|
345
|
-
sig { override.params(node: YARP::StringConcatNode).void }
|
346
|
-
def visit_string_concat_node(node)
|
347
|
-
@listeners[:on_string_concat]&.each { |l| T.unsafe(l).on_string_concat(node) }
|
348
|
-
super
|
349
|
-
end
|
350
|
-
end
|
351
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module RubyLsp
|
5
|
-
module Requests
|
6
|
-
module Support
|
7
|
-
class HighlightTarget
|
8
|
-
extend T::Sig
|
9
|
-
|
10
|
-
READ = Constant::DocumentHighlightKind::READ
|
11
|
-
WRITE = Constant::DocumentHighlightKind::WRITE
|
12
|
-
|
13
|
-
class HighlightMatch
|
14
|
-
extend T::Sig
|
15
|
-
|
16
|
-
sig { returns(Integer) }
|
17
|
-
attr_reader :type
|
18
|
-
|
19
|
-
sig { returns(YARP::Location) }
|
20
|
-
attr_reader :location
|
21
|
-
|
22
|
-
sig { params(type: Integer, location: YARP::Location).void }
|
23
|
-
def initialize(type:, location:)
|
24
|
-
@type = type
|
25
|
-
@location = location
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
sig { params(node: YARP::Node).void }
|
30
|
-
def initialize(node)
|
31
|
-
@node = node
|
32
|
-
@value = T.let(value(node), T.nilable(String))
|
33
|
-
end
|
34
|
-
|
35
|
-
sig { params(other: YARP::Node).returns(T.nilable(HighlightMatch)) }
|
36
|
-
def highlight_type(other)
|
37
|
-
matched_highlight(other) if @value && @value == value(other)
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
# Match the target type (where the cursor is positioned) with the `other` type (the node we're currently
|
43
|
-
# visiting)
|
44
|
-
sig { params(other: YARP::Node).returns(T.nilable(HighlightMatch)) }
|
45
|
-
def matched_highlight(other)
|
46
|
-
case @node
|
47
|
-
# Method definitions and invocations
|
48
|
-
when YARP::CallNode, YARP::DefNode
|
49
|
-
case other
|
50
|
-
when YARP::CallNode
|
51
|
-
HighlightMatch.new(type: READ, location: other.location)
|
52
|
-
when YARP::DefNode
|
53
|
-
HighlightMatch.new(type: WRITE, location: other.name_loc)
|
54
|
-
end
|
55
|
-
# Variables, parameters and constants
|
56
|
-
else
|
57
|
-
case other
|
58
|
-
when YARP::GlobalVariableTargetNode, YARP::InstanceVariableTargetNode, YARP::ConstantPathTargetNode,
|
59
|
-
YARP::ConstantTargetNode, YARP::ClassVariableTargetNode, YARP::LocalVariableTargetNode,
|
60
|
-
YARP::BlockParameterNode, YARP::RequiredParameterNode
|
61
|
-
|
62
|
-
HighlightMatch.new(type: WRITE, location: other.location)
|
63
|
-
when YARP::LocalVariableWriteNode, YARP::KeywordParameterNode, YARP::RestParameterNode,
|
64
|
-
YARP::OptionalParameterNode, YARP::KeywordRestParameterNode, YARP::LocalVariableAndWriteNode,
|
65
|
-
YARP::LocalVariableOperatorWriteNode, YARP::LocalVariableOrWriteNode, YARP::ClassVariableWriteNode,
|
66
|
-
YARP::ClassVariableOrWriteNode, YARP::ClassVariableOperatorWriteNode, YARP::ClassVariableAndWriteNode,
|
67
|
-
YARP::ConstantWriteNode, YARP::ConstantOrWriteNode, YARP::ConstantOperatorWriteNode,
|
68
|
-
YARP::InstanceVariableWriteNode, YARP::ConstantAndWriteNode, YARP::InstanceVariableOrWriteNode,
|
69
|
-
YARP::InstanceVariableAndWriteNode, YARP::InstanceVariableOperatorWriteNode,
|
70
|
-
YARP::GlobalVariableWriteNode, YARP::GlobalVariableOrWriteNode, YARP::GlobalVariableAndWriteNode,
|
71
|
-
YARP::GlobalVariableOperatorWriteNode
|
72
|
-
|
73
|
-
HighlightMatch.new(type: WRITE, location: T.must(other.name_loc)) if other.name
|
74
|
-
when YARP::ConstantPathWriteNode, YARP::ConstantPathOrWriteNode, YARP::ConstantPathAndWriteNode,
|
75
|
-
YARP::ConstantPathOperatorWriteNode
|
76
|
-
|
77
|
-
HighlightMatch.new(type: WRITE, location: other.target.location)
|
78
|
-
when YARP::LocalVariableReadNode, YARP::ConstantPathNode, YARP::ConstantReadNode,
|
79
|
-
YARP::InstanceVariableReadNode, YARP::ClassVariableReadNode, YARP::GlobalVariableReadNode
|
80
|
-
|
81
|
-
HighlightMatch.new(type: READ, location: other.location)
|
82
|
-
when YARP::ClassNode, YARP::ModuleNode
|
83
|
-
HighlightMatch.new(type: WRITE, location: other.constant_path.location)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
sig { params(node: YARP::Node).returns(T.nilable(String)) }
|
89
|
-
def value(node)
|
90
|
-
case node
|
91
|
-
when YARP::ConstantReadNode, YARP::ConstantPathNode, YARP::BlockArgumentNode, YARP::ConstantTargetNode,
|
92
|
-
YARP::ConstantPathWriteNode, YARP::ConstantPathTargetNode, YARP::ConstantPathOrWriteNode,
|
93
|
-
YARP::ConstantPathOperatorWriteNode, YARP::ConstantPathAndWriteNode
|
94
|
-
node.slice
|
95
|
-
when YARP::GlobalVariableReadNode, YARP::GlobalVariableAndWriteNode, YARP::GlobalVariableOperatorWriteNode,
|
96
|
-
YARP::GlobalVariableOrWriteNode, YARP::GlobalVariableTargetNode, YARP::GlobalVariableWriteNode,
|
97
|
-
YARP::InstanceVariableAndWriteNode, YARP::InstanceVariableOperatorWriteNode,
|
98
|
-
YARP::InstanceVariableOrWriteNode, YARP::InstanceVariableReadNode, YARP::InstanceVariableTargetNode,
|
99
|
-
YARP::InstanceVariableWriteNode, YARP::ConstantAndWriteNode, YARP::ConstantOperatorWriteNode,
|
100
|
-
YARP::ConstantOrWriteNode, YARP::ConstantWriteNode, YARP::ClassVariableAndWriteNode,
|
101
|
-
YARP::ClassVariableOperatorWriteNode, YARP::ClassVariableOrWriteNode, YARP::ClassVariableReadNode,
|
102
|
-
YARP::ClassVariableTargetNode, YARP::ClassVariableWriteNode, YARP::LocalVariableAndWriteNode,
|
103
|
-
YARP::LocalVariableOperatorWriteNode, YARP::LocalVariableOrWriteNode, YARP::LocalVariableReadNode,
|
104
|
-
YARP::LocalVariableTargetNode, YARP::LocalVariableWriteNode, YARP::DefNode, YARP::BlockParameterNode,
|
105
|
-
YARP::KeywordParameterNode, YARP::KeywordRestParameterNode, YARP::OptionalParameterNode,
|
106
|
-
YARP::RequiredParameterNode, YARP::RestParameterNode
|
107
|
-
|
108
|
-
node.name.to_s
|
109
|
-
when YARP::CallNode
|
110
|
-
node.message
|
111
|
-
when YARP::ClassNode, YARP::ModuleNode
|
112
|
-
node.constant_path.slice
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|