-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,6 @@ jobs: | |
|
||
- name: Run tests | ||
run: bundle exec rake | ||
|
||
- name: Run ruby-lsp-check | ||
run: bundle exec ruby-lsp-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
# This executable checks if all automatic LSP requests run successfully on every Ruby file under the current directory | ||
|
||
require "sorbet-runtime" | ||
|
||
begin | ||
T::Configuration.default_checked_level = :never | ||
T::Configuration.call_validation_error_handler = ->(*) {} | ||
T::Configuration.inline_type_error_handler = ->(*) {} | ||
T::Configuration.sig_validation_error_handler = ->(*) {} | ||
rescue | ||
nil | ||
end | ||
|
||
require_relative "../lib/ruby_lsp/internal" | ||
|
||
RubyLsp::Extension.load_extensions | ||
|
||
T::Utils.run_all_sig_blocks | ||
|
||
files = Dir.glob("#{Dir.pwd}/**/*.rb") | ||
|
||
puts "Verifying that all automatic LSP requests execute successfully. This may take a while..." | ||
|
||
errors = {} | ||
store = RubyLsp::Store.new | ||
message_queue = Thread::Queue.new | ||
executor = RubyLsp::Executor.new(store, message_queue) | ||
|
||
files.each_with_index do |file, index| | ||
uri = "file://#{file}" | ||
store.set(uri: uri, source: File.read(file), version: 1) | ||
|
||
# Executing any of the automatic requests will execute all of them, so here we just pick one | ||
result = executor.execute({ | ||
method: "textDocument/documentSymbol", | ||
params: { textDocument: { uri: uri } }, | ||
}) | ||
|
||
error = result.error | ||
errors[file] = error if error | ||
ensure | ||
store.delete(uri) | ||
print("\033[M\033[0KCompleted #{index + 1}/#{files.length}") | ||
end | ||
|
||
puts "\n" | ||
message_queue.close | ||
|
||
if errors.empty? | ||
puts "All automatic LSP requests executed successfully" | ||
exit | ||
end | ||
|
||
puts <<~ERRORS | ||
Errors while executing requests: | ||
#{errors.map { |file, error| "#{file}: #{error.message}" }.join("\n")} | ||
ERRORS | ||
exit! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters