load_addons()
def load_addons
Addon.load_addons(@global_state, @outgoing_queue)
errored_addons = Addon.addons.select(&:error?)
if errored_addons.any?
send_message(
Notification.new(
method: "window/showMessage",
params: Interface::ShowMessageParams.new(
type: Constant::MessageType::WARNING,
message: "Error loading addons:\n\n#{errored_addons.map(&:formatted_errors).join("\n\n")}",
),
),
)
$stderr.puts(errored_addons.map(&:backtraces).join("\n\n"))
end
end
process_message(message)
def process_message(message)
case message[:method]
when "initialize"
$stderr.puts("Initializing Ruby LSP v#{VERSION}...")
run_initialize(message)
when "initialized"
$stderr.puts("Finished initializing Ruby LSP!") unless @test_mode
run_initialized
when "textDocument/didOpen"
text_document_did_open(message)
when "textDocument/didClose"
text_document_did_close(message)
when "textDocument/didChange"
text_document_did_change(message)
when "textDocument/selectionRange"
text_document_selection_range(message)
when "textDocument/documentSymbol"
text_document_document_symbol(message)
when "textDocument/documentLink"
text_document_document_link(message)
when "textDocument/codeLens"
text_document_code_lens(message)
when "textDocument/semanticTokens/full"
text_document_semantic_tokens_full(message)
when "textDocument/foldingRange"
text_document_folding_range(message)
when "textDocument/semanticTokens/range"
text_document_semantic_tokens_range(message)
when "textDocument/formatting"
text_document_formatting(message)
when "textDocument/documentHighlight"
text_document_document_highlight(message)
when "textDocument/onTypeFormatting"
text_document_on_type_formatting(message)
when "textDocument/hover"
text_document_hover(message)
when "textDocument/inlayHint"
text_document_inlay_hint(message)
when "textDocument/codeAction"
text_document_code_action(message)
when "codeAction/resolve"
code_action_resolve(message)
when "textDocument/diagnostic"
text_document_diagnostic(message)
when "textDocument/completion"
text_document_completion(message)
when "completionItem/resolve"
text_document_completion_item_resolve(message)
when "textDocument/signatureHelp"
text_document_signature_help(message)
when "textDocument/definition"
text_document_definition(message)
when "workspace/didChangeWatchedFiles"
workspace_did_change_watched_files(message)
when "workspace/symbol"
workspace_symbol(message)
when "rubyLsp/textDocument/showSyntaxTree"
text_document_show_syntax_tree(message)
when "rubyLsp/workspace/dependencies"
workspace_dependencies(message)
when "$/cancelRequest"
@mutex.synchronize { @cancelled_requests << message[:params][:id] }
end
rescue StandardError, LoadError => e
if message[:id]
send_message(Error.new(id: message[:id], code: Constant::ErrorCodes::INTERNAL_ERROR, message: e.full_message))
end
$stderr.puts("Error processing #{message[:method]}: #{e.full_message}")
end