[PATCH] D37101: [clangd] [WIP] Add support for snippet completions

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 1 02:35:07 PDT 2017


ilya-biryukov added a comment.

This looks like a useful change even without prior changes to VSCode.

Maybe add a command-line flag to clangd(`--enable-snippets`) and commit that?
When snippets are disabled, we could simply do `insertText =  /*<item name>*/` after `ProcessChunks`, we will deprecate and remove that flag eventually when all the clients support it.



================
Comment at: clangd/ClangdUnit.cpp:337
+    // Fill in the kind field of the CompletionItem.
+    Item.kind = getKind(Result.CursorKind);
+
----------------
Could we also set `Item.filterText` to completion item name?
So that various pieces of function signature would not match on user input.


================
Comment at: clangd/ClangdUnit.cpp:419
+        assert(item.detail.empty() && "Unexpected extraneous CK_ResultType");
+        Item.detail = Chunk.Text;
+        break;
----------------
Won't that assertion fail with function return types? Let's add a test for that.

```
int (*foo(int a))(float);
```


https://reviews.llvm.org/D37101





More information about the cfe-commits mailing list