ruby-lsp 0.23.15 → 0.23.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e54bcceea5e2a289c338ab213823ea63915ad96901f99c1976e6ad746c5c5402
4
- data.tar.gz: 643f3843f6085d5cf7f29e1d577a94c8d994cbe932708da875e6600ca4fe4c64
3
+ metadata.gz: 6c17ad9bdfcbd63ad18912cd0247475f9a0b3739dd6ffae489a72d0d2b4b1d77
4
+ data.tar.gz: 3681e153bac6f08236fbd1f875a6fbafbb4c523af187f7471c798be8d3d40b7b
5
5
  SHA512:
6
- metadata.gz: 49b288356198fbfe6d66e4c6f4765585e44e6b46c5bb81d18d5df547914c5f167b9ac781add2d725f5f9fda9e042dc585323672c60e27c034c80a46eb8f121e3
7
- data.tar.gz: 95a7119a9272c5a012ea17fd90c86dc70fa6d66bf81a056ad19dd7ab891d7db9c9c596aff6342432505dd2b487212d48bbb8a28f35468268370d3856b8d1d7ee
6
+ metadata.gz: 669a6d69961413145b35aec0d81dbcb0507e1d856f4534c70af38946dd43e9ee6f20a07fcb44e5f3ff7515de8ac47546d95ff7542a8756ce9b693ad35b70f20e
7
+ data.tar.gz: 11d7d9dd59c2cb216b49c5cc3ec7fa2cc1eda781a6394185fec614f287b0f707a363fc49aa3700cea7659c1735ea447a0d5c96d0ea81944eff96ae41c9fb4cda
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.23.15
1
+ 0.23.16
@@ -66,7 +66,7 @@ module RubyIndexer
66
66
  flags = File::FNM_PATHNAME | File::FNM_EXTGLOB
67
67
 
68
68
  uris = @included_patterns.flat_map do |pattern|
69
- load_path_entry = T.let(nil, T.nilable(String))
69
+ load_path_entry = nil #: String?
70
70
 
71
71
  Dir.glob(File.join(@workspace_path, pattern), flags).map! do |path|
72
72
  # All entries for the same pattern match the same $LOAD_PATH entry. Since searching the $LOAD_PATH for every
@@ -1023,7 +1023,7 @@ module RubyIndexer
1023
1023
  # Otherwise, push all of the leading parts of the nesting that aren't redundant into the name. For example, if we
1024
1024
  # have a reference to `Foo::Bar` inside the `[Namespace, Foo]` nesting, then only the `Foo` part is redundant, but
1025
1025
  # we still need to include the `Namespace` part
1026
- T.unsafe(name_parts).unshift(*nesting[0...first_redundant_part])
1026
+ name_parts.unshift(*nesting[0...first_redundant_part])
1027
1027
  name_parts.join("::")
1028
1028
  end
1029
1029
 
@@ -56,8 +56,13 @@ module RubyLsp
56
56
  @encoding = global_state.encoding #: Encoding
57
57
  @uri = uri #: URI::Generic
58
58
  @needs_parsing = true #: bool
59
- @parse_result = T.unsafe(nil) #: ParseResultType
60
59
  @last_edit = nil #: Edit?
60
+
61
+ # Workaround to be able to type parse_result properly. It is immediately set when invoking parse!
62
+ @parse_result = ( # rubocop:disable Style/RedundantParentheses
63
+ nil #: as untyped
64
+ ) #: ParseResultType
65
+
61
66
  parse!
62
67
  end
63
68
 
@@ -93,9 +93,9 @@ module RubyLsp
93
93
  if examples.empty?
94
94
  "^#{group_regex}(#|::)"
95
95
  elsif examples.length == 1
96
- "^#{group_regex}##{examples[0]}$"
96
+ "^#{group_regex}##{examples[0]}\\$"
97
97
  else
98
- "^#{group_regex}#(#{examples.join("|")})$"
98
+ "^#{group_regex}#(#{examples.join("|")})\\$"
99
99
  end
100
100
  end
101
101
 
@@ -116,13 +116,13 @@ module RubyLsp
116
116
  Shellwords.escape(TestDiscovery::DYNAMIC_REFERENCE_MARKER),
117
117
  ".*",
118
118
  )
