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 +4 -4
- data/VERSION +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +1 -1
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +1 -1
- data/lib/ruby_lsp/document.rb +6 -1
- data/lib/ruby_lsp/listeners/test_style.rb +5 -5
- data/lib/ruby_lsp/requests/code_action_resolve.rb +10 -12
- data/lib/ruby_lsp/requests/selection_ranges.rb +1 -1
- data/lib/ruby_lsp/requests/show_syntax_tree.rb +1 -1
- data/lib/ruby_lsp/requests/support/source_uri.rb +4 -2
- data/lib/ruby_lsp/ruby_document.rb +2 -2
- data/lib/ruby_lsp/server.rb +2 -1
- data/lib/ruby_lsp/setup_bundler.rb +2 -1
- data/lib/ruby_lsp/test_reporters/lsp_reporter.rb +12 -0
- data/lib/ruby_lsp/utils.rb +12 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c17ad9bdfcbd63ad18912cd0247475f9a0b3739dd6ffae489a72d0d2b4b1d77
|
4
|
+
data.tar.gz: 3681e153bac6f08236fbd1f875a6fbafbb4c523af187f7471c798be8d3d40b7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 669a6d69961413145b35aec0d81dbcb0507e1d856f4534c70af38946dd43e9ee6f20a07fcb44e5f3ff7515de8ac47546d95ff7542a8756ce9b693ad35b70f20e
|
7
|
+
data.tar.gz: 11d7d9dd59c2cb216b49c5cc3ec7fa2cc1eda781a6394185fec614f287b0f707a363fc49aa3700cea7659c1735ea447a0d5c96d0ea81944eff96ae41c9fb4cda
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.23.
|
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 =
|
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
|
-
|
1026
|
+
name_parts.unshift(*nesting[0...first_redundant_part])
|
1027
1027
|
name_parts.join("::")
|
1028
1028
|
end
|
1029
1029
|
|
data/lib/ruby_lsp/document.rb
CHANGED
@@ -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 =
|
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 =
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
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
|
-
|
35
|
+
queue.unshift(*node.child_nodes.map { |child| [child, range] })
|
36
36
|
@ranges.unshift(range)
|
37
37
|
end
|
38
38
|
|
@@ -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
|
-
|
25
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/ruby_lsp/server.rb
CHANGED
@@ -1062,7 +1062,8 @@ module RubyLsp
|
|
1062
1062
|
end
|
1063
1063
|
|
1064
1064
|
Addon.file_watcher_addons.each do |addon|
|
1065
|
-
|
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
|
-
|
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
|
data/lib/ruby_lsp/utils.rb
CHANGED
@@ -137,7 +137,12 @@ module RubyLsp
|
|
137
137
|
#: -> Hash[Symbol, untyped]
|
138
138
|
def to_hash
|
139
139
|
hash = { method: @method }
|
140
|
-
|
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
|
-
|
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
|