ruby-lsp 0.13.1 → 0.13.2
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/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +30 -1
- data/lib/ruby_lsp/document.rb +3 -7
- data/lib/ruby_lsp/executor.rb +59 -11
- data/lib/ruby_lsp/requests/code_action_resolve.rb +1 -1
- data/lib/ruby_lsp/requests/code_actions.rb +2 -2
- data/lib/ruby_lsp/requests/completion.rb +1 -3
- data/lib/ruby_lsp/requests/on_type_formatting.rb +2 -2
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +1 -1
- data/lib/ruby_lsp/requests/signature_help.rb +95 -0
- data/lib/ruby_lsp/requests/support/selection_range.rb +1 -1
- data/lib/ruby_lsp/requests.rb +2 -0
- data/lib/ruby_lsp/store.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2329129b74c75a0bb4113d1f1489463f666b74ef495d0ac65bad675fbd83d1d3
|
4
|
+
data.tar.gz: 2f31f495b9ca0b1a9f909758dabce816411d0b64a006577c93c7a80a253791e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c3ab34cb3e7877105ca21df3f521589d9838bd15e77a3d17cc4df91ca1f93221ef845e514a902a03a63a1f82ad6b5cf90fa4f9a93037fbfb57af5f7a48b0ebe
|
7
|
+
data.tar.gz: d4867c86eb238abf039f40592d7ff48acd85749fcf9349ab72fdea218ff5201156fc0d511987ed768b1fb2dcc9fd55a76bfac611f3fc565b7b2ba8c8d1054a72
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.13.
|
1
|
+
0.13.2
|
@@ -193,7 +193,7 @@ module RubyIndexer
|
|
193
193
|
# When working on a gem, we need to make sure that its gemspec dependencies can't be excluded. This is necessary
|
194
194
|
# because Bundler doesn't assign groups to gemspec dependencies
|
195
195
|
this_gem = Bundler.definition.dependencies.find do |d|
|
196
|
-
d.to_spec
|
196
|
+
d.to_spec&.full_gem_path == Dir.pwd
|
197
197
|
rescue Gem::MissingSpecError
|
198
198
|
false
|
199
199
|
end
|
@@ -81,9 +81,13 @@ module RubyIndexer
|
|
81
81
|
|
82
82
|
abstract!
|
83
83
|
|
84
|
+
# Name includes just the name of the parameter, excluding symbols like splats
|
84
85
|
sig { returns(Symbol) }
|
85
86
|
attr_reader :name
|
86
87
|
|
88
|
+
# Decorated name is the parameter name including the splat or block prefix, e.g.: `*foo`, `**foo` or `&block`
|
89
|
+
alias_method :decorated_name, :name
|
90
|
+
|
87
91
|
sig { params(name: Symbol).void }
|
88
92
|
def initialize(name:)
|
89
93
|
@name = name
|
@@ -100,25 +104,48 @@ module RubyIndexer
|
|
100
104
|
|
101
105
|
# An required keyword method parameter, e.g. `def foo(a:)`
|
102
106
|
class KeywordParameter < Parameter
|
107
|
+
sig { override.returns(Symbol) }
|
108
|
+
def decorated_name
|
109
|
+
:"#{@name}:"
|
110
|
+
end
|
103
111
|
end
|
104
112
|
|
105
113
|
# An optional keyword method parameter, e.g. `def foo(a: 123)`
|
106
114
|
class OptionalKeywordParameter < Parameter
|
115
|
+
sig { override.returns(Symbol) }
|
116
|
+
def decorated_name
|
117
|
+
:"#{@name}:"
|
118
|
+
end
|
107
119
|
end
|
108
120
|
|
109
121
|
# A rest method parameter, e.g. `def foo(*a)`
|
110
122
|
class RestParameter < Parameter
|
111
123
|
DEFAULT_NAME = T.let(:"<anonymous splat>", Symbol)
|
124
|
+
|
125
|
+
sig { override.returns(Symbol) }
|
126
|
+
def decorated_name
|
127
|
+
:"*#{@name}"
|
128
|
+
end
|
112
129
|
end
|
113
130
|
|
114
131
|
# A keyword rest method parameter, e.g. `def foo(**a)`
|
115
132
|
class KeywordRestParameter < Parameter
|
116
133
|
DEFAULT_NAME = T.let(:"<anonymous keyword splat>", Symbol)
|
134
|
+
|
135
|
+
sig { override.returns(Symbol) }
|
136
|
+
def decorated_name
|
137
|
+
:"**#{@name}"
|
138
|
+
end
|
117
139
|
end
|
118
140
|
|
119
141
|
# A block method parameter, e.g. `def foo(&block)`
|
120
142
|
class BlockParameter < Parameter
|
121
143
|
DEFAULT_NAME = T.let(:"<anonymous block>", Symbol)
|
144
|
+
|
145
|
+
sig { override.returns(Symbol) }
|
146
|
+
def decorated_name
|
147
|
+
:"&#{@name}"
|
148
|
+
end
|
122
149
|
end
|
123
150
|
|
124
151
|
class Member < Entry
|
@@ -220,7 +247,7 @@ module RubyIndexer
|
|
220
247
|
|
221
248
|
rest = parameters_node.rest
|
222
249
|
|
223
|
-
if rest
|
250
|
+
if rest.is_a?(Prism::RestParameterNode)
|
224
251
|
rest_name = rest.name || RestParameter::DEFAULT_NAME
|
225
252
|
parameters << RestParameter.new(name: rest_name)
|
226
253
|
end
|
@@ -261,6 +288,8 @@ module RubyIndexer
|
|
261
288
|
names << (rest.operator == "*" ? "*#{name}".to_sym : name&.to_sym)
|
262
289
|
end
|
263
290
|
|
291
|
+
names << nil if rest.is_a?(Prism::ImplicitRestNode)
|
292
|
+
|
264
293
|
names.concat(node.rights.map { |parameter_node| parameter_name(parameter_node) })
|
265
294
|
|
266
295
|
names_with_commas = names.join(", ")
|
data/lib/ruby_lsp/document.rb
CHANGED
@@ -8,10 +8,6 @@ module RubyLsp
|
|
8
8
|
|
9
9
|
abstract!
|
10
10
|
|
11
|
-
PositionShape = T.type_alias { { line: Integer, character: Integer } }
|
12
|
-
RangeShape = T.type_alias { { start: PositionShape, end: PositionShape } }
|
13
|
-
EditShape = T.type_alias { { range: RangeShape, text: String } }
|
14
|
-
|
15
11
|
sig { returns(Prism::ParseResult) }
|
16
12
|
attr_reader :parse_result
|
17
13
|
|
@@ -80,7 +76,7 @@ module RubyLsp
|
|
80
76
|
@cache[request_name]
|
81
77
|
end
|
82
78
|
|
83
|
-
sig { params(edits: T::Array[
|
79
|
+
sig { params(edits: T::Array[T::Hash[Symbol, T.untyped]], version: Integer).void }
|
84
80
|
def push_edits(edits, version:)
|
85
81
|
edits.each do |edit|
|
86
82
|
range = edit[:range]
|
@@ -112,7 +108,7 @@ module RubyLsp
|
|
112
108
|
|
113
109
|
sig do
|
114
110
|
params(
|
115
|
-
position:
|
111
|
+
position: T::Hash[Symbol, T.untyped],
|
116
112
|
node_types: T::Array[T.class_of(Prism::Node)],
|
117
113
|
).returns([T.nilable(Prism::Node), T.nilable(Prism::Node), T::Array[String]])
|
118
114
|
end
|
@@ -193,7 +189,7 @@ module RubyLsp
|
|
193
189
|
end
|
194
190
|
|
195
191
|
# Finds the character index inside the source string for a given line and column
|
196
|
-
sig { params(position:
|
192
|
+
sig { params(position: T::Hash[Symbol, T.untyped]).returns(Integer) }
|
197
193
|
def find_char_position(position)
|
198
194
|
# Find the character index for the beginning of the requested line
|
199
195
|
until @current_line == position[:line]
|
data/lib/ruby_lsp/executor.rb
CHANGED
@@ -25,6 +25,7 @@ module RubyLsp
|
|
25
25
|
begin
|
26
26
|
response = run(request)
|
27
27
|
rescue StandardError, LoadError => e
|
28
|
+
warn(e.message)
|
28
29
|
error = e
|
29
30
|
end
|
30
31
|
|
@@ -171,6 +172,8 @@ module RubyLsp
|
|
171
172
|
completion(uri, request.dig(:params, :position))
|
172
173
|
when "textDocument/definition"
|
173
174
|
definition(uri, request.dig(:params, :position))
|
175
|
+
when "textDocument/signatureHelp"
|
176
|
+
signature_help(uri, request.dig(:params, :position), request.dig(:params, :context))
|
174
177
|
when "workspace/didChangeWatchedFiles"
|
175
178
|
did_change_watched_files(request.dig(:params, :changes))
|
176
179
|
when "workspace/symbol"
|
@@ -240,12 +243,44 @@ module RubyLsp
|
|
240
243
|
end
|
241
244
|
end
|
242
245
|
|
246
|
+
sig do
|
247
|
+
params(
|
248
|
+
uri: URI::Generic,
|
249
|
+
position: T::Hash[Symbol, T.untyped],
|
250
|
+
context: T::Hash[Symbol, T.untyped],
|
251
|
+
).returns(T.any(T.nilable(Interface::SignatureHelp), T::Hash[Symbol, T.untyped]))
|
252
|
+
end
|
253
|
+
def signature_help(uri, position, context)
|
254
|
+
current_signature = context[:activeSignatureHelp]
|
255
|
+
document = @store.get(uri)
|
256
|
+
target, parent, nesting = document.locate_node(
|
257
|
+
{ line: position[:line], character: position[:character] - 2 },
|
258
|
+
node_types: [Prism::CallNode],
|
259
|
+
)
|
260
|
+
|
261
|
+
# If we're typing a nested method call (e.g.: `foo(bar)`), then we may end up locating `bar` as the target method
|
262
|
+
# call incorrectly. To correct that, we check if there's an active signature with the same name as the parent node
|
263
|
+
# and then replace the target
|
264
|
+
if current_signature && parent.is_a?(Prism::CallNode)
|
265
|
+
active_signature = current_signature[:activeSignature] || 0
|
266
|
+
|
267
|
+
if current_signature.dig(:signatures, active_signature, :label)&.start_with?(parent.message)
|
268
|
+
target = parent
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
dispatcher = Prism::Dispatcher.new
|
273
|
+
listener = Requests::SignatureHelp.new(context, nesting, @index, dispatcher)
|
274
|
+
dispatcher.dispatch_once(target)
|
275
|
+
listener.response
|
276
|
+
end
|
277
|
+
|
243
278
|
sig { params(query: T.nilable(String)).returns(T::Array[Interface::WorkspaceSymbol]) }
|
244
279
|
def workspace_symbol(query)
|
245
280
|
Requests::WorkspaceSymbol.new(query, @index).run
|
246
281
|
end
|
247
282
|
|
248
|
-
sig { params(uri: URI::Generic, range: T.nilable(
|
283
|
+
sig { params(uri: URI::Generic, range: T.nilable(T::Hash[Symbol, T.untyped])).returns({ ast: String }) }
|
249
284
|
def show_syntax_tree(uri, range)
|
250
285
|
{ ast: Requests::ShowSyntaxTree.new(@store.get(uri), range).run }
|
251
286
|
end
|
@@ -253,7 +288,7 @@ module RubyLsp
|
|
253
288
|
sig do
|
254
289
|
params(
|
255
290
|
uri: URI::Generic,
|
256
|
-
position:
|
291
|
+
position: T::Hash[Symbol, T.untyped],
|
257
292
|
).returns(T.nilable(T.any(T::Array[Interface::Location], Interface::Location)))
|
258
293
|
end
|
259
294
|
def definition(uri, position)
|
@@ -274,7 +309,7 @@ module RubyLsp
|
|
274
309
|
sig do
|
275
310
|
params(
|
276
311
|
uri: URI::Generic,
|
277
|
-
position:
|
312
|
+
position: T::Hash[Symbol, T.untyped],
|
278
313
|
).returns(T.nilable(Interface::Hover))
|
279
314
|
end
|
280
315
|
def hover(uri, position)
|
@@ -301,7 +336,7 @@ module RubyLsp
|
|
301
336
|
end
|
302
337
|
|
303
338
|
sig do
|
304
|
-
params(uri: URI::Generic, content_changes: T::Array[
|
339
|
+
params(uri: URI::Generic, content_changes: T::Array[T::Hash[Symbol, T.untyped]], version: Integer).returns(Object)
|
305
340
|
end
|
306
341
|
def text_document_did_change(uri, content_changes, version)
|
307
342
|
@store.push_edits(uri: uri, edits: content_changes, version: version)
|
@@ -323,7 +358,7 @@ module RubyLsp
|
|
323
358
|
sig do
|
324
359
|
params(
|
325
360
|
uri: URI::Generic,
|
326
|
-
positions: T::Array[
|
361
|
+
positions: T::Array[T::Hash[Symbol, T.untyped]],
|
327
362
|
).returns(T.nilable(T::Array[T.nilable(Requests::Support::SelectionRange)]))
|
328
363
|
end
|
329
364
|
def selection_range(uri, positions)
|
@@ -361,7 +396,7 @@ module RubyLsp
|
|
361
396
|
sig do
|
362
397
|
params(
|
363
398
|
uri: URI::Generic,
|
364
|
-
position:
|
399
|
+
position: T::Hash[Symbol, T.untyped],
|
365
400
|
character: String,
|
366
401
|
).returns(T::Array[Interface::TextEdit])
|
367
402
|
end
|
@@ -372,7 +407,7 @@ module RubyLsp
|
|
372
407
|
sig do
|
373
408
|
params(
|
374
409
|
uri: URI::Generic,
|
375
|
-
position:
|
410
|
+
position: T::Hash[Symbol, T.untyped],
|
376
411
|
).returns(T.nilable(T::Array[Interface::DocumentHighlight]))
|
377
412
|
end
|
378
413
|
def document_highlight(uri, position)
|
@@ -385,7 +420,12 @@ module RubyLsp
|
|
385
420
|
listener.response
|
386
421
|
end
|
387
422
|
|
388
|
-
sig
|
423
|
+
sig do
|
424
|
+
params(
|
425
|
+
uri: URI::Generic,
|
426
|
+
range: T::Hash[Symbol, T.untyped],
|
427
|
+
).returns(T.nilable(T::Array[Interface::InlayHint]))
|
428
|
+
end
|
389
429
|
def inlay_hint(uri, range)
|
390
430
|
document = @store.get(uri)
|
391
431
|
|
@@ -402,7 +442,7 @@ module RubyLsp
|
|
402
442
|
sig do
|
403
443
|
params(
|
404
444
|
uri: URI::Generic,
|
405
|
-
range:
|
445
|
+
range: T::Hash[Symbol, T.untyped],
|
406
446
|
context: T::Hash[Symbol, T.untyped],
|
407
447
|
).returns(T.nilable(T::Array[Interface::CodeAction]))
|
408
448
|
end
|
@@ -456,7 +496,7 @@ module RubyLsp
|
|
456
496
|
Interface::FullDocumentDiagnosticReport.new(kind: "full", items: response) if response
|
457
497
|
end
|
458
498
|
|
459
|
-
sig { params(uri: URI::Generic, range:
|
499
|
+
sig { params(uri: URI::Generic, range: T::Hash[Symbol, T.untyped]).returns(Interface::SemanticTokens) }
|
460
500
|
def semantic_tokens_range(uri, range)
|
461
501
|
document = @store.get(uri)
|
462
502
|
start_line = range.dig(:start, :line)
|
@@ -472,7 +512,7 @@ module RubyLsp
|
|
472
512
|
sig do
|
473
513
|
params(
|
474
514
|
uri: URI::Generic,
|
475
|
-
position:
|
515
|
+
position: T::Hash[Symbol, T.untyped],
|
476
516
|
).returns(T.nilable(T::Array[Interface::CompletionItem]))
|
477
517
|
end
|
478
518
|
def completion(uri, position)
|
@@ -692,6 +732,13 @@ module RubyLsp
|
|
692
732
|
)
|
693
733
|
end
|
694
734
|
|
735
|
+
signature_help_provider = if enabled_features["signatureHelp"]
|
736
|
+
# Identifier characters are automatically included, such as A-Z, a-z, 0-9, _, * or :
|
737
|
+
Interface::SignatureHelpOptions.new(
|
738
|
+
trigger_characters: ["(", " ", ","],
|
739
|
+
)
|
740
|
+
end
|
741
|
+
|
695
742
|
# Dynamically registered capabilities
|
696
743
|
file_watching_caps = options.dig(:capabilities, :workspace, :didChangeWatchedFiles)
|
697
744
|
|
@@ -744,6 +791,7 @@ module RubyLsp
|
|
744
791
|
code_lens_provider: code_lens_provider,
|
745
792
|
definition_provider: enabled_features["definition"],
|
746
793
|
workspace_symbol_provider: enabled_features["workspaceSymbol"],
|
794
|
+
signature_help_provider: signature_help_provider,
|
747
795
|
),
|
748
796
|
serverInfo: {
|
749
797
|
name: "Ruby LSP",
|
@@ -137,7 +137,7 @@ module RubyLsp
|
|
137
137
|
|
138
138
|
private
|
139
139
|
|
140
|
-
sig { params(range:
|
140
|
+
sig { params(range: T::Hash[Symbol, T.untyped], new_text: String).returns(Interface::TextEdit) }
|
141
141
|
def create_text_edit(range, new_text)
|
142
142
|
Interface::TextEdit.new(
|
143
143
|
range: Interface::Range.new(
|
@@ -22,7 +22,7 @@ module RubyLsp
|
|
22
22
|
sig do
|
23
23
|
params(
|
24
24
|
document: Document,
|
25
|
-
range:
|
25
|
+
range: T::Hash[Symbol, T.untyped],
|
26
26
|
context: T::Hash[Symbol, T.untyped],
|
27
27
|
).void
|
28
28
|
end
|
@@ -49,7 +49,7 @@ module RubyLsp
|
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
-
sig { params(range:
|
52
|
+
sig { params(range: T::Hash[Symbol, T.untyped], uri: URI::Generic).returns(Interface::CodeAction) }
|
53
53
|
def refactor_code_action(range, uri)
|
54
54
|
Interface::CodeAction.new(
|
55
55
|
title: "Refactor: Extract Variable",
|
@@ -154,13 +154,11 @@ module RubyLsp
|
|
154
154
|
end
|
155
155
|
def build_method_completion(entry, node)
|
156
156
|
name = entry.name
|
157
|
-
parameters = entry.parameters
|
158
|
-
new_text = parameters.empty? ? name : "#{name}(#{parameters.map(&:name).join(", ")})"
|
159
157
|
|
160
158
|
Interface::CompletionItem.new(
|
161
159
|
label: name,
|
162
160
|
filter_text: name,
|
163
|
-
text_edit: Interface::TextEdit.new(range: range_from_node(node), new_text:
|
161
|
+
text_edit: Interface::TextEdit.new(range: range_from_node(node), new_text: name),
|
164
162
|
kind: Constant::CompletionItemKind::METHOD,
|
165
163
|
label_details: Interface::CompletionItemLabelDetails.new(
|
166
164
|
description: entry.file_name,
|
@@ -26,7 +26,7 @@ module RubyLsp
|
|
26
26
|
T::Array[Regexp],
|
27
27
|
)
|
28
28
|
|
29
|
-
sig { params(document: Document, position:
|
29
|
+
sig { params(document: Document, position: T::Hash[Symbol, T.untyped], trigger_character: String).void }
|
30
30
|
def initialize(document, position, trigger_character)
|
31
31
|
super(document)
|
32
32
|
|
@@ -143,7 +143,7 @@ module RubyLsp
|
|
143
143
|
add_edit_with_text("##{spaces}")
|
144
144
|
end
|
145
145
|
|
146
|
-
sig { params(text: String, position:
|
146
|
+
sig { params(text: String, position: T::Hash[Symbol, T.untyped]).void }
|
147
147
|
def add_edit_with_text(text, position = @position)
|
148
148
|
pos = Interface::Position.new(
|
149
149
|
line: position[:line],
|
@@ -20,7 +20,7 @@ module RubyLsp
|
|
20
20
|
class ShowSyntaxTree < BaseRequest
|
21
21
|
extend T::Sig
|
22
22
|
|
23
|
-
sig { params(document: Document, range: T.nilable(
|
23
|
+
sig { params(document: Document, range: T.nilable(T::Hash[Symbol, T.untyped])).void }
|
24
24
|
def initialize(document, range)
|
25
25
|
super(document)
|
26
26
|
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module RubyLsp
|
5
|
+
module Requests
|
6
|
+
# ![Signature help demo](../../signature_help.gif)
|
7
|
+
#
|
8
|
+
# The [signature help
|
9
|
+
# request](https://microsoft.github.io/language-server-protocol/specification#textDocument_signatureHelp) displays
|
10
|
+
# information about the parameters of a method as you type an invocation.
|
11
|
+
#
|
12
|
+
# Currently only supports methods invoked directly on `self` without taking inheritance into account.
|
13
|
+
#
|
14
|
+
# # Example
|
15
|
+
#
|
16
|
+
# ```ruby
|
17
|
+
# class Foo
|
18
|
+
# def bar(a, b, c)
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# def baz
|
22
|
+
# bar( # -> Signature help will show the parameters of `bar`
|
23
|
+
# end
|
24
|
+
# ```
|
25
|
+
class SignatureHelp < Listener
|
26
|
+
extend T::Sig
|
27
|
+
extend T::Generic
|
28
|
+
|
29
|
+
ResponseType = type_member { { fixed: T.nilable(T.any(Interface::SignatureHelp, T::Hash[Symbol, T.untyped])) } }
|
30
|
+
|
31
|
+
sig { override.returns(ResponseType) }
|
32
|
+
attr_reader :_response
|
33
|
+
|
34
|
+
sig do
|
35
|
+
params(
|
36
|
+
context: T::Hash[Symbol, T.untyped],
|
37
|
+
nesting: T::Array[String],
|
38
|
+
index: RubyIndexer::Index,
|
39
|
+
dispatcher: Prism::Dispatcher,
|
40
|
+
).void
|
41
|
+
end
|
42
|
+
def initialize(context, nesting, index, dispatcher)
|
43
|
+
@context = context
|
44
|
+
@nesting = nesting
|
45
|
+
@index = index
|
46
|
+
@_response = T.let(nil, ResponseType)
|
47
|
+
|
48
|
+
super(dispatcher)
|
49
|
+
dispatcher.register(self, :on_call_node_enter)
|
50
|
+
end
|
51
|
+
|
52
|
+
sig { params(node: Prism::CallNode).void }
|
53
|
+
def on_call_node_enter(node)
|
54
|
+
return if DependencyDetector.instance.typechecker
|
55
|
+
return unless self_receiver?(node)
|
56
|
+
|
57
|
+
message = node.message
|
58
|
+
return unless message
|
59
|
+
|
60
|
+
target_method = @index.resolve_method(message, @nesting.join("::"))
|
61
|
+
return unless target_method
|
62
|
+
|
63
|
+
parameters = target_method.parameters
|
64
|
+
name = target_method.name
|
65
|
+
|
66
|
+
# If the method doesn't have any parameters, there's no need to show signature help
|
67
|
+
return if parameters.empty?
|
68
|
+
|
69
|
+
label = "#{name}(#{parameters.map(&:decorated_name).join(", ")})"
|
70
|
+
|
71
|
+
arguments_node = node.arguments
|
72
|
+
arguments = arguments_node&.arguments || []
|
73
|
+
active_parameter = (arguments.length - 1).clamp(0, parameters.length - 1)
|
74
|
+
|
75
|
+
# If there are arguments, then we need to check if there's a trailing comma after the end of the last argument
|
76
|
+
# to advance the active parameter to the next one
|
77
|
+
if arguments_node &&
|
78
|
+
node.slice.byteslice(arguments_node.location.end_offset - node.location.start_offset) == ","
|
79
|
+
active_parameter += 1
|
80
|
+
end
|
81
|
+
|
82
|
+
@_response = Interface::SignatureHelp.new(
|
83
|
+
signatures: [
|
84
|
+
Interface::SignatureInformation.new(
|
85
|
+
label: label,
|
86
|
+
parameters: parameters.map { |param| Interface::ParameterInformation.new(label: param.name) },
|
87
|
+
documentation: markdown_from_index_entries("", target_method),
|
88
|
+
),
|
89
|
+
],
|
90
|
+
active_parameter: active_parameter,
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -7,7 +7,7 @@ module RubyLsp
|
|
7
7
|
class SelectionRange < Interface::SelectionRange
|
8
8
|
extend T::Sig
|
9
9
|
|
10
|
-
sig { params(position:
|
10
|
+
sig { params(position: T::Hash[Symbol, T.untyped]).returns(T::Boolean) }
|
11
11
|
def cover?(position)
|
12
12
|
start_covered = range.start.line < position[:line] ||
|
13
13
|
(range.start.line == position[:line] && range.start.character <= position[:character])
|
data/lib/ruby_lsp/requests.rb
CHANGED
@@ -22,6 +22,7 @@ module RubyLsp
|
|
22
22
|
# - [Definition](rdoc-ref:RubyLsp::Requests::Definition)
|
23
23
|
# - [ShowSyntaxTree](rdoc-ref:RubyLsp::Requests::ShowSyntaxTree)
|
24
24
|
# - [WorkspaceSymbol](rdoc-ref:RubyLsp::Requests::WorkspaceSymbol)
|
25
|
+
# - [SignatureHelp](rdoc-ref:RubyLsp::Requests::SignatureHelp)
|
25
26
|
|
26
27
|
module Requests
|
27
28
|
autoload :BaseRequest, "ruby_lsp/requests/base_request"
|
@@ -43,6 +44,7 @@ module RubyLsp
|
|
43
44
|
autoload :Definition, "ruby_lsp/requests/definition"
|
44
45
|
autoload :ShowSyntaxTree, "ruby_lsp/requests/show_syntax_tree"
|
45
46
|
autoload :WorkspaceSymbol, "ruby_lsp/requests/workspace_symbol"
|
47
|
+
autoload :SignatureHelp, "ruby_lsp/requests/signature_help"
|
46
48
|
|
47
49
|
# :nodoc:
|
48
50
|
module Support
|
data/lib/ruby_lsp/store.rb
CHANGED
@@ -63,7 +63,7 @@ module RubyLsp
|
|
63
63
|
@state[uri.to_s] = document
|
64
64
|
end
|
65
65
|
|
66
|
-
sig { params(uri: URI::Generic, edits: T::Array[
|
66
|
+
sig { params(uri: URI::Generic, edits: T::Array[T::Hash[Symbol, T.untyped]], version: Integer).void }
|
67
67
|
def push_edits(uri:, edits:, version:)
|
68
68
|
T.must(@state[uri.to_s]).push_edits(edits, version: version)
|
69
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lsp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: language_server-protocol
|
@@ -30,20 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.19.0
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '0.
|
36
|
+
version: '0.20'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
43
|
+
version: 0.19.0
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.20'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sorbet-runtime
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/ruby_lsp/requests/selection_ranges.rb
|
119
119
|
- lib/ruby_lsp/requests/semantic_highlighting.rb
|
120
120
|
- lib/ruby_lsp/requests/show_syntax_tree.rb
|
121
|
+
- lib/ruby_lsp/requests/signature_help.rb
|
121
122
|
- lib/ruby_lsp/requests/support/annotation.rb
|
122
123
|
- lib/ruby_lsp/requests/support/common.rb
|
123
124
|
- lib/ruby_lsp/requests/support/dependency_detector.rb
|