ruby-lsp 0.17.3 → 0.17.5
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 +4 -0
- data/VERSION +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +251 -100
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +173 -114
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +337 -77
- data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +43 -14
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +79 -3
- data/lib/ruby_indexer/test/index_test.rb +563 -29
- data/lib/ruby_indexer/test/instance_variables_test.rb +84 -7
- data/lib/ruby_indexer/test/method_test.rb +75 -25
- data/lib/ruby_indexer/test/rbs_indexer_test.rb +38 -2
- data/lib/ruby_indexer/test/test_case.rb +1 -5
- data/lib/ruby_lsp/addon.rb +13 -1
- data/lib/ruby_lsp/document.rb +50 -23
- data/lib/ruby_lsp/erb_document.rb +125 -0
- data/lib/ruby_lsp/global_state.rb +11 -4
- data/lib/ruby_lsp/internal.rb +3 -0
- data/lib/ruby_lsp/listeners/completion.rb +69 -34
- data/lib/ruby_lsp/listeners/definition.rb +34 -23
- data/lib/ruby_lsp/listeners/hover.rb +14 -7
- data/lib/ruby_lsp/listeners/signature_help.rb +5 -2
- data/lib/ruby_lsp/node_context.rb +6 -1
- data/lib/ruby_lsp/requests/code_action_resolve.rb +2 -2
- data/lib/ruby_lsp/requests/completion.rb +6 -5
- data/lib/ruby_lsp/requests/completion_resolve.rb +7 -4
- data/lib/ruby_lsp/requests/definition.rb +4 -3
- data/lib/ruby_lsp/requests/formatting.rb +2 -0
- data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +88 -0
- data/lib/ruby_lsp/requests/selection_ranges.rb +1 -1
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +3 -2
- data/lib/ruby_lsp/requests/support/common.rb +19 -1
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +12 -4
- data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +87 -0
- data/lib/ruby_lsp/requests/workspace_symbol.rb +1 -21
- data/lib/ruby_lsp/requests.rb +2 -0
- data/lib/ruby_lsp/ruby_document.rb +10 -0
- data/lib/ruby_lsp/server.rb +95 -26
- data/lib/ruby_lsp/store.rb +23 -8
- data/lib/ruby_lsp/test_helper.rb +3 -1
- data/lib/ruby_lsp/type_inferrer.rb +86 -0
- metadata +10 -6
data/lib/ruby_lsp/server.rb
CHANGED
@@ -68,6 +68,12 @@ module RubyLsp
|
|
68
68
|
text_document_signature_help(message)
|
69
69
|
when "textDocument/definition"
|
70
70
|
text_document_definition(message)
|
71
|
+
when "textDocument/prepareTypeHierarchy"
|
72
|
+
text_document_prepare_type_hierarchy(message)
|
73
|
+
when "typeHierarchy/supertypes"
|
74
|
+
type_hierarchy_supertypes(message)
|
75
|
+
when "typeHierarchy/subtypes"
|
76
|
+
type_hierarchy_subtypes(message)
|
71
77
|
when "workspace/didChangeWatchedFiles"
|
72
78
|
workspace_did_change_watched_files(message)
|
73
79
|
when "workspace/symbol"
|
@@ -76,13 +82,32 @@ module RubyLsp
|
|
76
82
|
text_document_show_syntax_tree(message)
|
77
83
|
when "rubyLsp/workspace/dependencies"
|
78
84
|
workspace_dependencies(message)
|
85
|
+
when "rubyLsp/workspace/addons"
|
86
|
+
send_message(
|
87
|
+
Result.new(
|
88
|
+
id: message[:id],
|
89
|
+
response:
|
90
|
+
Addon.addons.map do |addon|
|
91
|
+
{ name: addon.name, errored: addon.error? }
|
92
|
+
end,
|
93
|
+
),
|
94
|
+
)
|
79
95
|
when "$/cancelRequest"
|
80
96
|
@mutex.synchronize { @cancelled_requests << message[:params][:id] }
|
81
97
|
end
|
82
98
|
rescue StandardError, LoadError => e
|
83
99
|
# If an error occurred in a request, we have to return an error response or else the editor will hang
|
84
100
|
if message[:id]
|
85
|
-
send_message(Error.new(
|
101
|
+
send_message(Error.new(
|
102
|
+
id: message[:id],
|
103
|
+
code: Constant::ErrorCodes::INTERNAL_ERROR,
|
104
|
+
message: e.full_message,
|
105
|
+
data: {
|
106
|
+
errorClass: e.class.name,
|
107
|
+
errorMessage: e.message,
|
108
|
+
backtrace: e.backtrace&.join("\n"),
|
109
|
+
},
|
110
|
+
))
|
86
111
|
end
|
87
112
|
|
88
113
|
$stderr.puts("Error processing #{message[:method]}: #{e.full_message}")
|
@@ -104,7 +129,7 @@ module RubyLsp
|
|
104
129
|
),
|
105
130
|
)
|
106
131
|
|
107
|
-
$stderr.puts(errored_addons.map(&:errors_details).join("\n\n"))
|
132
|
+
$stderr.puts(errored_addons.map(&:errors_details).join("\n\n")) unless @test_mode
|
108
133
|
end
|
109
134
|
end
|
110
135
|
|
@@ -121,7 +146,6 @@ module RubyLsp
|
|
121
146
|
progress = options.dig(:capabilities, :window, :workDoneProgress)
|
122
147
|
@store.supports_progress = progress.nil? ? true : progress
|
123
148
|
configured_features = options.dig(:initializationOptions, :enabledFeatures)
|
124
|
-
@store.experimental_features = options.dig(:initializationOptions, :experimentalFeaturesEnabled) || false
|
125
149
|
|
126
150
|
configured_hints = options.dig(:initializationOptions, :featuresConfiguration, :inlayHint)
|
127
151
|
T.must(@store.features_configuration.dig(:inlayHint)).configuration.merge!(configured_hints) if configured_hints
|
@@ -152,6 +176,7 @@ module RubyLsp
|
|
152
176
|
inlay_hint_provider = Requests::InlayHints.provider if enabled_features["inlayHint"]
|
153
177
|
completion_provider = Requests::Completion.provider if enabled_features["completion"]
|
154
178
|
signature_help_provider = Requests::SignatureHelp.provider if enabled_features["signatureHelp"]
|
179
|
+
type_hierarchy_provider = Requests::PrepareTypeHierarchy.provider if enabled_features["typeHierarchy"]
|
155
180
|
|
156
181
|
response = {
|
157
182
|
capabilities: Interface::ServerCapabilities.new(
|
@@ -175,8 +200,12 @@ module RubyLsp
|
|
175
200
|
completion_provider: completion_provider,
|
176
201
|
code_lens_provider: code_lens_provider,
|
177
202
|
definition_provider: enabled_features["definition"],
|
178
|
-
workspace_symbol_provider: enabled_features["workspaceSymbol"] && !@global_state.
|
203
|
+
workspace_symbol_provider: enabled_features["workspaceSymbol"] && !@global_state.has_type_checker,
|
179
204
|
signature_help_provider: signature_help_provider,
|
205
|
+
type_hierarchy_provider: type_hierarchy_provider,
|
206
|
+
experimental: {
|
207
|
+
addon_detection: true,
|
208
|
+
},
|
180
209
|
),
|
181
210
|
serverInfo: {
|
182
211
|
name: "Ruby LSP",
|
@@ -259,11 +288,18 @@ module RubyLsp
|
|
259
288
|
def text_document_did_open(message)
|
260
289
|
@mutex.synchronize do
|
261
290
|
text_document = message.dig(:params, :textDocument)
|
291
|
+
language_id = case text_document[:languageId]
|
292
|
+
when "erb"
|
293
|
+
Document::LanguageId::ERB
|
294
|
+
else
|
295
|
+
Document::LanguageId::Ruby
|
296
|
+
end
|
262
297
|
@store.set(
|
263
298
|
uri: text_document[:uri],
|
264
299
|
source: text_document[:text],
|
265
300
|
version: text_document[:version],
|
266
301
|
encoding: @global_state.encoding,
|
302
|
+
language_id: language_id,
|
267
303
|
)
|
268
304
|
end
|
269
305
|
end
|
@@ -327,15 +363,17 @@ module RubyLsp
|
|
327
363
|
return
|
328
364
|
end
|
329
365
|
|
366
|
+
parse_result = document.parse_result
|
367
|
+
|
330
368
|
# Run requests for the document
|
331
369
|
dispatcher = Prism::Dispatcher.new
|
332
|
-
folding_range = Requests::FoldingRanges.new(
|
370
|
+
folding_range = Requests::FoldingRanges.new(parse_result.comments, dispatcher)
|
333
371
|
document_symbol = Requests::DocumentSymbol.new(uri, dispatcher)
|
334
|
-
document_link = Requests::DocumentLink.new(uri,
|
372
|
+
document_link = Requests::DocumentLink.new(uri, parse_result.comments, dispatcher)
|
335
373
|
code_lens = Requests::CodeLens.new(@global_state, uri, dispatcher)
|
336
374
|
|
337
375
|
semantic_highlighting = Requests::SemanticHighlighting.new(@global_state, dispatcher)
|
338
|
-
dispatcher.dispatch(
|
376
|
+
dispatcher.dispatch(parse_result.value)
|
339
377
|
|
340
378
|
# Store all responses retrieve in this round of visits in the cache and then return the response for the request
|
341
379
|
# we actually received
|
@@ -367,7 +405,7 @@ module RubyLsp
|
|
367
405
|
|
368
406
|
dispatcher = Prism::Dispatcher.new
|
369
407
|
request = Requests::SemanticHighlighting.new(@global_state, dispatcher, range: start_line..end_line)
|
370
|
-
dispatcher.visit(document.
|
408
|
+
dispatcher.visit(document.parse_result.value)
|
371
409
|
|
372
410
|
response = request.perform
|
373
411
|
send_message(Result.new(id: message[:id], response: response))
|
@@ -390,7 +428,11 @@ module RubyLsp
|
|
390
428
|
return
|
391
429
|
end
|
392
430
|
|
393
|
-
|
431
|
+
document = @store.get(uri)
|
432
|
+
|
433
|
+
return send_empty_response(message[:id]) if document.is_a?(ERBDocument)
|
434
|
+
|
435
|
+
response = Requests::Formatting.new(@global_state, document).perform
|
394
436
|
send_message(Result.new(id: message[:id], response: response))
|
395
437
|
rescue Requests::Request::InvalidFormatter => error
|
396
438
|
send_message(Notification.window_show_error("Configuration error: #{error.message}"))
|
@@ -406,19 +448,22 @@ module RubyLsp
|
|
406
448
|
dispatcher = Prism::Dispatcher.new
|
407
449
|
document = @store.get(params.dig(:textDocument, :uri))
|
408
450
|
request = Requests::DocumentHighlight.new(document, params[:position], dispatcher)
|
409
|
-
dispatcher.dispatch(document.
|
451
|
+
dispatcher.dispatch(document.parse_result.value)
|
410
452
|
send_message(Result.new(id: message[:id], response: request.perform))
|
411
453
|
end
|
412
454
|
|
413
455
|
sig { params(message: T::Hash[Symbol, T.untyped]).void }
|
414
456
|
def text_document_on_type_formatting(message)
|
415
457
|
params = message[:params]
|
458
|
+
document = @store.get(params.dig(:textDocument, :uri))
|
459
|
+
|
460
|
+
return send_empty_response(message[:id]) if document.is_a?(ERBDocument)
|
416
461
|
|
417
462
|
send_message(
|
418
463
|
Result.new(
|
419
464
|
id: message[:id],
|
420
465
|
response: Requests::OnTypeFormatting.new(
|
421
|
-
|
466
|
+
document,
|
422
467
|
params[:position],
|
423
468
|
params[:ch],
|
424
469
|
@store.client_name,
|
@@ -449,7 +494,7 @@ module RubyLsp
|
|
449
494
|
|
450
495
|
sig { params(document: Document).returns(T::Boolean) }
|
451
496
|
def typechecker_enabled?(document)
|
452
|
-
@global_state.
|
497
|
+
@global_state.has_type_checker && document.sorbet_sigil_is_true_or_higher
|
453
498
|
end
|
454
499
|
|
455
500
|
sig { params(message: T::Hash[Symbol, T.untyped]).void }
|
@@ -459,7 +504,7 @@ module RubyLsp
|
|
459
504
|
dispatcher = Prism::Dispatcher.new
|
460
505
|
document = @store.get(params.dig(:textDocument, :uri))
|
461
506
|
request = Requests::InlayHints.new(document, params[:range], hints_configurations, dispatcher)
|
462
|
-
dispatcher.visit(document.
|
507
|
+
dispatcher.visit(document.parse_result.value)
|
463
508
|
send_message(Result.new(id: message[:id], response: request.perform))
|
464
509
|
end
|
465
510
|
|
@@ -468,6 +513,8 @@ module RubyLsp
|
|
468
513
|
params = message[:params]
|
469
514
|
document = @store.get(params.dig(:textDocument, :uri))
|
470
515
|
|
516
|
+
return send_empty_response(message[:id]) if document.is_a?(ERBDocument)
|
517
|
+
|
471
518
|
send_message(
|
472
519
|
Result.new(
|
473
520
|
id: message[:id],
|
@@ -521,7 +568,11 @@ module RubyLsp
|
|
521
568
|
return
|
522
569
|
end
|
523
570
|
|
524
|
-
|
571
|
+
document = @store.get(uri)
|
572
|
+
|
573
|
+
return send_empty_response(message[:id]) if document.is_a?(ERBDocument)
|
574
|
+
|
575
|
+
response = document.cache_fetch("textDocument/diagnostic") do |document|
|
525
576
|
Requests::Diagnostics.new(@global_state, document).perform
|
526
577
|
end
|
527
578
|
|
@@ -551,7 +602,7 @@ module RubyLsp
|
|
551
602
|
response: Requests::Completion.new(
|
552
603
|
document,
|
553
604
|
@global_state,
|
554
|
-
params
|
605
|
+
params,
|
555
606
|
typechecker_enabled?(document),
|
556
607
|
dispatcher,
|
557
608
|
).perform,
|
@@ -660,6 +711,33 @@ module RubyLsp
|
|
660
711
|
send_message(Result.new(id: message[:id], response: response))
|
661
712
|
end
|
662
713
|
|
714
|
+
sig { params(message: T::Hash[Symbol, T.untyped]).void }
|
715
|
+
def text_document_prepare_type_hierarchy(message)
|
716
|
+
params = message[:params]
|
717
|
+
response = Requests::PrepareTypeHierarchy.new(
|
718
|
+
@store.get(params.dig(:textDocument, :uri)),
|
719
|
+
@global_state.index,
|
720
|
+
params[:position],
|
721
|
+
).perform
|
722
|
+
send_message(Result.new(id: message[:id], response: response))
|
723
|
+
end
|
724
|
+
|
725
|
+
sig { params(message: T::Hash[Symbol, T.untyped]).void }
|
726
|
+
def type_hierarchy_supertypes(message)
|
727
|
+
response = Requests::TypeHierarchySupertypes.new(
|
728
|
+
@global_state.index,
|
729
|
+
message.dig(:params, :item),
|
730
|
+
).perform
|
731
|
+
send_message(Result.new(id: message[:id], response: response))
|
732
|
+
end
|
733
|
+
|
734
|
+
sig { params(message: T::Hash[Symbol, T.untyped]).void }
|
735
|
+
def type_hierarchy_subtypes(message)
|
736
|
+
# TODO: implement subtypes
|
737
|
+
# The current index representation doesn't allow us to find the children of an entry.
|
738
|
+
send_message(Result.new(id: message[:id], response: nil))
|
739
|
+
end
|
740
|
+
|
663
741
|
sig { params(message: T::Hash[Symbol, T.untyped]).void }
|
664
742
|
def workspace_dependencies(message)
|
665
743
|
response = begin
|
@@ -690,23 +768,14 @@ module RubyLsp
|
|
690
768
|
|
691
769
|
sig { params(config_hash: T::Hash[String, T.untyped]).void }
|
692
770
|
def perform_initial_indexing(config_hash)
|
693
|
-
index_ruby_core
|
694
|
-
index_ruby_code(config_hash)
|
695
|
-
end
|
696
|
-
|
697
|
-
sig { void }
|
698
|
-
def index_ruby_core
|
699
|
-
RubyIndexer::RBSIndexer.new(@global_state.index).index_ruby_core
|
700
|
-
end
|
701
|
-
|
702
|
-
sig { params(config_hash: T::Hash[String, T.untyped]).void }
|
703
|
-
def index_ruby_code(config_hash)
|
704
771
|
# The begin progress invocation happens during `initialize`, so that the notification is sent before we are
|
705
772
|
# stuck indexing files
|
706
773
|
RubyIndexer.configuration.apply_config(config_hash)
|
707
774
|
|
708
775
|
Thread.new do
|
709
776
|
begin
|
777
|
+
RubyIndexer::RBSIndexer.new(@global_state.index).index_ruby_core
|
778
|
+
|
710
779
|
@global_state.index.index_all do |percentage|
|
711
780
|
progress("indexing-progress", percentage)
|
712
781
|
true
|
data/lib/ruby_lsp/store.rb
CHANGED
@@ -8,9 +8,6 @@ module RubyLsp
|
|
8
8
|
sig { returns(T::Boolean) }
|
9
9
|
attr_accessor :supports_progress
|
10
10
|
|
11
|
-
sig { returns(T::Boolean) }
|
12
|
-
attr_accessor :experimental_features
|
13
|
-
|
14
11
|
sig { returns(T::Hash[Symbol, RequestConfig]) }
|
15
12
|
attr_accessor :features_configuration
|
16
13
|
|
@@ -21,7 +18,6 @@ module RubyLsp
|
|
21
18
|
def initialize
|
22
19
|
@state = T.let({}, T::Hash[String, Document])
|
23
20
|
@supports_progress = T.let(true, T::Boolean)
|
24
|
-
@experimental_features = T.let(false, T::Boolean)
|
25
21
|
@features_configuration = T.let(
|
26
22
|
{
|
27
23
|
inlayHint: RequestConfig.new({
|
@@ -41,13 +37,32 @@ module RubyLsp
|
|
41
37
|
return document unless document.nil?
|
42
38
|
|
43
39
|
path = T.must(uri.to_standardized_path)
|
44
|
-
|
40
|
+
ext = File.extname(path)
|
41
|
+
language_id = if ext == ".erb" || ext == ".rhtml"
|
42
|
+
Document::LanguageId::ERB
|
43
|
+
else
|
44
|
+
Document::LanguageId::Ruby
|
45
|
+
end
|
46
|
+
set(uri: uri, source: File.binread(path), version: 0, language_id: language_id)
|
45
47
|
T.must(@state[uri.to_s])
|
46
48
|
end
|
47
49
|
|
48
|
-
sig
|
49
|
-
|
50
|
-
|
50
|
+
sig do
|
51
|
+
params(
|
52
|
+
uri: URI::Generic,
|
53
|
+
source: String,
|
54
|
+
version: Integer,
|
55
|
+
language_id: Document::LanguageId,
|
56
|
+
encoding: Encoding,
|
57
|
+
).void
|
58
|
+
end
|
59
|
+
def set(uri:, source:, version:, language_id:, encoding: Encoding::UTF_8)
|
60
|
+
document = case language_id
|
61
|
+
when Document::LanguageId::ERB
|
62
|
+
ERBDocument.new(source: source, version: version, uri: uri, encoding: encoding)
|
63
|
+
else
|
64
|
+
RubyDocument.new(source: source, version: version, uri: uri, encoding: encoding)
|
65
|
+
end
|
51
66
|
@state[uri.to_s] = document
|
52
67
|
end
|
53
68
|
|
data/lib/ruby_lsp/test_helper.rb
CHANGED
@@ -20,8 +20,9 @@ module RubyLsp
|
|
20
20
|
def with_server(source = nil, uri = Kernel.URI("file:///fake.rb"), stub_no_typechecker: false, load_addons: true,
|
21
21
|
&block)
|
22
22
|
server = RubyLsp::Server.new(test_mode: true)
|
23
|
-
server.global_state.stubs(:
|
23
|
+
server.global_state.stubs(:has_type_checker).returns(false) if stub_no_typechecker
|
24
24
|
server.global_state.apply_options({})
|
25
|
+
language_id = uri.to_s.end_with?(".erb") ? "erb" : "ruby"
|
25
26
|
|
26
27
|
if source
|
27
28
|
server.process_message({
|
@@ -31,6 +32,7 @@ module RubyLsp
|
|
31
32
|
uri: uri,
|
32
33
|
text: source,
|
33
34
|
version: 1,
|
35
|
+
languageId: language_id,
|
34
36
|
},
|
35
37
|
},
|
36
38
|
})
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module RubyLsp
|
5
|
+
# A minimalistic type checker to try to resolve types that can be inferred without requiring a type system or
|
6
|
+
# annotations
|
7
|
+
class TypeInferrer
|
8
|
+
extend T::Sig
|
9
|
+
|
10
|
+
sig { params(index: RubyIndexer::Index).void }
|
11
|
+
def initialize(index)
|
12
|
+
@index = index
|
13
|
+
end
|
14
|
+
|
15
|
+
sig { params(node_context: NodeContext).returns(T.nilable(String)) }
|
16
|
+
def infer_receiver_type(node_context)
|
17
|
+
node = node_context.node
|
18
|
+
|
19
|
+
case node
|
20
|
+
when Prism::CallNode
|
21
|
+
infer_receiver_for_call_node(node, node_context)
|
22
|
+
when Prism::InstanceVariableReadNode, Prism::InstanceVariableAndWriteNode, Prism::InstanceVariableWriteNode,
|
23
|
+
Prism::InstanceVariableOperatorWriteNode, Prism::InstanceVariableOrWriteNode, Prism::InstanceVariableTargetNode
|
24
|
+
nesting = node_context.nesting
|
25
|
+
# If we're at the top level, then the invocation is happening on `<main>`, which is a special singleton that
|
26
|
+
# inherits from Object
|
27
|
+
return "Object" if nesting.empty?
|
28
|
+
|
29
|
+
fully_qualified_name = node_context.fully_qualified_name
|
30
|
+
return fully_qualified_name if node_context.surrounding_method
|
31
|
+
|
32
|
+
"#{fully_qualified_name}::<Class:#{nesting.last}>"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
sig { params(node: Prism::CallNode, node_context: NodeContext).returns(T.nilable(String)) }
|
39
|
+
def infer_receiver_for_call_node(node, node_context)
|
40
|
+
receiver = node.receiver
|
41
|
+
|
42
|
+
case receiver
|
43
|
+
when Prism::SelfNode, nil
|
44
|
+
nesting = node_context.nesting
|
45
|
+
# If we're at the top level, then the invocation is happening on `<main>`, which is a special singleton that
|
46
|
+
# inherits from Object
|
47
|
+
return "Object" if nesting.empty?
|
48
|
+
return node_context.fully_qualified_name if node_context.surrounding_method
|
49
|
+
|
50
|
+
# If we're not inside a method, then we're inside the body of a class or module, which is a singleton
|
51
|
+
# context
|
52
|
+
"#{nesting.join("::")}::<Class:#{nesting.last}>"
|
53
|
+
when Prism::ConstantPathNode, Prism::ConstantReadNode
|
54
|
+
# When the receiver is a constant reference, we have to try to resolve it to figure out the right
|
55
|
+
# receiver. But since the invocation is directly on the constant, that's the singleton context of that
|
56
|
+
# class/module
|
57
|
+
receiver_name = constant_name(receiver)
|
58
|
+
return unless receiver_name
|
59
|
+
|
60
|
+
resolved_receiver = @index.resolve(receiver_name, node_context.nesting)
|
61
|
+
name = resolved_receiver&.first&.name
|
62
|
+
return unless name
|
63
|
+
|
64
|
+
*parts, last = name.split("::")
|
65
|
+
return "#{last}::<Class:#{last}>" if parts.empty?
|
66
|
+
|
67
|
+
"#{parts.join("::")}::#{last}::<Class:#{last}>"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
sig do
|
72
|
+
params(
|
73
|
+
node: T.any(
|
74
|
+
Prism::ConstantPathNode,
|
75
|
+
Prism::ConstantReadNode,
|
76
|
+
),
|
77
|
+
).returns(T.nilable(String))
|
78
|
+
end
|
79
|
+
def constant_name(node)
|
80
|
+
node.full_name
|
81
|
+
rescue Prism::ConstantPathNode::DynamicPartsInConstantPathError,
|
82
|
+
Prism::ConstantPathNode::MissingNodesInConstantPathError
|
83
|
+
nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
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.17.
|
4
|
+
version: 0.17.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: language_server-protocol
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/ruby_lsp/base_server.rb
|
121
121
|
- lib/ruby_lsp/check_docs.rb
|
122
122
|
- lib/ruby_lsp/document.rb
|
123
|
+
- lib/ruby_lsp/erb_document.rb
|
123
124
|
- lib/ruby_lsp/global_state.rb
|
124
125
|
- lib/ruby_lsp/internal.rb
|
125
126
|
- lib/ruby_lsp/listeners/code_lens.rb
|
@@ -152,6 +153,7 @@ files:
|
|
152
153
|
- lib/ruby_lsp/requests/hover.rb
|
153
154
|
- lib/ruby_lsp/requests/inlay_hints.rb
|
154
155
|
- lib/ruby_lsp/requests/on_type_formatting.rb
|
156
|
+
- lib/ruby_lsp/requests/prepare_type_hierarchy.rb
|
155
157
|
- lib/ruby_lsp/requests/request.rb
|
156
158
|
- lib/ruby_lsp/requests/selection_ranges.rb
|
157
159
|
- lib/ruby_lsp/requests/semantic_highlighting.rb
|
@@ -167,6 +169,7 @@ files:
|
|
167
169
|
- lib/ruby_lsp/requests/support/sorbet.rb
|
168
170
|
- lib/ruby_lsp/requests/support/source_uri.rb
|
169
171
|
- lib/ruby_lsp/requests/support/syntax_tree_formatter.rb
|
172
|
+
- lib/ruby_lsp/requests/type_hierarchy_supertypes.rb
|
170
173
|
- lib/ruby_lsp/requests/workspace_symbol.rb
|
171
174
|
- lib/ruby_lsp/response_builders.rb
|
172
175
|
- lib/ruby_lsp/response_builders/collection_response_builder.rb
|
@@ -180,6 +183,7 @@ files:
|
|
180
183
|
- lib/ruby_lsp/setup_bundler.rb
|
181
184
|
- lib/ruby_lsp/store.rb
|
182
185
|
- lib/ruby_lsp/test_helper.rb
|
186
|
+
- lib/ruby_lsp/type_inferrer.rb
|
183
187
|
- lib/ruby_lsp/utils.rb
|
184
188
|
homepage: https://github.com/Shopify/ruby-lsp
|
185
189
|
licenses:
|
@@ -187,7 +191,7 @@ licenses:
|
|
187
191
|
metadata:
|
188
192
|
allowed_push_host: https://rubygems.org
|
189
193
|
documentation_uri: https://shopify.github.io/ruby-lsp/
|
190
|
-
post_install_message:
|
194
|
+
post_install_message:
|
191
195
|
rdoc_options: []
|
192
196
|
require_paths:
|
193
197
|
- lib
|
@@ -202,8 +206,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
206
|
- !ruby/object:Gem::Version
|
203
207
|
version: '0'
|
204
208
|
requirements: []
|
205
|
-
rubygems_version: 3.5.
|
206
|
-
signing_key:
|
209
|
+
rubygems_version: 3.5.14
|
210
|
+
signing_key:
|
207
211
|
specification_version: 4
|
208
212
|
summary: An opinionated language server for Ruby
|
209
213
|
test_files: []
|