ruby-lsp 0.12.2 → 0.12.3

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: 3f60569fbb67f1c78fcffed58dbf540cb4e68fe10200841e54cd8a68859cf0de
4
- data.tar.gz: 07c4419c763e590e1fbed7fe14a2660c1bf6ddbd92ca791948a8c2235208f6e9
3
+ metadata.gz: b053184e8e593901a5344dfd3d34d20962fd2ed773900e00112be751008dae7d
4
+ data.tar.gz: '087be2ed7ace3fdb9eed751215a806deab096c6a5aa415d170eceaa45286c4d9'
5
5
  SHA512:
6
- metadata.gz: 5284be197a27351a845cbcfc1735a0e9546472d60f9600ffd4ee55ba3ab0998438110c1ec59f684e0cf2fbaa7ff99f89878919ae3954022372e50116182c59dd
7
- data.tar.gz: f706c17b0cd47c1001bffb42f6c9a1c43efbd390e548ffe7b51fb3c58bdb433c868a7f907a3aa32175d7742ccbb3c1c29606a0c7c979246bfe887500e6531676
6
+ metadata.gz: e29d0633e023d4d3ce3efe5347479d9e2c16b1cbf02638e29b8f617158c08d7aae84ae4ad1f5898f6bd34033e841070d8cd2ffe8d67180ad4c554f3d5f80b564
7
+ data.tar.gz: 7a74cc5acca390661a196e21760f6c82e00478a02539c4c5cc2d17089948287762886c8a169d2384b59aa7e3324dda08fc3fa52a1aa6112951a2a8bc6b9253ab
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.2
1
+ 0.12.3
@@ -136,8 +136,9 @@ module RubyIndexer
136
136
  case node
137
137
  when Prism::RequiredParameterNode
138
138
  node.name
139
- when Prism::RequiredDestructuredParameterNode
140
- names = node.parameters.map { |parameter_node| parameter_name(parameter_node) }
139
+ when Prism::MultiTargetNode
140
+ names = [*node.lefts, *node.rest, *node.rights].map { |parameter_node| parameter_name(parameter_node) }
141
+
141
142
  names_with_commas = names.join(", ")
142
143
  :"(#{names_with_commas})"
143
144
  end
@@ -35,7 +35,7 @@ module RubyIndexer
35
35
  value = node.value
36
36
  values = value.is_a?(Prism::ArrayNode) && value.opening_loc ? value.elements : []
37
37
 
38
- node.targets.each_with_index do |target, i|
38
+ [*node.lefts, *node.rest, *node.rights].each_with_index do |target, i|
39
39
  current_value = values[i]
40
40
  # The moment we find a splat on the right hand side of the assignment, we can no longer figure out which value
41
41
  # gets assigned to what
@@ -87,15 +87,19 @@ module RubyLsp
87
87
  :start,
88
88
  :line,
89
89
  ) && closest_node_loc.end_line - 1 >= source_range.dig(:end, :line)
90
- indentation_line = closest_node_loc.start_line - 1
91
- target_line = indentation_line
90
+ indentation_line_number = closest_node_loc.start_line - 1
91
+ target_line = indentation_line_number
92
92
  else
93
93
  target_line = closest_node_loc.end_line
94
- indentation_line = closest_node_loc.end_line - 1
94
+ indentation_line_number = closest_node_loc.end_line - 1
95
95
  end
96
96
 
97
97
  lines = @document.source.lines
98
- indentation = T.must(T.must(lines[indentation_line])[/\A */]).size
98
+
99
+ indentation_line = lines[indentation_line_number]
100
+ return Error::InvalidTargetRange unless indentation_line
101
+
102
+ indentation = T.must(indentation_line[/\A */]).size
99
103
 
