I'm writing a language server. It delivers additional DiagnosticRelatedInformation as part of its diagnostics response. Just like in https://code.visualstudio.com/updates/v1_22#_related-information-in-errors-and-warnings. Currently, though while I do see the main error being displayed both in the "Problems" window and in the main text area, the additional "relatedInformation" is nowhere to be seen.
I suspect there may be two reasons for this. Either clientside: the capability of displaying this information is not enabled in VS Code. At least when the protocol is initiated, this capability is nowhere to be seen, here is the initial JSON message from the client:
[Trace - 2:22:13 PM] Sending request 'initialize - (0)'.
Params: {
"processId": 6640,
"rootPath": null,
"rootUri": null,
"capabilities": {
"workspace": {
"applyEdit": true,
"didChangeConfiguration": {
"dynamicRegistration": true
},
"didChangeWatchedFiles": {
"dynamicRegistration": true
},
"symbol": {
"dynamicRegistration": true
},
"executeCommand": {
"dynamicRegistration": true
}
},
"textDocument": {
"synchronization": {
"dynamicRegistration": true,
"willSave": true,
"willSaveWaitUntil": true,
"didSave": true
},
"completion": {
"dynamicRegistration": true,
"completionItem": {
"snippetSupport": true,
"commitCharactersSupport": true
}
},
"hover": {
"dynamicRegistration": true
},
"signatureHelp": {
"dynamicRegistration": true
},
"definition": {
"dynamicRegistration": true
},
"references": {
"dynamicRegistration": true
},
"documentHighlight": {
"dynamicRegistration": true
},
"documentSymbol": {
"dynamicRegistration": true
},
"codeAction": {
"dynamicRegistration": true
},
"codeLens": {
"dynamicRegistration": true
},
"formatting": {
"dynamicRegistration": true
},
"rangeFormatting": {
"dynamicRegistration": true
},
"onTypeFormatting": {
"dynamicRegistration": true
},
"rename": {
"dynamicRegistration": true
},
"documentLink": {
"dynamicRegistration": true
}
}
},
"trace": "verbose"
}
I'm using VS Code 1.28.2 on Win10, by the way.
The other reason may be serverside: the response that contains the diagnostics may be misformed. It looks like this:
Params: {
"diagnostics": [
{
"code": null,
"message": "the declaration of 'x' shadows an existing declaration",
"range": {
"end": {
"character": 17,
"line": 8
},
"start": {
"character": 17,
"line": 8
}
},
"relatedInformation": [
{
"location": {
"uri": "file:///c%3A/Users/blabla/XlocalShadow3.blc",
"range": {
"end": {
"character": 13,
"line": 6
},
"start": {
"character": 13,
"line": 6
}
}
},
"message": "existing declaration"
},
{
"location": {
"uri": "file:///c%3A/Users/blabla/XlocalShadow3.blc",
"range": {
"end": {
"character": 17,
"line": 8
},
"start": {
"character": 17,
"line": 8
}
}
},
"message": "shadowing declaration"
}
],
"severity": {
"_tag": 0
},
"source": "Parsing Error"
}
],
"uri": "file:///c%3A/Users/blabla/XlocalShadow3.blc"
}
At least the URIs are correct (though modified for readability here) since I can click on them and the editor does jump to the correct file.
My problem is I do not see how to test the one or the other hypothesis about what is going wrong. Or maybe I am missing something completely different?
The problem simply was an outdated version of vscode-languageclient
in the dependencies section of package.json. The feature was implemented in 4.1.0 but since my project is a bit dated it required only something above 3.5. I have now updated to the newest version and everything works.