Skip to content

No diagnostics after the client responds to workspace/configuration #5464

@bstaletic

Description

@bstaletic

Because some other server required it, ycmd is doing the following:

  1. Send initialize request and wait for response.
  2. Send initialized notification.
  3. Send workspace/didChangeConfiguration notification.

This triggers workspace/configuration request, to which, provided no user configuration, ycmd will respond with [null]. This, however, results in rust-analyzer sending empty diagnostics until the next didSave notification.

Here's the full log of exchanged messages:

2020-07-20 21:46:58,432 - DEBUG - TX: Sending message: b'Content-Length: 1052\r\n\r\n{"id":1,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"experimental":{"statusNotification":true},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"documentationFormat":["plaintext","markdown"]},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"contentFormat":["plaintext","markdown"]},"signatureHelp":{"signatureInformation":{"documentationFormat":["plaintext","markdown"],"parameterInformation":{"labelOffsetSupport":false}}},"synchronization":{"didSave":true}},"workspace":{"configuration":true}},"initializationOptions":{},"processId":12969,"rootPath":"/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common","rootUri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common"}}'
2020-07-20 21:46:58,433 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"callHierarchyProvider":true,"codeActionProvider":{"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"]},"codeLensProvider":{"resolveProvider":true},"completionProvider":{"triggerCharacters":[":","."]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"=","moreTriggerCharacter":[".",">"]},"documentSymbolProvider":true,"experimental":{"joinLines":true,"onEnter":true,"parentModule":true,"runnables":{"kinds":["cargo"]},"ssr":true},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"documentProvider":true,"legend":{"tokenModifiers":["documentation","declaration","definition","static","abstract","deprecated","readonly","constant","controlFlow","injected","mutable","unsafe","attribute"],"tokenTypes":["comment","keyword","string","number","regexp","operator","namespace","type","struct","class","interface","enum","typeParameter","function","member","property","macro","variable","parameter","label","attribute","boolean","builtinType","enumMember","escapeSequence","formatSpecifier","generic","lifetime","selfKeyword","typeAlias","union","unresolvedReference"]},"rangeProvider":true},"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":{"change":2,"openClose":true,"save":{}},"typeDefinitionProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"rust-analyzer","version":"f5a4a4b"}}}'
2020-07-20 21:46:58,435 - DEBUG - TX: Sending notification: b'Content-Length: 52\r\n\r\n{"jsonrpc":"2.0","method":"initialized","params":{}}'
2020-07-20 21:46:58,435 - DEBUG - TX: Sending notification: b'Content-Length: 86\r\n\r\n{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}'
2020-07-20 21:46:58,436 - DEBUG - TX: Sending notification: b'Content-Length: 555\r\n\r\n{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"rust","text":"mod test;\\n\\nuse test::*;\\n\\nstruct Earth {}\\nstruct Mars {}\\ntrait Atmosphere {}\\nimpl Atmosphere for Earth {}\\nimpl Atmosphere for Mars {}\\n\\nfn main() {\\n    create_universe();\\n    let builder = Builder {};\\n    builder.build_\\n}\\n\\nfn             format_test() {\\n\\n    let\\n        a : \\ni32 = 5;\\n}\\n","uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common/src/main.rs","version":1}}}'
2020-07-20 21:46:58,437 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"textDocument/didSave","method":"textDocument/didSave","registerOptions":{"documentSelector":[{"pattern":"**/*.rs"},{"pattern":"**/Cargo.toml"},{"pattern":"**/Cargo.lock"}]}}]}}'
2020-07-20 21:46:58,437 - DEBUG - TX: Sending response: b'Content-Length: 38\r\n\r\n{"id":0,"jsonrpc":"2.0","result":null}'
2020-07-20 21:46:58,437 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]}}'
2020-07-20 21:46:58,437 - DEBUG - TX: Sending response: b'Content-Length: 40\r\n\r\n{"id":1,"jsonrpc":"2.0","result":[null]}'
2020-07-20 21:46:58,440 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"rust-analyzer/status","params":"invalid"}'
2020-07-20 21:46:58,441 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common/src/main.rs"}}'
2020-07-20 21:46:58,514 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"rust-analyzer/status","params":"loading"}'
2020-07-20 21:46:58,602 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"rust-analyzer/status","params":"ready"}'
2020-07-20 21:47:02,111 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common/src/main.rs"}}'
2020-07-20 21:47:07,142 - DEBUG - TX: Sending notification: b'Content-Length: 218\r\n\r\n{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common/src/main.rs","version":1}}}'
2020-07-20 21:47:07,673 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"E0609","message":"no field `build_` on type `test::Builder`\\nunknown field","range":{"end":{"character":18,"line":13},"start":{"character":12,"line":13}},"severity":1,"source":"rustc"}],"uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common/src/main.rs"}}'

On request, I can provide rust-analyzer's log too, just tell me at what verbosity level.