100
104
  target_range = {
101
105
  start: { line: target_line, character: indentation },
@@ -97,7 +97,8 @@ module RubyLsp
97
97
  Prism::LocalVariableWriteNode,
98
98
  Prism::BlockParameterNode,
99
99
  Prism::RequiredParameterNode,
100
- Prism::KeywordParameterNode,
100
+ Prism::RequiredKeywordParameterNode,
101
+ Prism::OptionalKeywordParameterNode,
101
102
  Prism::RestParameterNode,
102
103
  Prism::OptionalParameterNode,
103
104
  Prism::KeywordRestParameterNode,
@@ -137,8 +138,9 @@ module RubyLsp
137
138
  Prism::ClassVariableReadNode, Prism::ClassVariableTargetNode, Prism::ClassVariableWriteNode,
138
139
  Prism::LocalVariableAndWriteNode, Prism::LocalVariableOperatorWriteNode, Prism::LocalVariableOrWriteNode,
139
140
  Prism::LocalVariableReadNode, Prism::LocalVariableTargetNode, Prism::LocalVariableWriteNode,
140
- Prism::CallNode, Prism::BlockParameterNode, Prism::KeywordParameterNode, Prism::KeywordRestParameterNode,
141
- Prism::OptionalParameterNode, Prism::RequiredParameterNode, Prism::RestParameterNode
141
+ Prism::CallNode, Prism::BlockParameterNode, Prism::RequiredKeywordParameterNode,
142
+ Prism::RequiredKeywordParameterNode, Prism::KeywordRestParameterNode, Prism::OptionalParameterNode,
143
+ Prism::RequiredParameterNode, Prism::RestParameterNode
142
144
  target
143
145
  end
144
146
 
@@ -171,7 +173,8 @@ module RubyLsp
171
173
  :on_constant_path_and_write_node_enter,
172
174
  :on_constant_path_operator_write_node_enter,
173
175
  :on_local_variable_write_node_enter,
174
- :on_keyword_parameter_node_enter,
176
+ :on_required_keyword_parameter_node_enter,
177
+ :on_optional_keyword_parameter_node_enter,
175
178
  :on_rest_parameter_node_enter,
176
179
  :on_optional_parameter_node_enter,
177
180
  :on_keyword_rest_parameter_node_enter,
@@ -359,8 +362,15 @@ module RubyLsp
359
362
  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
360
363
  end
361
364
 
362
- sig { params(node: Prism::KeywordParameterNode).void }
363
- def on_keyword_parameter_node_enter(node)
365
+ sig { params(node: Prism::RequiredKeywordParameterNode).void }
366
+ def on_required_keyword_parameter_node_enter(node)
367
+ return unless matches?(node, LOCAL_NODES)
368
+
369
+ add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
370
+ end
371
+
372
+ sig { params(node: Prism::OptionalKeywordParameterNode).void }
373
+ def on_optional_keyword_parameter_node_enter(node)
364
374
  return unless matches?(node, LOCAL_NODES)
365
375
 
366
376
  add_highlight(Constant::DocumentHighlightKind::WRITE, node.name_loc)
@@ -551,8 +561,8 @@ module RubyLsp
551
561
  Prism::ClassVariableTargetNode, Prism::ClassVariableWriteNode, Prism::LocalVariableAndWriteNode,
552
562
  Prism::LocalVariableOperatorWriteNode, Prism::LocalVariableOrWriteNode, Prism::LocalVariableReadNode,
553
563
  Prism::LocalVariableTargetNode, Prism::LocalVariableWriteNode, Prism::DefNode, Prism::BlockParameterNode,
554
- Prism::KeywordParameterNode, Prism::KeywordRestParameterNode, Prism::OptionalParameterNode,
555
- Prism::RequiredParameterNode, Prism::RestParameterNode
564
+ Prism::RequiredKeywordParameterNode, Prism::OptionalKeywordParameterNode, Prism::KeywordRestParameterNode,
565
+ Prism::OptionalParameterNode, Prism::RequiredParameterNode, Prism::RestParameterNode
556
566
 
557
567
  node.name.to_s
558
568
  when Prism::CallNode
@@ -94,7 +94,7 @@ module RubyLsp
94
94
  opening_loc = node.opening_loc
95
95
  closing_loc = node.closing_loc
96
96
 
97
- add_lines_range(opening_loc.start_line, closing_loc.end_line - 1) if opening_loc && closing_loc
97
+ add_lines_range(opening_loc.start_line, closing_loc.start_line - 1) if opening_loc && closing_loc
98
98
  end
99
99
 
100
100
  sig { params(node: Prism::ArrayNode).void }
@@ -135,7 +135,8 @@ module RubyLsp
135
135
  :on_local_variable_write_node_enter,
136
136
  :on_local_variable_read_node_enter,
137
137
  :on_block_parameter_node_enter,
138
- :on_keyword_parameter_node_enter,
138
+ :on_required_keyword_parameter_node_enter,
139
+ :on_optional_keyword_parameter_node_enter,
139
140
  :on_keyword_rest_parameter_node_enter,
140
141
  :on_optional_parameter_node_enter,
141
142
  :on_required_parameter_node_enter,
@@ -252,11 +253,18 @@ module RubyLsp
252
253
  @current_scope << name.to_sym if name
253
254
  end
254
255
 
255
- sig { params(node: Prism::KeywordParameterNode).void }
256
- def on_keyword_parameter_node_enter(node)
257
- name = node.name
258
- @current_scope << name.to_s.delete_suffix(":").to_sym if name
256
+ sig { params(node: Prism::RequiredKeywordParameterNode).void }
257
+ def on_required_keyword_parameter_node_enter(node)
258
+ @current_scope << node.name
259
+ return unless visible?(node, @range)
260
+
261
+ location = node.name_loc
262
+ add_token(location.copy(length: location.length - 1), :parameter)
263
+ end
259
264
 
265
+ sig { params(node: Prism::OptionalKeywordParameterNode).void }
266
+ def on_optional_keyword_parameter_node_enter(node)
267
+ @current_scope << node.name
260
268
  return unless visible?(node, @range)
261
269
 
262
270
  location = node.name_loc
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.12.2
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-31 00:00:00.000000000 Z
11
+ date: 2023-11-06 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.15.1
33
+ version: 0.17.1
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '0.16'
36
+ version: '0.18'
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.15.1
43
+ version: 0.17.1
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.16'
46
+ version: '0.18'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sorbet-runtime
49
49
  requirement: !ruby/object:Gem::Requirement