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