ruby-lsp 0.17.10 → 0.17.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fafb2e9f1ef8ae394523d09256bce9016307821ab32ecd17fe645dd3f9d88f1
4
- data.tar.gz: 74396754fdbf6dffb91ff4d6d237f67c26b92fd7ec0f187fc3e40627dc214de1
3
+ metadata.gz: 13815c41a1b7509782277cb5dac09481130e18efc4253a01cede31ca41b335a7
4
+ data.tar.gz: 40e6584ff6ff743ea1e62a29d6090d80bf318ae3dd5d90808de1b35723bea063
5
5
  SHA512:
6
- metadata.gz: 8901ced915cabc4e749cc9451de7d7f9927c4025c6484002a682e65b1a20f7e52d38d3e5b52255b061998e8c114da8efeaaf605f0419fff8ed93c09cf00a2dae
7
- data.tar.gz: 5679783fa6a828a7e6a3db9fb193ec9b4c1c094c6a67c187f7c2169f5f11fe53fe5024b0c7b0f08273eb46293639ff1d67f7787a851f4f1ac599be23a10ff7dd
6
+ metadata.gz: 74da4b254b598cd4b10701b65c49d045cc33be83330399e67602f8e43597c9e54567715343a67fa720b31084de540e498cc3d5525e64679500d52b4842e44cf7
7
+ data.tar.gz: 313695187e34ceb34c50d320bbe0abe0bda18d99157e8f4710faf8f72bc5028abd813511665fd4eac274dd73606eebb1c901b949fa307a8f925c2bfaa39b0c45
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.17.10
1
+ 0.17.11
@@ -46,6 +46,7 @@ module RubyLsp
46
46
  :on_instance_variable_or_write_node_enter,
47
47
  :on_instance_variable_target_node_enter,
48
48
  :on_string_node_enter,
49
+ :on_symbol_node_enter,
49
50
  :on_super_node_enter,
50
51
  :on_forwarding_super_node_enter,
51
52
  )
@@ -54,9 +55,7 @@ module RubyLsp
54
55
  sig { params(node: Prism::CallNode).void }
55
56
  def on_call_node_enter(node)
56
57
  # Sorbet can handle go to definition for methods invoked on self on typed true or higher
57
- if (@sorbet_level == Document::SorbetLevel::True || @sorbet_level == Document::SorbetLevel::Strict) &&
58
- self_receiver?(node)
59
- end
58
+ return if sorbet_level_true_or_higher?(@sorbet_level) && self_receiver?(node)
60
59
 
61
60
  message = node.message
62
61
  return unless message
@@ -83,6 +82,17 @@ module RubyLsp
83
82
  handle_require_definition(node, name)
84
83
  end
85
84
 
85
+ sig { params(node: Prism::SymbolNode).void }
86
+ def on_symbol_node_enter(node)
87
+ enclosing_call = @node_context.call_node
88
+ return unless enclosing_call
89
+
90
+ name = enclosing_call.name
91
+ return unless name == :autoload
92
+
93
+ handle_autoload_definition(enclosing_call)
94
+ end
95
+
86
96
  sig { params(node: Prism::BlockArgumentNode).void }
87
97
  def on_block_argument_node_enter(node)
88
98
  expression = node.expression
@@ -253,6 +263,17 @@ module RubyLsp
253
263
  end
254
264
  end
255
265
 
266
+ sig { params(node: Prism::CallNode).void }
267
+ def handle_autoload_definition(node)
268
+ argument = node.arguments&.arguments&.first
269
+ return unless argument.is_a?(Prism::SymbolNode)
270
+
271
+ constant_name = argument.value
272
+ return unless constant_name
273
+
274
+ find_in_index(constant_name)
275
+ end
276
+
256
277
  sig { params(value: String).void }
257
278
  def find_in_index(value)
258
279
  entries = @index.resolve(value, @node_context.nesting)
@@ -25,9 +25,12 @@ module RubyLsp
25
25
  class << self
26
26
  extend T::Sig
27
27
 
28
- sig { returns(Interface::CodeActionOptions) }
28
+ sig { returns(Interface::CodeActionRegistrationOptions) }
29
29
  def provider