119
- command = +"#{BASE_COMMAND} -Itest #{file_path} --testcase \"/^#{group_regex}$/\""
119
+ command = +"#{BASE_COMMAND} -Itest #{file_path} --testcase \"/^#{group_regex}\\$/\""
120
120
 
121
121
  unless examples.empty?
122
122
  command << if examples.length == 1
123
- " --name \"/#{examples[0]}$/\""
123
+ " --name \"/#{examples[0]}\\$/\""
124
124
  else
125
- " --name \"/(#{examples.join("|")})$/\""
125
+ " --name \"/(#{examples.join("|")})\\$/\""
126
126
  end
127
127
  end
128
128
 
@@ -115,10 +115,10 @@ module RubyLsp
115
115
 
116
116
  # Find the node with the end line closest to the requested position, so that we can place the refactor
117
117
  # immediately after that closest node
118
- closest_node = T.must(closest_statements.child_nodes.compact.min_by do |node|
118
+ closest_node = closest_statements.child_nodes.compact.min_by do |node|
119
119
  distance = source_range.dig(:start, :line) - (node.location.end_line - 1)
120
120
  distance <= 0 ? Float::INFINITY : distance
121
- end)
121
+ end #: as !nil
122
122
 
123
123
  return Error::InvalidTargetRange if closest_node.is_a?(Prism::MissingNode)
124
124
 
@@ -380,16 +380,14 @@ module RubyLsp
380
380
 
381
381
  attribute_name = node.name[1..]
382
382
  indentation = " " * (closest_node.location.start_column + 2)
383
- attribute_accessor_source = T.must(
384
- case @code_action[:title]
385
- when CodeActions::CREATE_ATTRIBUTE_READER
386
- "#{indentation}attr_reader :#{attribute_name}\n\n"
387
- when CodeActions::CREATE_ATTRIBUTE_WRITER
388
- "#{indentation}attr_writer :#{attribute_name}\n\n"
389
- when CodeActions::CREATE_ATTRIBUTE_ACCESSOR
390
- "#{indentation}attr_accessor :#{attribute_name}\n\n"
391
- end,
392
- )
383
+ attribute_accessor_source = case @code_action[:title]
384
+ when CodeActions::CREATE_ATTRIBUTE_READER
385
+ "#{indentation}attr_reader :#{attribute_name}\n\n"
386
+ when CodeActions::CREATE_ATTRIBUTE_WRITER
387
+ "#{indentation}attr_writer :#{attribute_name}\n\n"
388
+ when CodeActions::CREATE_ATTRIBUTE_ACCESSOR
389
+ "#{indentation}attr_accessor :#{attribute_name}\n\n"
390
+ end #: as !nil
393
391
 
394
392
  target_start_line = closest_node.location.start_line
