forked from OSchip/llvm-project
[Clangd] Failed to decode params using 1.x-compatible request message
textDocument/completion sends a TextDocumentPositionParams message in the 2.x and 3.x. But in 1.x it was instead a TextDocumentPosition with inlined parameters. This means that the "uri" field is at the top level and not in textDocument. Because of this, some clients that maintain compability with 1.x have both uri and textDocument.uri. Clangd, however, early returns in the presence of anything but 'textDocument' or 'position' which prevents a client compatible with both 3.x and 1.x to work correctly. If Clangd was a bit more permissive (no early return), clients implementing all the versions of the protocol would work. Patch by Marc-Andre Laperle! Differential Revision: https://reviews.llvm.org/D32238 llvm-svn: 300991
This commit is contained in:
parent
8c3ba63d07
commit
d3326a04e0
|
@ -648,7 +648,7 @@ TextDocumentPositionParams::parse(llvm::yaml::MappingNode *Params) {
|
|||
auto *Value =
|
||||
dyn_cast_or_null<llvm::yaml::MappingNode>(NextKeyValue.getValue());
|
||||
if (!Value)
|
||||
return llvm::None;
|
||||
continue;
|
||||
|
||||
llvm::SmallString<10> Storage;
|
||||
if (KeyValue == "textDocument") {
|
||||
|
|
|
@ -30,6 +30,17 @@ Content-Length: 146
|
|||
# CHECK-DAG: {"label":"bb","kind":5}
|
||||
# CHECK-DAG: {"label":"ccc","kind":5}
|
||||
# CHECK: ]}
|
||||
|
||||
Content-Length: 172
|
||||
|
||||
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
|
||||
# Test params parsing in the presence of a 1.x-compatible client (inlined "uri")
|
||||
#
|
||||
# CHECK: {"jsonrpc":"2.0","id":1,"result":[
|
||||
# CHECK-DAG: {"label":"a","kind":5}
|
||||
# CHECK-DAG: {"label":"bb","kind":5}
|
||||
# CHECK-DAG: {"label":"ccc","kind":5}
|
||||
# CHECK: ]}
|
||||
Content-Length: 44
|
||||
|
||||
{"jsonrpc":"2.0","id":3,"method":"shutdown"}
|
||||
|
|
Loading…
Reference in New Issue