ruby-lsp 0.10.1 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/VERSION +1 -1
- data/exe/ruby-lsp-check +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +40 -5
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +141 -5
- data/lib/ruby_indexer/lib/ruby_indexer/visitor.rb +66 -18
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +23 -0
- data/lib/ruby_indexer/test/configuration_test.rb +2 -0
- data/lib/ruby_indexer/test/constant_test.rb +202 -0
- data/lib/ruby_indexer/test/index_test.rb +20 -0
- data/lib/ruby_lsp/{extension.rb → addon.rb} +27 -25
- data/lib/ruby_lsp/check_docs.rb +7 -8
- data/lib/ruby_lsp/document.rb +35 -38
- data/lib/ruby_lsp/event_emitter.rb +239 -77
- data/lib/ruby_lsp/executor.rb +45 -55
- data/lib/ruby_lsp/internal.rb +2 -3
- data/lib/ruby_lsp/listener.rb +8 -7
- data/lib/ruby_lsp/parameter_scope.rb +33 -0
- data/lib/ruby_lsp/requests/base_request.rb +3 -3
- data/lib/ruby_lsp/requests/code_action_resolve.rb +14 -14
- data/lib/ruby_lsp/requests/code_lens.rb +39 -63
- data/lib/ruby_lsp/requests/completion.rb +54 -32
- data/lib/ruby_lsp/requests/definition.rb +30 -27
- data/lib/ruby_lsp/requests/diagnostics.rb +26 -3
- data/lib/ruby_lsp/requests/document_highlight.rb +18 -19
- data/lib/ruby_lsp/requests/document_link.rb +50 -9
- data/lib/ruby_lsp/requests/document_symbol.rb +82 -75
- data/lib/ruby_lsp/requests/folding_ranges.rb +199 -222
- data/lib/ruby_lsp/requests/formatting.rb +5 -6
- data/lib/ruby_lsp/requests/hover.rb +33 -22
- data/lib/ruby_lsp/requests/inlay_hints.rb +2 -3
- data/lib/ruby_lsp/requests/selection_ranges.rb +65 -40
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +187 -145
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +3 -4
- data/lib/ruby_lsp/requests/support/annotation.rb +18 -17
- data/lib/ruby_lsp/requests/support/common.rb +17 -26
- data/lib/ruby_lsp/requests/support/dependency_detector.rb +67 -42
- data/lib/ruby_lsp/requests/support/highlight_target.rb +64 -45
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +9 -4
- data/lib/ruby_lsp/requests/support/selection_range.rb +5 -4
- data/lib/ruby_lsp/requests/support/sorbet.rb +2 -57
- data/lib/ruby_lsp/requests/support/syntax_tree_formatting_runner.rb +7 -1
- data/lib/ruby_lsp/requests/workspace_symbol.rb +4 -1
- data/lib/ruby_lsp/server.rb +6 -44
- data/lib/ruby_lsp/utils.rb +2 -12
- metadata +11 -30
@@ -15,288 +15,265 @@ module RubyLsp
|
|
15
15
|
# puts "Hello"
|
16
16
|
# end # <-- folding range end
|
17
17
|
# ```
|
18
|
-
class FoldingRanges <
|
18
|
+
class FoldingRanges < Listener
|
19
19
|
extend T::Sig
|
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
|
-
SyntaxTree::In,
|
58
|
-
SyntaxTree::Rescue,
|
59
|
-
SyntaxTree::When,
|
20
|
+
extend T::Generic
|
21
|
+
|
22
|
+
ResponseType = type_member { { fixed: T::Array[Interface::FoldingRange] } }
|
23
|
+
|
24
|
+
sig { params(comments: T::Array[YARP::Comment], emitter: EventEmitter, queue: Thread::Queue).void }
|
25
|
+
def initialize(comments, emitter, queue)
|
26
|
+
super(emitter, queue)
|
27
|
+
|
28
|
+
@_response = T.let([], ResponseType)
|
29
|
+
@requires = T.let([], T::Array[YARP::CallNode])
|
30
|
+
@finalized_response = T.let(false, T::Boolean)
|
31
|
+
@comments = comments
|
32
|
+
|
33
|
+
emitter.register(
|
34
|
+
self,
|
35
|
+
:on_if,
|
36
|
+
:on_in,
|
37
|
+
:on_rescue,
|
38
|
+
:on_when,
|
39
|
+
:on_interpolated_string,
|
40
|
+
:on_array,
|
41
|
+
:on_block,
|
42
|
+
:on_case,
|
43
|
+
:on_class,
|
44
|
+
:on_module,
|
45
|
+
:on_for,
|
46
|
+
:on_hash,
|
47
|
+
:on_singleton_class,
|
48
|
+
:on_unless,
|
49
|
+
:on_until,
|
50
|
+
:on_while,
|
51
|
+
:on_else,
|
52
|
+
:on_ensure,
|
53
|
+
:on_begin,
|
54
|
+
:on_string_concat,
|
55
|
+
:on_def,
|
56
|
+
:on_call,
|
60
57
|
)
|
61
58
|
end
|
62
59
|
|
63
|
-
sig {
|
64
|
-
def
|
65
|
-
|
60
|
+
sig { override.returns(ResponseType) }
|
61
|
+
def _response
|
62
|
+
unless @finalized_response
|
63
|
+
push_comment_ranges
|
64
|
+
emit_requires_range
|
65
|
+
@finalized_response = true
|
66
|
+
end
|
66
67
|
|
67
|
-
@
|
68
|
-
@partial_range = T.let(nil, T.nilable(PartialRange))
|
68
|
+
@_response
|
69
69
|
end
|
70
70
|
|
71
|
-
sig {
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
emit_partial_range
|
76
|
-
end
|
71
|
+
sig { params(node: YARP::IfNode).void }
|
72
|
+
def on_if(node)
|
73
|
+
add_statements_range(node)
|
74
|
+
end
|
77
75
|
|
78
|
-
|
76
|
+
sig { params(node: YARP::InNode).void }
|
77
|
+
def on_in(node)
|
78
|
+
add_statements_range(node)
|
79
79
|
end
|
80
80
|
|
81
|
-
|
81
|
+
sig { params(node: YARP::RescueNode).void }
|
82
|
+
def on_rescue(node)
|
83
|
+
add_statements_range(node)
|
84
|
+
end
|
82
85
|
|
83
|
-
sig {
|
84
|
-
def
|
85
|
-
|
86
|
+
sig { params(node: YARP::WhenNode).void }
|
87
|
+
def on_when(node)
|
88
|
+
add_statements_range(node)
|
89
|
+
end
|
86
90
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
when *NODES_WITH_STATEMENTS
|
92
|
-
add_statements_range(T.must(node), T.cast(node, StatementNode).statements)
|
93
|
-
when SyntaxTree::CallNode, SyntaxTree::CommandCall
|
94
|
-
# If there is a receiver, it may be a chained invocation,
|
95
|
-
# so we need to process it in special way.
|
96
|
-
if node.receiver.nil?
|
97
|
-
location = node.location
|
98
|
-
add_lines_range(location.start_line, location.end_line - 1)
|
99
|
-
else
|
100
|
-
add_call_range(node)
|
101
|
-
return
|
102
|
-
end
|
103
|
-
when SyntaxTree::Command
|
104
|
-
unless same_lines_for_command_and_block?(node)
|
105
|
-
location = node.location
|
106
|
-
add_lines_range(location.start_line, location.end_line - 1)
|
107
|
-
end
|
108
|
-
when SyntaxTree::DefNode
|
109
|
-
add_def_range(node)
|
110
|
-
when SyntaxTree::StringConcat
|
111
|
-
add_string_concat(node)
|
112
|
-
return
|
113
|
-
end
|
91
|
+
sig { params(node: YARP::InterpolatedStringNode).void }
|
92
|
+
def on_interpolated_string(node)
|
93
|
+
opening_loc = node.opening_loc
|
94
|
+
closing_loc = node.closing_loc
|
114
95
|
|
115
|
-
|
96
|
+
add_lines_range(opening_loc.start_line, closing_loc.end_line - 1) if opening_loc && closing_loc
|
116
97
|
end
|
117
98
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
return false unless node_block
|
99
|
+
sig { params(node: YARP::ArrayNode).void }
|
100
|
+
def on_array(node)
|
101
|
+
add_simple_range(node)
|
102
|
+
end
|
123
103
|
|
124
|
-
|
125
|
-
|
126
|
-
|
104
|
+
sig { params(node: YARP::BlockNode).void }
|
105
|
+
def on_block(node)
|
106
|
+
add_simple_range(node)
|
127
107
|
end
|
128
108
|
|
129
|
-
|
130
|
-
|
109
|
+
sig { params(node: YARP::CaseNode).void }
|
110
|
+
def on_case(node)
|
111
|
+
add_simple_range(node)
|
112
|
+
end
|
131
113
|
|
132
|
-
|
133
|
-
|
114
|
+
sig { params(node: YARP::ClassNode).void }
|
115
|
+
def on_class(node)
|
116
|
+
add_simple_range(node)
|
117
|
+
end
|
134
118
|
|
135
|
-
|
136
|
-
|
119
|
+
sig { params(node: YARP::ModuleNode).void }
|
120
|
+
def on_module(node)
|
121
|
+
add_simple_range(node)
|
122
|
+
end
|
137
123
|
|
138
|
-
|
139
|
-
|
124
|
+
sig { params(node: YARP::ForNode).void }
|
125
|
+
def on_for(node)
|
126
|
+
add_simple_range(node)
|
127
|
+
end
|
140
128
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
end
|
129
|
+
sig { params(node: YARP::HashNode).void }
|
130
|
+
def on_hash(node)
|
131
|
+
add_simple_range(node)
|
132
|
+
end
|
146
133
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
@kind = kind
|
152
|
-
end
|
134
|
+
sig { params(node: YARP::SingletonClassNode).void }
|
135
|
+
def on_singleton_class(node)
|
136
|
+
add_simple_range(node)
|
137
|
+
end
|
153
138
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
end
|
139
|
+
sig { params(node: YARP::UnlessNode).void }
|
140
|
+
def on_unless(node)
|
141
|
+
add_simple_range(node)
|
142
|
+
end
|
159
143
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
144
|
+
sig { params(node: YARP::UntilNode).void }
|
145
|
+
def on_until(node)
|
146
|
+
add_simple_range(node)
|
147
|
+
end
|
164
148
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
end_line: @end_line,
|
170
|
-
kind: @kind,
|
171
|
-
)
|
172
|
-
end
|
149
|
+
sig { params(node: YARP::WhileNode).void }
|
150
|
+
def on_while(node)
|
151
|
+
add_simple_range(node)
|
152
|
+
end
|
173
153
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
end
|
154
|
+
sig { params(node: YARP::ElseNode).void }
|
155
|
+
def on_else(node)
|
156
|
+
add_simple_range(node)
|
178
157
|
end
|
179
158
|
|
180
|
-
sig { params(node:
|
181
|
-
def
|
182
|
-
|
159
|
+
sig { params(node: YARP::EnsureNode).void }
|
160
|
+
def on_ensure(node)
|
161
|
+
add_simple_range(node)
|
162
|
+
end
|
183
163
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
164
|
+
sig { params(node: YARP::BeginNode).void }
|
165
|
+
def on_begin(node)
|
166
|
+
add_simple_range(node)
|
167
|
+
end
|
188
168
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
emit_partial_range
|
194
|
-
PartialRange.from(target_node, kind)
|
195
|
-
else
|
196
|
-
@partial_range.extend_to(target_node)
|
197
|
-
end
|
169
|
+
sig { params(node: YARP::Node).void }
|
170
|
+
def on_node(node)
|
171
|
+
emit_requires_range unless node.is_a?(YARP::CallNode)
|
172
|
+
end
|
198
173
|
|
199
|
-
|
174
|
+
sig { params(node: YARP::StringConcatNode).void }
|
175
|
+
def on_string_concat(node)
|
176
|
+
left = T.let(node.left, YARP::Node)
|
177
|
+
left = left.left while left.is_a?(YARP::StringConcatNode)
|
178
|
+
|
179
|
+
add_lines_range(left.location.start_line, node.right.location.end_line - 1)
|
200
180
|
end
|
201
181
|
|
202
|
-
sig { params(node:
|
203
|
-
def
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
182
|
+
sig { params(node: YARP::DefNode).void }
|
183
|
+
def on_def(node)
|
184
|
+
params = node.parameters
|
185
|
+
parameter_loc = params&.location
|
186
|
+
location = node.location
|
187
|
+
|
188
|
+
if params && parameter_loc.end_line > location.start_line
|
189
|
+
# Multiline parameters
|
190
|
+
add_lines_range(location.start_line, parameter_loc.end_line)
|
191
|
+
add_lines_range(parameter_loc.end_line + 1, location.end_line - 1)
|
192
|
+
else
|
193
|
+
add_lines_range(location.start_line, location.end_line - 1)
|
211
194
|
end
|
212
195
|
end
|
213
196
|
|
214
|
-
sig { void }
|
215
|
-
def
|
216
|
-
|
197
|
+
sig { params(node: YARP::CallNode).void }
|
198
|
+
def on_call(node)
|
199
|
+
# If we find a require, don't visit the child nodes (prevent `super`), so that we can keep accumulating into
|
200
|
+
# the `@requires` array and then push the range whenever we find a node that isn't a CallNode
|
201
|
+
if require?(node)
|
202
|
+
@requires << node
|
203
|
+
return
|
204
|
+
end
|
217
205
|
|
218
|
-
|
219
|
-
|
206
|
+
location = node.location
|
207
|
+
add_lines_range(location.start_line, location.end_line - 1)
|
220
208
|
end
|
221
209
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
end
|
238
|
-
else
|
239
|
-
break
|
240
|
-
end
|
210
|
+
private
|
211
|
+
|
212
|
+
sig { void }
|
213
|
+
def push_comment_ranges
|
214
|
+
# Group comments that are on consecutive lines and then push ranges for each group that has at least 2 comments
|
215
|
+
@comments.chunk_while do |this, other|
|
216
|
+
this.location.end_line + 1 == other.location.start_line
|
217
|
+
end.each do |chunk|
|
218
|
+
next if chunk.length == 1
|
219
|
+
|
220
|
+
@_response << Interface::FoldingRange.new(
|
221
|
+
start_line: T.must(chunk.first).location.start_line - 1,
|
222
|
+
end_line: T.must(chunk.last).location.end_line - 1,
|
223
|
+
kind: "comment",
|
224
|
+
)
|
241
225
|
end
|
226
|
+
end
|
242
227
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
)
|
249
|
-
|
228
|
+
sig { void }
|
229
|
+
def emit_requires_range
|
230
|
+
if @requires.length > 1
|
231
|
+
@_response << Interface::FoldingRange.new(
|
232
|
+
start_line: T.must(@requires.first).location.start_line - 1,
|
233
|
+
end_line: T.must(@requires.last).location.end_line - 1,
|
234
|
+
kind: "imports",
|
235
|
+
)
|
250
236
|
end
|
251
237
|
|
252
|
-
|
253
|
-
visit(node.block) if node.is_a?(SyntaxTree::CommandCall)
|
238
|
+
@requires.clear
|
254
239
|
end
|
255
240
|
|
256
|
-
sig { params(node:
|
257
|
-
def
|
258
|
-
|
259
|
-
|
260
|
-
params = node.params
|
261
|
-
return unless params
|
241
|
+
sig { params(node: YARP::CallNode).returns(T::Boolean) }
|
242
|
+
def require?(node)
|
243
|
+
message = node.message
|
244
|
+
return false unless message == "require" || message == "require_relative"
|
262
245
|
|
263
|
-
|
246
|
+
receiver = node.receiver
|
247
|
+
return false unless receiver.nil? || receiver.slice == "Kernel"
|
264
248
|
|
265
|
-
|
266
|
-
|
267
|
-
else
|
268
|
-
location = node.location
|
269
|
-
add_lines_range(location.start_line, location.end_line - 1)
|
270
|
-
end
|
249
|
+
arguments = node.arguments&.arguments
|
250
|
+
return false unless arguments
|
271
251
|
|
272
|
-
|
273
|
-
if bodystmt.is_a?(SyntaxTree::BodyStmt)
|
274
|
-
visit(bodystmt.statements)
|
275
|
-
else
|
276
|
-
visit(bodystmt)
|
277
|
-
end
|
252
|
+
arguments.length == 1 && arguments.first.is_a?(YARP::StringNode)
|
278
253
|
end
|
279
254
|
|
280
|
-
sig { params(node:
|
281
|
-
def add_statements_range(node
|
282
|
-
|
255
|
+
sig { params(node: T.any(YARP::IfNode, YARP::InNode, YARP::RescueNode, YARP::WhenNode)).void }
|
256
|
+
def add_statements_range(node)
|
257
|
+
statements = node.statements
|
258
|
+
return unless statements
|
283
259
|
|
284
|
-
|
285
|
-
|
260
|
+
body = statements.body
|
261
|
+
return if body.empty?
|
286
262
|
|
287
|
-
|
288
|
-
|
289
|
-
left = T.let(node.left, SyntaxTree::Node)
|
290
|
-
left = left.left while left.is_a?(SyntaxTree::StringConcat)
|
263
|
+
add_lines_range(node.location.start_line, T.must(body.last).location.end_line)
|
264
|
+
end
|
291
265
|
|
292
|
-
|
266
|
+
sig { params(node: YARP::Node).void }
|
267
|
+
def add_simple_range(node)
|
268
|
+
location = node.location
|
269
|
+
add_lines_range(location.start_line, location.end_line - 1)
|
293
270
|
end
|
294
271
|
|
295
272
|
sig { params(start_line: Integer, end_line: Integer).void }
|
296
273
|
def add_lines_range(start_line, end_line)
|
297
274
|
return if start_line >= end_line
|
298
275
|
|
299
|
-
@
|
276
|
+
@_response << Interface::FoldingRange.new(
|
300
277
|
start_line: start_line - 1,
|
301
278
|
end_line: end_line - 1,
|
302
279
|
kind: "region",
|
@@ -29,12 +29,7 @@ module RubyLsp
|
|
29
29
|
class Error < StandardError; end
|
30
30
|
class InvalidFormatter < StandardError; end
|
31
31
|
|
32
|
-
@formatters = T.let(
|
33
|
-
{
|
34
|
-
"syntax_tree" => Support::SyntaxTreeFormattingRunner.instance,
|
35
|
-
},
|
36
|
-
T::Hash[String, Support::FormatterRunner],
|
37
|
-
)
|
32
|
+
@formatters = T.let({}, T::Hash[String, Support::FormatterRunner])
|
38
33
|
|
39
34
|
class << self
|
40
35
|
extend T::Sig
|
@@ -52,6 +47,10 @@ module RubyLsp
|
|
52
47
|
register_formatter("rubocop", Support::RuboCopFormattingRunner.instance)
|
53
48
|
end
|
54
49
|
|
50
|
+
if defined?(Support::SyntaxTreeFormattingRunner)
|
51
|
+
register_formatter("syntax_tree", Support::SyntaxTreeFormattingRunner.instance)
|
52
|
+
end
|
53
|
+
|
55
54
|
extend T::Sig
|
56
55
|
|
57
56
|
sig { params(document: Document, formatter: String).void }
|
@@ -21,12 +21,12 @@ module RubyLsp
|
|
21
21
|
|
22
22
|
ALLOWED_TARGETS = T.let(
|
23
23
|
[
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
YARP::CallNode,
|
25
|
+
YARP::ConstantReadNode,
|
26
|
+
YARP::ConstantWriteNode,
|
27
|
+
YARP::ConstantPathNode,
|
28
28
|
],
|
29
|
-
T::Array[T.class_of(
|
29
|
+
T::Array[T.class_of(YARP::Node)],
|
30
30
|
)
|
31
31
|
|
32
32
|
sig { override.returns(ResponseType) }
|
@@ -41,17 +41,17 @@ module RubyLsp
|
|
41
41
|
).void
|
42
42
|
end
|
43
43
|
def initialize(index, nesting, emitter, message_queue)
|
44
|
-
@nesting = nesting
|
45
44
|
@index = index
|
45
|
+
@nesting = nesting
|
46
46
|
@_response = T.let(nil, ResponseType)
|
47
47
|
|
48
48
|
super(emitter, message_queue)
|
49
|
-
emitter.register(self, :
|
49
|
+
emitter.register(self, :on_constant_read, :on_constant_write, :on_constant_path)
|
50
50
|
end
|
51
51
|
|
52
|
-
sig { override.params(
|
53
|
-
def initialize_external_listener(
|
54
|
-
|
52
|
+
sig { override.params(addon: Addon).returns(T.nilable(Listener[ResponseType])) }
|
53
|
+
def initialize_external_listener(addon)
|
54
|
+
addon.create_hover_listener(@nesting, @index, @emitter, @message_queue)
|
55
55
|
end
|
56
56
|
|
57
57
|
# Merges responses from other hover listeners
|
@@ -69,30 +69,41 @@ module RubyLsp
|
|
69
69
|
self
|
70
70
|
end
|
71
71
|
|
72
|
-
sig { params(node:
|
73
|
-
def
|
74
|
-
return if DependencyDetector
|
72
|
+
sig { params(node: YARP::ConstantReadNode).void }
|
73
|
+
def on_constant_read(node)
|
74
|
+
return if DependencyDetector.instance.typechecker
|
75
|
+
|
76
|
+
generate_hover(node.slice, node.location)
|
77
|
+
end
|
78
|
+
|
79
|
+
sig { params(node: YARP::ConstantWriteNode).void }
|
80
|
+
def on_constant_write(node)
|
81
|
+
return if DependencyDetector.instance.typechecker
|
75
82
|
|
76
|
-
name
|
77
|
-
generate_hover(name, node)
|
83
|
+
generate_hover(node.name.to_s, node.name_loc)
|
78
84
|
end
|
79
85
|
|
80
|
-
sig { params(node:
|
81
|
-
def
|
82
|
-
return if DependencyDetector
|
86
|
+
sig { params(node: YARP::ConstantPathNode).void }
|
87
|
+
def on_constant_path(node)
|
88
|
+
return if DependencyDetector.instance.typechecker
|
83
89
|
|
84
|
-
generate_hover(node.
|
90
|
+
generate_hover(node.slice, node.location)
|
85
91
|
end
|
86
92
|
|
87
93
|
private
|
88
94
|
|
89
|
-
sig { params(name: String,
|
90
|
-
def generate_hover(name,
|
95
|
+
sig { params(name: String, location: YARP::Location).void }
|
96
|
+
def generate_hover(name, location)
|
91
97
|
entries = @index.resolve(name, @nesting)
|
92
98
|
return unless entries
|
93
99
|
|
100
|
+
# We should only show hover for private constants if the constant is defined in the same namespace as the
|
101
|
+
# reference
|
102
|
+
first_entry = T.must(entries.first)
|
103
|
+
return if first_entry.visibility == :private && first_entry.name != "#{@nesting.join("::")}::#{name}"
|
104
|
+
|
94
105
|
@_response = Interface::Hover.new(
|
95
|
-
range:
|
106
|
+
range: range_from_location(location),
|
96
107
|
contents: markdown_from_index_entries(name, entries),
|
97
108
|
)
|
98
109
|
end
|
@@ -39,10 +39,9 @@ module RubyLsp
|
|
39
39
|
emitter.register(self, :on_rescue)
|
40
40
|
end
|
41
41
|
|
42
|
-
sig { params(node:
|
42
|
+
sig { params(node: YARP::RescueNode).void }
|
43
43
|
def on_rescue(node)
|
44
|
-
|
45
|
-
return unless exception.nil? || exception.exceptions.nil?
|
44
|
+
return unless node.exceptions.empty?
|
46
45
|
|
47
46
|
loc = node.location
|
48
47
|
return unless visible?(node, @range)
|