diff --git a/lib/rubocop/lsp/routes.rb b/lib/rubocop/lsp/routes.rb index 8d7c40d08fda..27ba1fc4a328 100644 --- a/lib/rubocop/lsp/routes.rb +++ b/lib/rubocop/lsp/routes.rb @@ -73,9 +73,7 @@ def for(name) end handle 'textDocument/diagnostic' do |request| - doc = request[:params][:textDocument] - result = diagnostic(doc[:uri], doc[:text]) - @server.write(result) + # no-op, diagnostics are handled in textDocument/didChange end handle 'textDocument/didChange' do |request| diff --git a/spec/rubocop/lsp/server_spec.rb b/spec/rubocop/lsp/server_spec.rb index 678d57738bf7..595a9ab2f1b7 100644 --- a/spec/rubocop/lsp/server_spec.rb +++ b/spec/rubocop/lsp/server_spec.rb @@ -103,10 +103,7 @@ method: 'textDocument/diagnostic', params: { textDocument: { - languageId: 'ruby', - text: "def hi#{eol} [1, 2,#{eol} 3 ]#{eol}end#{eol}", - uri: 'file:///path/to/file.rb', - version: 0 + uri: 'file:///path/to/file.rb' } } ] @@ -114,32 +111,7 @@ it 'handles requests' do expect(stderr).to eq('') - expect(messages.count).to eq(1) - expect(messages.first).to eq( - jsonrpc: '2.0', - method: 'textDocument/publishDiagnostics', - params: { - diagnostics: [ - { - code: 'Style/FrozenStringLiteralComment', - message: 'Missing frozen string literal comment.', - range: { - start: { character: 0, line: 0 }, end: { character: 0, line: 0 } - }, - severity: 3, - source: 'rubocop' - }, { - 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: 'rubocop' - } - ], uri: 'file:///path/to/file.rb' - } - ) + expect(messages.count).to eq(0) end end