From 2c08391153efdbe34cf07746ceca8b068c431306 Mon Sep 17 00:00:00 2001 From: Ryan Schlesinger Date: Mon, 29 Apr 2024 11:12:55 -0300 Subject: [PATCH] LSP: Don't advertise support for Pull Diagnostics Standard doesn't actually support the Pull Diagnostics that were added in LSP 3.17. It supports Push Diagnostics just fine. Pull Diagnostics: Advertise support via diagnosticProvider in the server capabilities. Respond to textDocument/diagnostic with diagnostics. Note that the textDocument/diagnostic message does not include the text to be diagnosed. Push Diagnostics: At some point after receiving a textDocument/didOpen or a textDocument/didChange, send a textDocument/publishDiagnostics to the client. Pull Diagnostics give the client more control over when diagnostics are computed and received and are preferred going forward. Since Standard doesn't actually support them (yet?) we shouldn't advertise that we do. --- lib/standard/lsp/routes.rb | 8 -------- test/standard/runners/lsp_test.rb | 18 +----------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/lib/standard/lsp/routes.rb b/lib/standard/lsp/routes.rb index 88e53b8f..ca07c202 100644 --- a/lib/standard/lsp/routes.rb +++ b/lib/standard/lsp/routes.rb @@ -27,10 +27,6 @@ def for(name) @writer.write(id: request[:id], result: Proto::Interface::InitializeResult.new( capabilities: Proto::Interface::ServerCapabilities.new( document_formatting_provider: true, - diagnostic_provider: LanguageServer::Protocol::Interface::DiagnosticOptions.new( - inter_file_dependencies: false, - workspace_diagnostics: false - ), text_document_sync: Proto::Interface::TextDocumentSyncOptions.new( change: Proto::Constant::TextDocumentSyncKind::FULL, open_close: true @@ -51,10 +47,6 @@ def for(name) end end - handle "textDocument/diagnostic" do |_request| - # no op, diagnostics are handled in textDocument/didChange - end - handle "textDocument/didChange" do |request| params = request[:params] result = diagnostic(params[:textDocument][:uri], params[:contentChanges][0][:text]) diff --git a/test/standard/runners/lsp_test.rb b/test/standard/runners/lsp_test.rb index 4869fecc..35366a80 100644 --- a/test/standard/runners/lsp_test.rb +++ b/test/standard/runners/lsp_test.rb @@ -17,8 +17,7 @@ def test_server_initializes_and_responds_with_proper_capabilities id: 2, result: {capabilities: { textDocumentSync: {openClose: true, change: 1}, - documentFormattingProvider: true, - diagnosticProvider: {interFileDependencies: false, workspaceDiagnostics: false} + documentFormattingProvider: true }}, jsonrpc: "2.0" } @@ -66,21 +65,6 @@ def test_did_open }, msgs.first) end - def test_diagnotic_route - msgs, err = run_server_on_requests({ - method: "textDocument/diagnostic", - jsonrpc: "2.0", - params: { - textDocument: { - uri: "file:///path/to/file.rb" - } - } - }) - - assert_equal "", err.string - assert_equal 0, msgs.count - end - def test_format msgs, err = run_server_on_requests( {