ruby-lsp 0.26.6 → 0.26.7
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/exe/ruby-lsp-launcher +5 -1
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +7 -1
- data/lib/ruby_lsp/setup_bundler.rb +2 -1
- data/lib/ruby_lsp/test_reporters/lsp_reporter.rb +43 -28
- data/lib/ruby_lsp/test_reporters/minitest_reporter.rb +1 -1
- data/lib/ruby_lsp/test_reporters/test_unit_reporter.rb +1 -1
- 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: a2fb06df12b49f414c218bd2cb6a1ef5b817dff076894fa6e2ae6585a370f172
|
|
4
|
+
data.tar.gz: b9fef2a34f9361b8f4b3f74ecb3c64d53226964293bb01f4b7400ce1688746e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e2c4674e72af204f3b4c78b6053e205c9a4c7ffd5b99642cf78db3c469c0334f3952e3326c7b091b54974e2cd523716dcb8c0b1c17d861b9f80f87bbedd4056
|
|
7
|
+
data.tar.gz: d3aaba57e7f33f5a46bdd12a69f7c965e50bcb95049032e1ee12c21d538f4d3ffc6220e798abd0fa6488085f9cb45fea468e7a9318097b16ba9d73923e2ea9a5
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.26.
|
|
1
|
+
0.26.7
|
data/exe/ruby-lsp-launcher
CHANGED
|
@@ -101,7 +101,7 @@ begin
|
|
|
101
101
|
Bundler.setup
|
|
102
102
|
$stderr.puts("Composed Bundle set up successfully")
|
|
103
103
|
end
|
|
104
|
-
rescue Bundler::GemNotFound, Bundler::GitError
|
|
104
|
+
rescue Bundler::GemNotFound, Bundler::GitError => e
|
|
105
105
|
# Sometimes, we successfully set up the bundle, but users either change their Gemfile or uninstall gems from an
|
|
106
106
|
# external process. If there's no install error, but the gem is still not found, then we need to attempt to start from
|
|
107
107
|
# scratch
|
|
@@ -113,6 +113,10 @@ rescue Bundler::GemNotFound, Bundler::GitError
|
|
|
113
113
|
exec(Gem.ruby, __FILE__, *ARGV, "--retry")
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
|
+
|
|
117
|
+
setup_error = e
|
|
118
|
+
$stderr.puts("Failed to set up composed Bundle\n#{e.full_message}")
|
|
119
|
+
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
|
|
116
120
|
rescue StandardError => e
|
|
117
121
|
setup_error = e
|
|
118
122
|
$stderr.puts("Failed to set up composed Bundle\n#{e.full_message}")
|
|
@@ -14,6 +14,12 @@ module RubyLsp
|
|
|
14
14
|
fatal: Constant::DiagnosticSeverity::ERROR,
|
|
15
15
|
}.freeze #: Hash[Symbol, Integer]
|
|
16
16
|
|
|
17
|
+
# Cops where adding a `rubocop:disable` inline comment would itself resolve the offense,
|
|
18
|
+
# causing Lint/RedundantCopDisableDirective to flag the disable as unnecessary.
|
|
19
|
+
SELF_RESOLVING_DISABLE_COPS = Set.new([
|
|
20
|
+
"Layout/EmptyComment",
|
|
21
|
+
]).freeze #: Set[String]
|
|
22
|
+
|
|
17
23
|
ENHANCED_DOC_URL = begin
|
|
18
24
|
gem("rubocop", ">= 1.64.0")
|
|
19
25
|
true
|
|
@@ -35,7 +41,7 @@ module RubyLsp
|
|
|
35
41
|
code_actions = []
|
|
36
42
|
|
|
37
43
|
code_actions << autocorrect_action if correctable?
|
|
38
|
-
code_actions << disable_line_action
|
|
44
|
+
code_actions << disable_line_action unless SELF_RESOLVING_DISABLE_COPS.include?(@offense.cop_name)
|
|
39
45
|
|
|
40
46
|
code_actions
|
|
41
47
|
end
|
|
@@ -126,6 +126,7 @@ module RubyLsp
|
|
|
126
126
|
return run_bundle_install(@custom_gemfile)
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
+
@needs_update_path.delete if @needs_update_path.exist?
|
|
129
130
|
FileUtils.cp(@lockfile.to_s, @custom_lockfile.to_s)
|
|
130
131
|
correct_relative_remote_paths
|
|
131
132
|
@lockfile_hash_path.write(@lockfile_hash)
|
|
@@ -340,7 +341,7 @@ module RubyLsp
|
|
|
340
341
|
|
|
341
342
|
Bundler::CLI::Update.new({ conservative: true }, gems).run
|
|
342
343
|
correct_relative_remote_paths if @custom_lockfile.exist?
|
|
343
|
-
@needs_update_path.delete
|
|
344
|
+
@needs_update_path.delete if @needs_update_path.exist?
|
|
344
345
|
@last_updated_path.write(Time.now.iso8601)
|
|
345
346
|
env
|
|
346
347
|
end
|
|
@@ -4,13 +4,40 @@
|
|
|
4
4
|
require "English"
|
|
5
5
|
require "json"
|
|
6
6
|
require "socket"
|
|
7
|
-
require "singleton"
|
|
8
7
|
require "tmpdir"
|
|
9
8
|
require_relative "../../ruby_indexer/lib/ruby_indexer/uri"
|
|
10
9
|
|
|
11
10
|
module RubyLsp
|
|
12
11
|
class LspReporter
|
|
13
|
-
|
|
12
|
+
@instance = nil #: LspReporter?
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
#: -> LspReporter
|
|
16
|
+
def instance
|
|
17
|
+
@instance ||= new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
#: -> bool
|
|
21
|
+
def start_coverage?
|
|
22
|
+
ENV["RUBY_LSP_TEST_RUNNER"] == "coverage"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
#: -> bool
|
|
26
|
+
def executed_under_test_runner?
|
|
27
|
+
!!(ENV["RUBY_LSP_TEST_RUNNER"] && ENV["RUBY_LSP_ENV"] != "test")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#: (Method | UnboundMethod) -> [URI::Generic, Integer?]?
|
|
31
|
+
def uri_and_line_for(method_object)
|
|
32
|
+
file_path, line = method_object.source_location
|
|
33
|
+
return unless file_path
|
|
34
|
+
return if file_path.start_with?("(eval at ")
|
|
35
|
+
|
|
36
|
+
uri = URI::Generic.from_path(path: File.expand_path(file_path))
|
|
37
|
+
zero_based_line = line ? line - 1 : nil
|
|
38
|
+
[uri, zero_based_line]
|
|
39
|
+
end
|
|
40
|
+
end
|
|
14
41
|
|
|
15
42
|
# https://code.visualstudio.com/api/references/vscode-api#Position
|
|
16
43
|
#: type position = { line: Integer, character: Integer }
|
|
@@ -50,6 +77,8 @@ module RubyLsp
|
|
|
50
77
|
end #: IO | StringIO
|
|
51
78
|
|
|
52
79
|
@invoked_shutdown = false #: bool
|
|
80
|
+
@message_queue = Thread::Queue.new #: Thread::Queue
|
|
81
|
+
@writer = Thread.new { write_loop } #: Thread
|
|
53
82
|
end
|
|
54
83
|
|
|
55
84
|
#: -> void
|
|
@@ -68,6 +97,8 @@ module RubyLsp
|
|
|
68
97
|
@invoked_shutdown = true
|
|
69
98
|
|
|
70
99
|
send_message("finish")
|
|
100
|
+
@message_queue.close
|
|
101
|
+
@writer.join
|
|
71
102
|
@io.close
|
|
72
103
|
end
|
|
73
104
|
|
|
@@ -96,17 +127,6 @@ module RubyLsp
|
|
|
96
127
|
send_message("error", id: id, message: message, uri: uri.to_s)
|
|
97
128
|
end
|
|
98
129
|
|
|
99
|
-
#: (Method | UnboundMethod) -> [URI::Generic, Integer?]?
|
|
100
|
-
def uri_and_line_for(method_object)
|
|
101
|
-
file_path, line = method_object.source_location
|
|
102
|
-
return unless file_path
|
|
103
|
-
return if file_path.start_with?("(eval at ")
|
|
104
|
-
|
|
105
|
-
uri = URI::Generic.from_path(path: File.expand_path(file_path))
|
|
106
|
-
zero_based_line = line ? line - 1 : nil
|
|
107
|
-
[uri, zero_based_line]
|
|
108
|
-
end
|
|
109
|
-
|
|
110
130
|
# Gather the results returned by Coverage.result and format like the VS Code test explorer expects
|
|
111
131
|
#
|
|
112
132
|
# Coverage result format:
|
|
@@ -195,23 +215,11 @@ module RubyLsp
|
|
|
195
215
|
internal_shutdown unless @invoked_shutdown
|
|
196
216
|
end
|
|
197
217
|
|
|
198
|
-
class << self
|
|
199
|
-
#: -> bool
|
|
200
|
-
def start_coverage?
|
|
201
|
-
ENV["RUBY_LSP_TEST_RUNNER"] == "coverage"
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
#: -> bool
|
|
205
|
-
def executed_under_test_runner?
|
|
206
|
-
!!(ENV["RUBY_LSP_TEST_RUNNER"] && ENV["RUBY_LSP_ENV"] != "test")
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
|
|
210
218
|
private
|
|
211
219
|
|
|
212
|
-
#: (String) ->
|
|
220
|
+
#: (String) -> Socket
|
|
213
221
|
def socket(port)
|
|
214
|
-
socket =
|
|
222
|
+
socket = Socket.tcp("localhost", port)
|
|
215
223
|
socket.binmode
|
|
216
224
|
socket.sync = true
|
|
217
225
|
socket
|
|
@@ -220,7 +228,14 @@ module RubyLsp
|
|
|
220
228
|
#: (String?, **untyped) -> void
|
|
221
229
|
def send_message(method_name, **params)
|
|
222
230
|
json_message = { method: method_name, params: params }.to_json
|
|
223
|
-
@
|
|
231
|
+
@message_queue << "Content-Length: #{json_message.bytesize}\r\n\r\n#{json_message}"
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
#: -> void
|
|
235
|
+
def write_loop
|
|
236
|
+
while (message = @message_queue.pop)
|
|
237
|
+
@io.write(message)
|
|
238
|
+
end
|
|
224
239
|
end
|
|
225
240
|
end
|
|
226
241
|
end
|
|
@@ -89,7 +89,7 @@ module RubyLsp
|
|
|
89
89
|
test_class_or_wrapper
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
uri, line = LspReporter.
|
|
92
|
+
uri, line = LspReporter.uri_and_line_for(klass.instance_method(method_name))
|
|
93
93
|
return unless uri
|
|
94
94
|
|
|
95
95
|
id = "#{name}##{handle_spec_test_id(method_name, line)}"
|