Sha256: 7c3594e51cc858b31ada6e885dd142ae7daccff2b2fdd635415e182ee1ee7e39

Contents?: true

Size: 1.82 KB

Versions: 9

Compression:

Stored size: 1.82 KB

Contents

#!/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 "ruby_lsp/load_sorbet"

$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "ruby_lsp/internal"

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 = {}
server = RubyLsp::Server.new(test_mode: true)

files.each_with_index do |file, index|
  uri = URI("file://#{file}")
  server.process_message({
    method: "textDocument/didOpen",
    params: { textDocument: { uri: uri, text: File.read(file), version: 1 } },
  })

  # Executing any of the automatic requests will execute all of them, so here we just pick one
  server.process_message({
    id: 1,
    method: "textDocument/documentSymbol",
    params: { textDocument: { uri: uri } },
  })

  result = server.pop_response
  errors[file] = result if result.is_a?(RubyLsp::Error)
ensure
  server.process_message({ method: "textDocument/didClose", params: { textDocument: { uri: uri } } })
  server.pop_response
  print("\033[M\033[0KCompleted #{index + 1}/#{files.length}") unless ENV["CI"]
end
puts "\n"

# Indexing
puts "Verifying that indexing executes successfully. This may take a while..."

index = RubyIndexer::Index.new
indexables = index.configuration.indexables

indexables.each_with_index do |indexable, i|
  index.index_single(indexable)
rescue => e
  errors[indexable.full_path] = e
ensure
  print("\033[M\033[0KIndexed #{i + 1}/#{indexables.length}") unless ENV["CI"]
end
puts "\n"

if errors.empty?
  puts "All operations completed successfully!"
  exit
end

puts <<~ERRORS
  Errors while executing:

  #{errors.map { |file, error| "#{file}: #{error.message}" }.join("\n")}
ERRORS
exit!

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby-lsp-0.22.1 exe/ruby-lsp-check
ruby-lsp-0.22.0 exe/ruby-lsp-check
ruby-lsp-0.21.3 exe/ruby-lsp-check
ruby-lsp-0.21.2 exe/ruby-lsp-check
ruby-lsp-0.21.1 exe/ruby-lsp-check
ruby-lsp-0.21.0 exe/ruby-lsp-check
ruby-lsp-0.20.1 exe/ruby-lsp-check
ruby-lsp-0.20.0 exe/ruby-lsp-check
ruby-lsp-0.19.1 exe/ruby-lsp-check