30
- Interface::CodeActionOptions.new(resolve_provider: true)
30
+ Interface::CodeActionRegistrationOptions.new(
31
+ document_selector: [Interface::DocumentFilter.new(language: "ruby")],
32
+ resolve_provider: true,
33
+ )
31
34
  end
32
35
  end
33
36
 
@@ -30,6 +30,12 @@ module RubyLsp
30
30
  extend T::Sig
31
31
  extend T::Generic
32
32
 
33
+ SPECIAL_METHOD_CALLS = [
34
+ :require,
35
+ :require_relative,
36
+ :autoload,
37
+ ].freeze
38
+
33
39
  sig do
34
40
  params(
35
41
  document: Document,
@@ -78,8 +84,9 @@ module RubyLsp
78
84
  parent,
79
85
  position,
80
86
  )
81
- elsif target.is_a?(Prism::CallNode) && target.name != :require && target.name != :require_relative &&
82
- !covers_position?(target.message_loc, position)
87
+ elsif target.is_a?(Prism::CallNode) && !SPECIAL_METHOD_CALLS.include?(target.message) && !covers_position?(
88
+ target.message_loc, position
89
+ )
83
90
  # If the target is a method call, we need to ensure that the requested position is exactly on top of the
84
91
  # method identifier. Otherwise, we risk showing definitions for unrelated things
85
92
  target = nil
@@ -22,12 +22,13 @@ module RubyLsp
22
22
  class << self
23
23
  extend T::Sig
24
24
 
25
- sig { returns(T::Hash[Symbol, T::Boolean]) }
25
+ sig { returns(Interface::DiagnosticRegistrationOptions) }
26
26
  def provider
27
- {
28
- interFileDependencies: false,
29
- workspaceDiagnostics: false,
30
- }
27
+ Interface::DiagnosticRegistrationOptions.new(
28
+ document_selector: [Interface::DocumentFilter.new(language: "ruby")],
29
+ inter_file_dependencies: false,
30
+ workspace_diagnostics: false,
31
+ )
31
32
  end
32
33
  end
33
34
 
@@ -34,14 +34,9 @@ module RubyLsp
34
34
  class << self
35
35
  extend T::Sig
36
36
 
37
- sig { returns(Interface::DocumentSymbolClientCapabilities) }
37
+ sig { returns(Interface::DocumentSymbolOptions) }
38
38
  def provider
39
- Interface::DocumentSymbolClientCapabilities.new(
40
- hierarchical_document_symbol_support: true,
41
- symbol_kind: {
42
- value_set: (Constant::SymbolKind::FILE..Constant::SymbolKind::TYPE_PARAMETER).to_a,
43
- },
44
- )
39
+ Interface::DocumentSymbolOptions.new
45
40
  end
46
41
  end
47
42
 
@@ -23,9 +23,13 @@ module RubyLsp
23
23
  class << self
24
24
  extend T::Sig
25
25
 
26
- sig { returns(Interface::FoldingRangeClientCapabilities) }
26
+ sig { returns(Interface::FoldingRangeRegistrationOptions) }
27
27
  def provider
28
- Interface::FoldingRangeClientCapabilities.new(line_folding_only: true)
28
+ Interface::FoldingRangeRegistrationOptions.new(
29
+ document_selector: [
30
+ Interface::DocumentFilter.new(language: "ruby"),
31
+ ],
32
+ )
29
33
  end
30
34
  end
31
35
 
@@ -27,6 +27,19 @@ module RubyLsp
27
27
 
28
28
  class Error < StandardError; end
29
29
 
30
+ class << self
31
+ extend T::Sig
32
+
33
+ sig { returns(Interface::DocumentFormattingRegistrationOptions) }
34
+ def provider
35
+ Interface::DocumentFormattingRegistrationOptions.new(
36
+ document_selector: [
37
+ Interface::DocumentFilter.new(language: "ruby"),
38
+ ],
39
+ )
40
+ end
41
+ end
42
+
30
43
  sig { params(global_state: GlobalState, document: Document).void }
31
44
  def initialize(global_state, document)
32
45
  super()
@@ -22,9 +22,9 @@ module RubyLsp
22
22
  class << self
23
23
  extend T::Sig
24
24
 
25
- sig { returns(Interface::HoverClientCapabilities) }
25
+ sig { returns(Interface::HoverOptions) }
26
26
  def provider
27
- Interface::HoverClientCapabilities.new(dynamic_registration: false)
27
+ Interface::HoverOptions.new
28
28
  end
29
29
  end
30
30
 
@@ -21,9 +21,10 @@ module RubyLsp
21
21
  class << self
22
22
  extend T::Sig
23
23
 
24
- sig { returns(Interface::DocumentOnTypeFormattingOptions) }
24
+ sig { returns(Interface::DocumentOnTypeFormattingRegistrationOptions) }
25
25
  def provider
26
- Interface::DocumentOnTypeFormattingOptions.new(
26
+ Interface::DocumentOnTypeFormattingRegistrationOptions.new(
27
+ document_selector: [Interface::DocumentFilter.new(language: "ruby")],
27
28
  first_trigger_character: "{",
28
29
  more_trigger_character: ["\n", "|", "d"],
29
30
  )
@@ -181,6 +181,7 @@ module RubyLsp
181
181
  hover_provider = Requests::Hover.provider if enabled_features["hover"]
182
182
  folding_ranges_provider = Requests::FoldingRanges.provider if enabled_features["foldingRanges"]
183
183
  semantic_tokens_provider = Requests::SemanticHighlighting.provider if enabled_features["semanticHighlighting"]
184
+ document_formatting_provider = Requests::Formatting.provider if enabled_features["formatting"]
184
185
  diagnostics_provider = Requests::Diagnostics.provider if enabled_features["diagnostics"]
185
186
  on_type_formatting_provider = Requests::OnTypeFormatting.provider if enabled_features["onTypeFormatting"]
186
187
  code_action_provider = Requests::CodeActions.provider if enabled_features["codeActions"]
@@ -202,7 +203,7 @@ module RubyLsp
202
203
  document_link_provider: document_link_provider,
203
204
  folding_range_provider: folding_ranges_provider,
204
205
  semantic_tokens_provider: semantic_tokens_provider,
205
- document_formatting_provider: enabled_features["formatting"] && @global_state.formatter != "none",
206
+ document_formatting_provider: document_formatting_provider && @global_state.formatter != "none",
206
207
  document_highlight_provider: enabled_features["documentHighlights"],
207
208
  code_action_provider: code_action_provider,
208
209
  document_on_type_formatting_provider: on_type_formatting_provider,
@@ -421,8 +422,6 @@ module RubyLsp
421
422
 
422
423
  document = @store.get(uri)
423
424
 
424
- return send_empty_response(message[:id]) if document.is_a?(ERBDocument)
425
-
426
425
  response = Requests::Formatting.new(@global_state, document).perform
427
426
  send_message(Result.new(id: message[:id], response: response))
428
427
  rescue Requests::Request::InvalidFormatter => error
@@ -448,8 +447,6 @@ module RubyLsp
448
447
  params = message[:params]
449
448
  document = @store.get(params.dig(:textDocument, :uri))
450
449
 
451
- return send_empty_response(message[:id]) if document.is_a?(ERBDocument)
452
-
453
450
  send_message(
454
451
  Result.new(
455
452
  id: message[:id],
@@ -506,8 +503,6 @@ module RubyLsp
506
503
  params = message[:params]
507
504
  document = @store.get(params.dig(:textDocument, :uri))
508
505
 
509
- return send_empty_response(message[:id]) if document.is_a?(ERBDocument)
510
-
511
506
  send_message(
512
507
  Result.new(
513
508
  id: message[:id],
@@ -563,8 +558,6 @@ module RubyLsp
563
558
 
564
559
  document = @store.get(uri)
565
560
 
566
- return send_empty_response(message[:id]) if document.is_a?(ERBDocument)
567
-
568
561
  response = document.cache_fetch("textDocument/diagnostic") do |document|
569
562
  Requests::Diagnostics.new(@global_state, document).perform
570
563
  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.10
4
+ version: 0.17.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-30 00:00:00.000000000 Z
11
+ date: 2024-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: language_server-protocol