ruby-lsp 0.17.12 → 0.17.14
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/VERSION +1 -1
- data/exe/ruby-lsp +6 -4
- data/exe/ruby-lsp-check +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +6 -1
- data/lib/ruby_indexer/ruby_indexer.rb +0 -8
- data/lib/ruby_indexer/test/configuration_test.rb +1 -1
- data/lib/ruby_lsp/addon.rb +9 -4
- data/lib/ruby_lsp/base_server.rb +7 -2
- data/lib/ruby_lsp/document.rb +9 -178
- data/lib/ruby_lsp/erb_document.rb +16 -2
- data/lib/ruby_lsp/global_state.rb +34 -14
- data/lib/ruby_lsp/internal.rb +1 -0
- data/lib/ruby_lsp/listeners/completion.rb +5 -5
- data/lib/ruby_lsp/listeners/definition.rb +3 -3
- data/lib/ruby_lsp/listeners/hover.rb +5 -5
- data/lib/ruby_lsp/listeners/signature_help.rb +1 -1
- data/lib/ruby_lsp/rbs_document.rb +41 -0
- data/lib/ruby_lsp/requests/code_action_resolve.rb +37 -21
- data/lib/ruby_lsp/requests/code_actions.rb +3 -3
- data/lib/ruby_lsp/requests/completion.rb +3 -3
- data/lib/ruby_lsp/requests/definition.rb +2 -2
- data/lib/ruby_lsp/requests/diagnostics.rb +1 -1
- data/lib/ruby_lsp/requests/document_highlight.rb +1 -1
- data/lib/ruby_lsp/requests/formatting.rb +1 -1
- data/lib/ruby_lsp/requests/hover.rb +2 -2
- data/lib/ruby_lsp/requests/inlay_hints.rb +1 -1
- data/lib/ruby_lsp/requests/on_type_formatting.rb +1 -1
- data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +1 -1
- data/lib/ruby_lsp/requests/selection_ranges.rb +2 -1
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +1 -1
- data/lib/ruby_lsp/requests/signature_help.rb +2 -2
- data/lib/ruby_lsp/requests/support/common.rb +2 -2
- data/lib/ruby_lsp/requests/support/formatter.rb +2 -2
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +1 -1
- data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +2 -2
- data/lib/ruby_lsp/requests/support/syntax_tree_formatter.rb +2 -2
- data/lib/ruby_lsp/ruby_document.rb +183 -1
- data/lib/ruby_lsp/server.rb +125 -15
- data/lib/ruby_lsp/setup_bundler.rb +15 -4
- data/lib/ruby_lsp/store.rb +10 -6
- data/lib/ruby_lsp/utils.rb +12 -0
- metadata +4 -3
data/lib/ruby_lsp/server.rb
CHANGED
@@ -19,10 +19,10 @@ module RubyLsp
|
|
19
19
|
def process_message(message)
|
20
20
|
case message[:method]
|
21
21
|
when "initialize"
|
22
|
-
|
22
|
+
send_log_message("Initializing Ruby LSP v#{VERSION}...")
|
23
23
|
run_initialize(message)
|
24
24
|
when "initialized"
|
25
|
-
|
25
|
+
send_log_message("Finished initializing Ruby LSP!") unless @test_mode
|
26
26
|
run_initialized
|
27
27
|
when "textDocument/didOpen"
|
28
28
|
text_document_did_open(message)
|
@@ -121,12 +121,20 @@ module RubyLsp
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
|
124
|
+
send_log_message("Error processing #{message[:method]}: #{e.full_message}", type: Constant::MessageType::ERROR)
|
125
125
|
end
|
126
126
|
|
127
127
|
sig { void }
|
128
128
|
def load_addons
|
129
|
-
Addon.load_addons(@global_state, @outgoing_queue)
|
129
|
+
errors = Addon.load_addons(@global_state, @outgoing_queue)
|
130
|
+
|
131
|
+
if errors.any?
|
132
|
+
send_log_message(
|
133
|
+
"Error loading addons:\n\n#{errors.map(&:full_message).join("\n\n")}",
|
134
|
+
type: Constant::MessageType::WARNING,
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
130
138
|
errored_addons = Addon.addons.select(&:error?)
|
131
139
|
|
132
140
|
if errored_addons.any?
|
@@ -140,7 +148,12 @@ module RubyLsp
|
|
140
148
|
),
|
141
149
|
)
|
142
150
|
|
143
|
-
|
151
|
+
unless @test_mode
|
152
|
+
send_log_message(
|
153
|
+
errored_addons.map(&:errors_details).join("\n\n"),
|
154
|
+
type: Constant::MessageType::WARNING,
|
155
|
+
)
|
156
|
+
end
|
144
157
|
end
|
145
158
|
end
|
146
159
|
|
@@ -149,7 +162,7 @@ module RubyLsp
|
|
149
162
|
sig { params(message: T::Hash[Symbol, T.untyped]).void }
|
150
163
|
def run_initialize(message)
|
151
164
|
options = message[:params]
|
152
|
-
@global_state.apply_options(options)
|
165
|
+
global_state_notifications = @global_state.apply_options(options)
|
153
166
|
|
154
167
|
client_name = options.dig(:clientInfo, :name)
|
155
168
|
@store.client_name = client_name if client_name
|
@@ -258,6 +271,8 @@ module RubyLsp
|
|
258
271
|
process_indexing_configuration(options.dig(:initializationOptions, :indexing))
|
259
272
|
|
260
273
|
begin_progress("indexing-progress", "Ruby LSP: indexing files")
|
274
|
+
|
275
|
+
global_state_notifications.each { |notification| send_message(notification) }
|
261
276
|
end
|
262
277
|
|
263
278
|
sig { void }
|
@@ -281,11 +296,14 @@ module RubyLsp
|
|
281
296
|
@mutex.synchronize do
|
282
297
|
text_document = message.dig(:params, :textDocument)
|
283
298
|
language_id = case text_document[:languageId]
|
284
|
-
when "erb"
|
299
|
+
when "erb", "eruby"
|
285
300
|
Document::LanguageId::ERB
|
301
|
+
when "rbs"
|
302
|
+
Document::LanguageId::RBS
|
286
303
|
else
|
287
304
|
Document::LanguageId::Ruby
|
288
305
|
end
|
306
|
+
|
289
307
|
@store.set(
|
290
308
|
uri: text_document[:uri],
|
291
309
|
source: text_document[:text],
|
@@ -326,7 +344,12 @@ module RubyLsp
|
|
326
344
|
def text_document_selection_range(message)
|
327
345
|
uri = message.dig(:params, :textDocument, :uri)
|
328
346
|
ranges = @store.cache_fetch(uri, "textDocument/selectionRange") do |document|
|
329
|
-
|
347
|
+
case document
|
348
|
+
when RubyDocument, ERBDocument
|
349
|
+
Requests::SelectionRanges.new(document).perform
|
350
|
+
else
|
351
|
+
[]
|
352
|
+
end
|
330
353
|
end
|
331
354
|
|
332
355
|
# Per the selection range request spec (https://microsoft.github.io/language-server-protocol/specification#textDocument_selectionRange),
|
@@ -348,6 +371,11 @@ module RubyLsp
|
|
348
371
|
uri = URI(message.dig(:params, :textDocument, :uri))
|
349
372
|
document = @store.get(uri)
|
350
373
|
|
374
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
375
|
+
send_empty_response(message[:id])
|
376
|
+
return
|
377
|
+
end
|
378
|
+
|
351
379
|
# If the response has already been cached by another request, return it
|
352
380
|
cached_response = document.cache_get(message[:method])
|
353
381
|
if cached_response
|
@@ -392,6 +420,12 @@ module RubyLsp
|
|
392
420
|
range = params[:range]
|
393
421
|
uri = params.dig(:textDocument, :uri)
|
394
422
|
document = @store.get(uri)
|
423
|
+
|
424
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
425
|
+
send_empty_response(message[:id])
|
426
|
+
return
|
427
|
+
end
|
428
|
+
|
395
429
|
start_line = range.dig(:start, :line)
|
396
430
|
end_line = range.dig(:end, :line)
|
397
431
|
|
@@ -421,6 +455,10 @@ module RubyLsp
|
|
421
455
|
end
|
422
456
|
|
423
457
|
document = @store.get(uri)
|
458
|
+
unless document.is_a?(RubyDocument)
|
459
|
+
send_empty_response(message[:id])
|
460
|
+
return
|
461
|
+
end
|
424
462
|
|
425
463
|
response = Requests::Formatting.new(@global_state, document).perform
|
426
464
|
send_message(Result.new(id: message[:id], response: response))
|
@@ -437,6 +475,12 @@ module RubyLsp
|
|
437
475
|
params = message[:params]
|
438
476
|
dispatcher = Prism::Dispatcher.new
|
439
477
|
document = @store.get(params.dig(:textDocument, :uri))
|
478
|
+
|
479
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
480
|
+
send_empty_response(message[:id])
|
481
|
+
return
|
482
|
+
end
|
483
|
+
|
440
484
|
request = Requests::DocumentHighlight.new(document, params[:position], dispatcher)
|
441
485
|
dispatcher.dispatch(document.parse_result.value)
|
442
486
|
send_message(Result.new(id: message[:id], response: request.perform))
|
@@ -447,6 +491,11 @@ module RubyLsp
|
|
447
491
|
params = message[:params]
|
448
492
|
document = @store.get(params.dig(:textDocument, :uri))
|
449
493
|
|
494
|
+
unless document.is_a?(RubyDocument)
|
495
|
+
send_empty_response(message[:id])
|
496
|
+
return
|
497
|
+
end
|
498
|
+
|
450
499
|
send_message(
|
451
500
|
Result.new(
|
452
501
|
id: message[:id],
|
@@ -466,6 +515,11 @@ module RubyLsp
|
|
466
515
|
dispatcher = Prism::Dispatcher.new
|
467
516
|
document = @store.get(params.dig(:textDocument, :uri))
|
468
517
|
|
518
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
519
|
+
send_empty_response(message[:id])
|
520
|
+
return
|
521
|
+
end
|
522
|
+
|
469
523
|
send_message(
|
470
524
|
Result.new(
|
471
525
|
id: message[:id],
|
@@ -480,9 +534,10 @@ module RubyLsp
|
|
480
534
|
)
|
481
535
|
end
|
482
536
|
|
483
|
-
sig { params(document: Document).returns(
|
537
|
+
sig { params(document: Document[T.untyped]).returns(RubyDocument::SorbetLevel) }
|
484
538
|
def sorbet_level(document)
|
485
|
-
return
|
539
|
+
return RubyDocument::SorbetLevel::Ignore unless @global_state.has_type_checker
|
540
|
+
return RubyDocument::SorbetLevel::Ignore unless document.is_a?(RubyDocument)
|
486
541
|
|
487
542
|
document.sorbet_level
|
488
543
|
end
|
@@ -493,6 +548,12 @@ module RubyLsp
|
|
493
548
|
hints_configurations = T.must(@store.features_configuration.dig(:inlayHint))
|
494
549
|
dispatcher = Prism::Dispatcher.new
|
495
550
|
document = @store.get(params.dig(:textDocument, :uri))
|
551
|
+
|
552
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
553
|
+
send_empty_response(message[:id])
|
554
|
+
return
|
555
|
+
end
|
556
|
+
|
496
557
|
request = Requests::InlayHints.new(document, params[:range], hints_configurations, dispatcher)
|
497
558
|
dispatcher.visit(document.parse_result.value)
|
498
559
|
send_message(Result.new(id: message[:id], response: request.perform))
|
@@ -503,6 +564,11 @@ module RubyLsp
|
|
503
564
|
params = message[:params]
|
504
565
|
document = @store.get(params.dig(:textDocument, :uri))
|
505
566
|
|
567
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
568
|
+
send_empty_response(message[:id])
|
569
|
+
return
|
570
|
+
end
|
571
|
+
|
506
572
|
send_message(
|
507
573
|
Result.new(
|
508
574
|
id: message[:id],
|
@@ -520,6 +586,12 @@ module RubyLsp
|
|
520
586
|
params = message[:params]
|
521
587
|
uri = URI(params.dig(:data, :uri))
|
522
588
|
document = @store.get(uri)
|
589
|
+
|
590
|
+
unless document.is_a?(RubyDocument)
|
591
|
+
send_message(Notification.window_show_error("Code actions are currently only available for Ruby documents"))
|
592
|
+
raise Requests::CodeActionResolve::CodeActionError
|
593
|
+
end
|
594
|
+
|
523
595
|
result = Requests::CodeActionResolve.new(document, params).perform
|
524
596
|
|
525
597
|
case result
|
@@ -559,7 +631,10 @@ module RubyLsp
|
|
559
631
|
document = @store.get(uri)
|
560
632
|
|
561
633
|
response = document.cache_fetch("textDocument/diagnostic") do |document|
|
562
|
-
|
634
|
+
case document
|
635
|
+
when RubyDocument
|
636
|
+
Requests::Diagnostics.new(@global_state, document).perform
|
637
|
+
end
|
563
638
|
end
|
564
639
|
|
565
640
|
send_message(
|
@@ -582,6 +657,11 @@ module RubyLsp
|
|
582
657
|
dispatcher = Prism::Dispatcher.new
|
583
658
|
document = @store.get(params.dig(:textDocument, :uri))
|
584
659
|
|
660
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
661
|
+
send_empty_response(message[:id])
|
662
|
+
return
|
663
|
+
end
|
664
|
+
|
585
665
|
send_message(
|
586
666
|
Result.new(
|
587
667
|
id: message[:id],
|
@@ -610,6 +690,11 @@ module RubyLsp
|
|
610
690
|
dispatcher = Prism::Dispatcher.new
|
611
691
|
document = @store.get(params.dig(:textDocument, :uri))
|
612
692
|
|
693
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
694
|
+
send_empty_response(message[:id])
|
695
|
+
return
|
696
|
+
end
|
697
|
+
|
613
698
|
send_message(
|
614
699
|
Result.new(
|
615
700
|
id: message[:id],
|
@@ -631,6 +716,11 @@ module RubyLsp
|
|
631
716
|
dispatcher = Prism::Dispatcher.new
|
632
717
|
document = @store.get(params.dig(:textDocument, :uri))
|
633
718
|
|
719
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
720
|
+
send_empty_response(message[:id])
|
721
|
+
return
|
722
|
+
end
|
723
|
+
|
634
724
|
send_message(
|
635
725
|
Result.new(
|
636
726
|
id: message[:id],
|
@@ -688,9 +778,16 @@ module RubyLsp
|
|
688
778
|
sig { params(message: T::Hash[Symbol, T.untyped]).void }
|
689
779
|
def text_document_show_syntax_tree(message)
|
690
780
|
params = message[:params]
|
781
|
+
document = @store.get(params.dig(:textDocument, :uri))
|
782
|
+
|
783
|
+
unless document.is_a?(RubyDocument)
|
784
|
+
send_empty_response(message[:id])
|
785
|
+
return
|
786
|
+
end
|
787
|
+
|
691
788
|
response = {
|
692
789
|
ast: Requests::ShowSyntaxTree.new(
|
693
|
-
|
790
|
+
document,
|
694
791
|
params[:range],
|
695
792
|
).perform,
|
696
793
|
}
|
@@ -700,11 +797,19 @@ module RubyLsp
|
|
700
797
|
sig { params(message: T::Hash[Symbol, T.untyped]).void }
|
701
798
|
def text_document_prepare_type_hierarchy(message)
|
702
799
|
params = message[:params]
|
800
|
+
document = @store.get(params.dig(:textDocument, :uri))
|
801
|
+
|
802
|
+
unless document.is_a?(RubyDocument) || document.is_a?(ERBDocument)
|
803
|
+
send_empty_response(message[:id])
|
804
|
+
return
|
805
|
+
end
|
806
|
+
|
703
807
|
response = Requests::PrepareTypeHierarchy.new(
|
704
|
-
|
808
|
+
document,
|
705
809
|
@global_state.index,
|
706
810
|
params[:position],
|
707
811
|
).perform
|
812
|
+
|
708
813
|
send_message(Result.new(id: message[:id], response: response))
|
709
814
|
end
|
710
815
|
|
@@ -771,6 +876,11 @@ module RubyLsp
|
|
771
876
|
send_message(Notification.window_show_error("Error while indexing: #{error.message}"))
|
772
877
|
end
|
773
878
|
|
879
|
+
# Indexing produces a high number of short lived object allocations. That might lead to some fragmentation and
|
880
|
+
# an unnecessarily expanded heap. Compacting ensures that the heap is as small as possible and that future
|
881
|
+
# allocations and garbage collections are faster
|
882
|
+
GC.compact
|
883
|
+
|
774
884
|
# Always end the progress notification even if indexing failed or else it never goes away and the user has no
|
775
885
|
# way of dismissing it
|
776
886
|
end_progress("indexing-progress")
|
@@ -862,7 +972,7 @@ module RubyLsp
|
|
862
972
|
|
863
973
|
if File.exist?(index_path)
|
864
974
|
begin
|
865
|
-
|
975
|
+
@global_state.index.configuration.apply_config(YAML.parse_file(index_path).to_ruby)
|
866
976
|
send_message(
|
867
977
|
Notification.new(
|
868
978
|
method: "window/showMessage",
|
@@ -891,7 +1001,7 @@ module RubyLsp
|
|
891
1001
|
return unless indexing_options
|
892
1002
|
|
893
1003
|
# The index expects snake case configurations, but VS Code standardizes on camel case settings
|
894
|
-
|
1004
|
+
@global_state.index.configuration.apply_config(
|
895
1005
|
indexing_options.transform_keys { |key| key.to_s.gsub(/([A-Z])/, "_\\1").downcase },
|
896
1006
|
)
|
897
1007
|
end
|
@@ -50,6 +50,7 @@ module RubyLsp
|
|
50
50
|
@last_updated_path = T.let(@custom_dir + "last_updated", Pathname)
|
51
51
|
|
52
52
|
@dependencies = T.let(load_dependencies, T::Hash[String, T.untyped])
|
53
|
+
@rails_app = T.let(rails_app?, T::Boolean)
|
53
54
|
@retry = T.let(false, T::Boolean)
|
54
55
|
end
|
55
56
|
|
@@ -62,7 +63,7 @@ module RubyLsp
|
|
62
63
|
# Do not set up a custom bundle if LSP dependencies are already in the Gemfile
|
63
64
|
if @dependencies["ruby-lsp"] &&
|
64
65
|
@dependencies["debug"] &&
|
65
|
-
(@
|
66
|
+
(@rails_app ? @dependencies["ruby-lsp-rails"] : true)
|
66
67
|
$stderr.puts(
|
67
68
|
"Ruby LSP> Skipping custom bundle setup since LSP dependencies are already in #{@gemfile}",
|
68
69
|
)
|
@@ -148,7 +149,7 @@ module RubyLsp
|
|
148
149
|
parts << 'gem "debug", require: false, group: :development, platforms: :mri'
|
149
150
|
end
|
150
151
|
|
151
|
-
if @
|
152
|
+
if @rails_app && !@dependencies["ruby-lsp-rails"]
|
152
153
|
parts << 'gem "ruby-lsp-rails", require: false, group: :development'
|
153
154
|
end
|
154
155
|
|
@@ -209,7 +210,7 @@ module RubyLsp
|
|
209
210
|
command << " && bundle update "
|
210
211
|
command << "ruby-lsp " unless @dependencies["ruby-lsp"]
|
211
212
|
command << "debug " unless @dependencies["debug"]
|
212
|
-
command << "ruby-lsp-rails " if @
|
213
|
+
command << "ruby-lsp-rails " if @rails_app && !@dependencies["ruby-lsp-rails"]
|
213
214
|
command << "--pre" if @experimental
|
214
215
|
command.delete_suffix!(" ")
|
215
216
|
command << ")"
|
@@ -244,7 +245,7 @@ module RubyLsp
|
|
244
245
|
def should_bundle_update?
|
245
246
|
# If `ruby-lsp`, `ruby-lsp-rails` and `debug` are in the Gemfile, then we shouldn't try to upgrade them or else it
|
246
247
|
# will produce version control changes
|
247
|
-
if @
|
248
|
+
if @rails_app
|
248
249
|
return false if @dependencies.values_at("ruby-lsp", "ruby-lsp-rails", "debug").all?
|
249
250
|
|
250
251
|
# If the custom lockfile doesn't include `ruby-lsp`, `ruby-lsp-rails` or `debug`, we need to run bundle install
|
@@ -280,5 +281,15 @@ module RubyLsp
|
|
280
281
|
|
281
282
|
@custom_lockfile.write(content)
|
282
283
|
end
|
284
|
+
|
285
|
+
# Detects if the project is a Rails app by looking if the superclass of the main class is `Rails::Application`
|
286
|
+
sig { returns(T::Boolean) }
|
287
|
+
def rails_app?
|
288
|
+
config = Pathname.new("config/application.rb").expand_path
|
289
|
+
application_contents = config.read if config.exist?
|
290
|
+
return false unless application_contents
|
291
|
+
|
292
|
+
/class .* < (::)?Rails::Application/.match?(application_contents)
|
293
|
+
end
|
283
294
|
end
|
284
295
|
end
|
data/lib/ruby_lsp/store.rb
CHANGED
@@ -18,7 +18,7 @@ module RubyLsp
|
|
18
18
|
|
19
19
|
sig { void }
|
20
20
|
def initialize
|
21
|
-
@state = T.let({}, T::Hash[String, Document])
|
21
|
+
@state = T.let({}, T::Hash[String, Document[T.untyped]])
|
22
22
|
@supports_progress = T.let(true, T::Boolean)
|
23
23
|
@features_configuration = T.let(
|
24
24
|
{
|
@@ -33,7 +33,7 @@ module RubyLsp
|
|
33
33
|
@client_name = T.let("Unknown", String)
|
34
34
|
end
|
35
35
|
|
36
|
-
sig { params(uri: URI::Generic).returns(Document) }
|
36
|
+
sig { params(uri: URI::Generic).returns(Document[T.untyped]) }
|
37
37
|
def get(uri)
|
38
38
|
document = @state[uri.to_s]
|
39
39
|
return document unless document.nil?
|
@@ -44,8 +44,11 @@ module RubyLsp
|
|
44
44
|
raise NonExistingDocumentError, uri.to_s unless path
|
45
45
|
|
46
46
|
ext = File.extname(path)
|
47
|
-
language_id =
|
47
|
+
language_id = case ext
|
48
|
+
when ".erb", ".rhtml"
|
48
49
|
Document::LanguageId::ERB
|
50
|
+
when ".rbs"
|
51
|
+
Document::LanguageId::RBS
|
49
52
|
else
|
50
53
|
Document::LanguageId::Ruby
|
51
54
|
end
|
@@ -66,13 +69,14 @@ module RubyLsp
|
|
66
69
|
).void
|
67
70
|
end
|
68
71
|
def set(uri:, source:, version:, language_id:, encoding: Encoding::UTF_8)
|
69
|
-
|
72
|
+
@state[uri.to_s] = case language_id
|
70
73
|
when Document::LanguageId::ERB
|
71
74
|
ERBDocument.new(source: source, version: version, uri: uri, encoding: encoding)
|
75
|
+
when Document::LanguageId::RBS
|
76
|
+
RBSDocument.new(source: source, version: version, uri: uri, encoding: encoding)
|
72
77
|
else
|
73
78
|
RubyDocument.new(source: source, version: version, uri: uri, encoding: encoding)
|
74
79
|
end
|
75
|
-
@state[uri.to_s] = document
|
76
80
|
end
|
77
81
|
|
78
82
|
sig { params(uri: URI::Generic, edits: T::Array[T::Hash[Symbol, T.untyped]], version: Integer).void }
|
@@ -100,7 +104,7 @@ module RubyLsp
|
|
100
104
|
.params(
|
101
105
|
uri: URI::Generic,
|
102
106
|
request_name: String,
|
103
|
-
block: T.proc.params(document: Document).returns(T.type_parameter(:T)),
|
107
|
+
block: T.proc.params(document: Document[T.untyped]).returns(T.type_parameter(:T)),
|
104
108
|
).returns(T.type_parameter(:T))
|
105
109
|
end
|
106
110
|
def cache_fetch(uri, request_name, &block)
|
data/lib/ruby_lsp/utils.rb
CHANGED
@@ -53,6 +53,7 @@ module RubyLsp
|
|
53
53
|
class Notification < Message
|
54
54
|
class << self
|
55
55
|
extend T::Sig
|
56
|
+
|
56
57
|
sig { params(message: String).returns(Notification) }
|
57
58
|
def window_show_error(message)
|
58
59
|
new(
|
@@ -63,6 +64,14 @@ module RubyLsp
|
|
63
64
|
),
|
64
65
|
)
|
65
66
|
end
|
67
|
+
|
68
|
+
sig { params(message: String, type: Integer).returns(Notification) }
|
69
|
+
def window_log_message(message, type: Constant::MessageType::LOG)
|
70
|
+
new(
|
71
|
+
method: "window/logMessage",
|
72
|
+
params: Interface::LogMessageParams.new(type: type, message: message),
|
73
|
+
)
|
74
|
+
end
|
66
75
|
end
|
67
76
|
|
68
77
|
extend T::Sig
|
@@ -122,6 +131,9 @@ module RubyLsp
|
|
122
131
|
sig { returns(T.untyped) }
|
123
132
|
attr_reader :response
|
124
133
|
|
134
|
+
sig { returns(Integer) }
|
135
|
+
attr_reader :id
|
136
|
+
|
125
137
|
sig { params(id: Integer, response: T.untyped).void }
|
126
138
|
def initialize(id:, response:)
|
127
139
|
@id = id
|
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.17.
|
4
|
+
version: 0.17.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: language_server-protocol
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/ruby_lsp/load_sorbet.rb
|
138
138
|
- lib/ruby_lsp/node_context.rb
|
139
139
|
- lib/ruby_lsp/parameter_scope.rb
|
140
|
+
- lib/ruby_lsp/rbs_document.rb
|
140
141
|
- lib/ruby_lsp/requests.rb
|
141
142
|
- lib/ruby_lsp/requests/code_action_resolve.rb
|
142
143
|
- lib/ruby_lsp/requests/code_actions.rb
|
@@ -206,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
207
|
- !ruby/object:Gem::Version
|
207
208
|
version: '0'
|
208
209
|
requirements: []
|
209
|
-
rubygems_version: 3.5.
|
210
|
+
rubygems_version: 3.5.17
|
210
211
|
signing_key:
|
211
212
|
specification_version: 4
|
212
213
|
summary: An opinionated language server for Ruby
|