[PATCH] D34033: [clangd] Add parameter and return type information to completion results
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 8 08:12:19 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304980: [clangd] Add parameter and return type information to completion results (authored by krasimir).
Changed prior to commit:
https://reviews.llvm.org/D34033?vs=101921&id=101925#toc
Repository:
rL LLVM
https://reviews.llvm.org/D34033
Files:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/test/clangd/completion.test
Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -138,9 +138,21 @@
CodeCompleteOpts.IncludeBriefComments);
if (CCS) {
CompletionItem Item;
+ for (CodeCompletionString::Chunk C : *CCS) {
+ switch (C.Kind) {
+ case CodeCompletionString::CK_ResultType:
+ Item.detail = C.Text;
+ break;
+ case CodeCompletionString::CK_Optional:
+ break;
+ default:
+ Item.label += C.Text;
+ break;
+ }
+ }
assert(CCS->getTypedText());
- Item.label = CCS->getTypedText();
Item.kind = getKind(Result.CursorKind);
+ Item.insertText = Item.sortText = Item.filterText = CCS->getTypedText();
if (CCS->getBriefComment())
Item.documentation = CCS->getBriefComment();
Items->push_back(std::move(Item));
Index: clang-tools-extra/trunk/test/clangd/completion.test
===================================================================
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/test/clangd/completion.test
@@ -5,41 +5,40 @@
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
-Content-Length: 211
+Content-Length: 246
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; };\nint main() {\n fake f;\n f.\n}\n"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n fake f;\n f.\n}\n"}}}
Content-Length: 148
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
# The order of results returned by ASTUnit CodeComplete seems to be
# nondeterministic, so we check regardless of order.
#
# 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-DAG: {"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"bb","filterText":"bb","insertText":"bb"}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"ccc","filterText":"ccc","insertText":"ccc"}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"operator=","filterText":"operator=","insertText":"operator="}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"}
+# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"}
# CHECK: ]}
Content-Length: 146
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
# Test authority-less 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-DAG: {"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
# 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-DAG: {"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
# CHECK: ]}
Content-Length: 44
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34033.101925.patch
Type: text/x-patch
Size: 4236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170608/d0101bc5/attachment-0001.bin>
More information about the cfe-commits
mailing list