395
393
  target_range = {
@@ -32,7 +32,7 @@ module RubyLsp
32
32
  next unless node
33
33
 
34
34
  range = Support::SelectionRange.new(range: range_from_location(node.location), parent: parent)
35
- T.unsafe(queue).unshift(*node.child_nodes.map { |child| [child, range] })
35
+ queue.unshift(*node.child_nodes.map { |child| [child, range] })
36
36
  @ranges.unshift(range)
37
37
  end
38
38
 
@@ -46,7 +46,7 @@ module RubyLsp
46
46
  if (start_char..end_char).cover?(loc.start_offset..loc.end_offset)
47
47
  found_nodes << node
48
48
  else
49
- T.unsafe(queue).unshift(*node.child_nodes)
49
+ queue.unshift(*node.child_nodes)
50
50
  end
51
51
  end
52
52
 
@@ -21,8 +21,10 @@ module URI
21
21
  # have the uri gem in their own bundle and thus not use a compatible version.
22
22
  PARSER = const_defined?(:RFC2396_PARSER) ? RFC2396_PARSER : DEFAULT_PARSER #: RFC2396_Parser
23
23
 
24
- T.unsafe(self).alias_method(:gem_name, :host)
25
- T.unsafe(self).alias_method(:line_number, :fragment)
24
+ self #: as untyped # rubocop:disable Style/RedundantSelf
25
+ .alias_method(:gem_name, :host)
26
+ self #: as untyped # rubocop:disable Style/RedundantSelf
27
+ .alias_method(:line_number, :fragment)
26
28
 
27
29
  #: String?
28
30
  attr_reader :gem_version
@@ -53,7 +53,7 @@ module RubyLsp
53
53
  # Add the next child_nodes to the queue to be processed. The order here is important! We want to move in the
54
54
  # same order as the visiting mechanism, which means searching the child nodes before moving on to the next
55
55
  # sibling
56
- T.unsafe(queue).unshift(*candidate.child_nodes)
56
+ queue.unshift(*candidate.child_nodes)
57
57
 
58
58
  # Skip if the current node doesn't cover the desired position
59
59
  loc = candidate.location
@@ -195,7 +195,7 @@ module RubyLsp
195
195
  # Add the next child_nodes to the queue to be processed. The order here is important! We want to move in the
196
196
  # same order as the visiting mechanism, which means searching the child nodes before moving on to the next
197
197
  # sibling
198
- T.unsafe(queue).unshift(*candidate.child_nodes)
198
+ queue.unshift(*candidate.child_nodes)
199
199
 
200
200
  # Skip if the current node doesn't cover the desired position
201
201
  loc = candidate.location
@@ -1062,7 +1062,8 @@ module RubyLsp
1062
1062
  end
1063
1063
 
1064
1064
  Addon.file_watcher_addons.each do |addon|
1065
- T.unsafe(addon).workspace_did_change_watched_files(changes)
1065
+ addon #: as untyped
1066
+ .workspace_did_change_watched_files(changes)
1066
1067
  rescue => e
1067
1068
  send_log_message(
1068
1069
  "Error in #{addon.name} add-on while processing watched file notifications: #{e.full_message}",
@@ -260,7 +260,8 @@ module RubyLsp
260
260
  # The ENV can only be merged after checking if an update is required because we depend on the original value of
261
261
  # ENV["BUNDLE_GEMFILE"], which gets overridden after the merge
262
262
  should_update = should_bundle_update?
263
- T.unsafe(ENV).merge!(env)
263
+ ENV #: as untyped
264
+ .merge!(env)
264
265
 
265
266
  unless should_update && !force_install
266
267
  Bundler::CLI::Install.new({ "no-cache" => true }).run
@@ -23,6 +23,17 @@ module RubyLsp
23
23
 
24
24
  #: -> void
25
25
  def shutdown
26
+ # When running in coverage mode, we don't want to inform the extension that we finished immediately after running
27
+ # tests. We only do it after we finish processing coverage results, by invoking `internal_shutdown`
28
+ return if ENV["RUBY_LSP_TEST_RUNNER"] == "coverage"
29
+
30
+ internal_shutdown
31
+ end
32
+
33
+ # This method is intended to be used by the RubyLsp::LspReporter class itself only. If you're writing a custom test
34
+ # reporter, use `shutdown` instead
35
+ #: -> void
36
+ def internal_shutdown
26
37
  send_message("finish")
27
38
  @io.close
28
39
  end
@@ -148,5 +159,6 @@ if ENV["RUBY_LSP_TEST_RUNNER"] == "coverage"
148
159
  at_exit do
149
160
  coverage_results = RubyLsp::LspReporter.instance.gather_coverage_results
150
161
  File.write(File.join(".ruby-lsp", "coverage_result.json"), coverage_results.to_json)
162
+ RubyLsp::LspReporter.instance.internal_shutdown
151
163
  end
152
164
  end
@@ -137,7 +137,12 @@ module RubyLsp
137
137
  #: -> Hash[Symbol, untyped]
138
138
  def to_hash
139
139
  hash = { method: @method }
140
- hash[:params] = T.unsafe(@params).to_hash if @params
140
+
141
+ if @params
142
+ hash[:params] = @params #: as untyped
143
+ .to_hash
144
+ end
145
+
141
146
  hash
142
147
  end
143
148
  end
@@ -181,7 +186,12 @@ module RubyLsp
181
186
  #: -> Hash[Symbol, untyped]
182
187
  def to_hash
183
188
  hash = { id: @id, method: @method }
184
- hash[:params] = T.unsafe(@params).to_hash if @params
189
+
190
+ if @params
191
+ hash[:params] = @params #: as untyped
192
+ .to_hash
193
+ end
194
+
185
195
  hash
186
196
  end
187
197
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.15
4
+ version: 0.23.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify