diff --git a/lib/standard/lsp/routes.rb b/lib/standard/lsp/routes.rb index 3afad197..88e53b8f 100644 --- a/lib/standard/lsp/routes.rb +++ b/lib/standard/lsp/routes.rb @@ -13,7 +13,7 @@ def initialize(writer, logger, standardizer) end def self.handle(name, &block) - define_method("handle_#{name}", &block) + define_method(:"handle_#{name}", &block) end def for(name) @@ -51,10 +51,8 @@ def for(name) end end - handle "textDocument/diagnostic" do |request| - doc = request[:params][:textDocument] - result = diagnostic(doc[:uri], doc[:text]) - @writer.write(result) + handle "textDocument/diagnostic" do |_request| + # no op, diagnostics are handled in textDocument/didChange end handle "textDocument/didChange" do |request| diff --git a/test/standard/runners/lsp_test.rb b/test/standard/runners/lsp_test.rb index 4d013baf..4869fecc 100644 --- a/test/standard/runners/lsp_test.rb +++ b/test/standard/runners/lsp_test.rb @@ -72,40 +72,13 @@ def test_diagnotic_route jsonrpc: "2.0", params: { textDocument: { - languageId: "ruby", - text: "def hi\n [1, 2,\n 3 ]\nend\n", - uri: "file:///path/to/file.rb", - version: 0 + uri: "file:///path/to/file.rb" } } }) assert_equal "", err.string - assert_equal 1, msgs.count - assert_equal({ - method: "textDocument/publishDiagnostics", - params: { - diagnostics: [ - {code: "Layout/ArrayAlignment", - message: "Use one level of indentation for elements following the first line of a multi-line array.", - range: {start: {character: 3, line: 2}, end: {character: 3, line: 2}}, - severity: 3, - source: "standard"}, - {code: "Layout/ExtraSpacing", - message: "Unnecessary spacing detected.", - range: {start: {character: 4, line: 2}, end: {character: 4, line: 2}}, - severity: 3, - source: "standard"}, - {code: "Layout/SpaceInsideArrayLiteralBrackets", - message: "Do not use space inside array brackets.", - range: {start: {character: 4, line: 2}, end: {character: 5, line: 2}}, - severity: 3, - source: "standard"} - ], - uri: "file:///path/to/file.rb" - }, - jsonrpc: "2.0" - }, msgs.first) + assert_equal 0, msgs.count end def test_format