Another thing to note in the above log is that the first rust-analyzer/status is invalid, then loading and then ready. What's up with the invalid one?

Finally, contrast the above log with the following one, where ycmd returns an error response on worksapce/configuration.

2020-07-20 21:53:31,189 - DEBUG - TX: Sending message: b'Content-Length: 1232\r\n\r\n{"id":1,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"experimental":{"statusNotification":true},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"documentationFormat":["plaintext","markdown"]},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"contentFormat":["plaintext","markdown"]},"signatureHelp":{"signatureInformation":{"documentationFormat":["plaintext","markdown"],"parameterInformation":{"labelOffsetSupport":false}}},"synchronization":{"didSave":true}},"workspace":{"applyEdit":true,"didChangeWatchedFiles":{"dynamicRegistration":true},"documentChanges":true,"symbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}}}},"initializationOptions":{},"processId":14895,"rootPath":"/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common","rootUri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common"}}'
2020-07-20 21:53:31,190 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"callHierarchyProvider":true,"codeActionProvider":{"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"]},"codeLensProvider":{"resolveProvider":true},"completionProvider":{"triggerCharacters":[":","."]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"=","moreTriggerCharacter":[".",">"]},"documentSymbolProvider":true,"experimental":{"joinLines":true,"onEnter":true,"parentModule":true,"runnables":{"kinds":["cargo"]},"ssr":true},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"documentProvider":true,"legend":{"tokenModifiers":["documentation","declaration","definition","static","abstract","deprecated","readonly","constant","controlFlow","injected","mutable","unsafe","attribute"],"tokenTypes":["comment","keyword","string","number","regexp","operator","namespace","type","struct","class","interface","enum","typeParameter","function","member","property","macro","variable","parameter","label","attribute","boolean","builtinType","enumMember","escapeSequence","formatSpecifier","generic","lifetime","selfKeyword","typeAlias","union","unresolvedReference"]},"rangeProvider":true},"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":{"change":2,"openClose":true,"save":{}},"typeDefinitionProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"rust-analyzer","version":"f5a4a4b"}}}'
2020-07-20 21:53:31,191 - DEBUG - TX: Sending notification: b'Content-Length: 52\r\n\r\n{"jsonrpc":"2.0","method":"initialized","params":{}}'
2020-07-20 21:53:31,191 - DEBUG - TX: Sending notification: b'Content-Length: 86\r\n\r\n{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}'
2020-07-20 21:53:31,192 - DEBUG - Refreshing file /home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common/src/main.rs: State is Open/action Open
2020-07-20 21:53:31,192 - DEBUG - TX: Sending notification: b'Content-Length: 555\r\n\r\n{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"rust","text":"mod test;\\n\\nuse test::*;\\n\\nstruct Earth {}\\nstruct Mars {}\\ntrait Atmosphere {}\\nimpl Atmosphere for Earth {}\\nimpl Atmosphere for Mars {}\\n\\nfn main() {\\n    create_universe();\\n    let builder = Builder {};\\n    builder.build_\\n}\\n\\nfn             format_test() {\\n\\n    let\\n        a : \\ni32 = 5;\\n}\\n","uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common/src/main.rs","version":1}}}'
2020-07-20 21:53:31,193 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"textDocument/didSave","method":"textDocument/didSave","registerOptions":{"documentSelector":[{"pattern":"**/*.rs"},{"pattern":"**/Cargo.toml"},{"pattern":"**/Cargo.lock"}]}}]}}'
2020-07-20 21:53:31,193 - DEBUG - TX: Sending response: b'Content-Length: 38\r\n\r\n{"id":0,"jsonrpc":"2.0","result":null}'
2020-07-20 21:53:31,193 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]}}'
2020-07-20 21:53:31,193 - DEBUG - TX: Sending response: b'Content-Length: 77\r\n\r\n{"error":{"code":-32601,"message":"Method not found"},"id":1,"jsonrpc":"2.0"}'
2020-07-20 21:53:31,271 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"rust-analyzer/status","params":"loading"}'
2020-07-20 21:53:31,357 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"rust-analyzer/status","params":"ready"}'
2020-07-20 21:53:31,430 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"E0609","message":"no field `build_` on type `test::Builder`\\nunknown field","range":{"end":{"character":18,"line":13},"start":{"character":12,"line":13}},"severity":1,"source":"rustc"}],"uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common/src/main.rs"}}'
2020-07-20 21:53:34,870 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"E0609","message":"no field `build_` on type `test::Builder`\\nunknown field","range":{"end":{"character":18,"line":13},"start":{"character":12,"line":13}},"severity":1,"source":"rustc"}],"uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/rust/testdata/common/src/main.rs"}}'

Differences between the two:

  1. There's no invalid status at any point.
  2. Diagnostics arrive as expected.

Finally, I'm testing with this file/project: https://github.com/ycm-core/ycmd/blob/master/ycmd/tests/rust/testdata/common/src/main.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions