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

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 05:20:55 PDT 2017


krasimir added inline comments.


================
Comment at: clangd/ClangdUnit.cpp:302
                                   unsigned NumResults) override {
-    for (unsigned I = 0; I != NumResults; ++I) {
-      CodeCompletionResult &Result = Results[I];
-      CodeCompletionString *CCS = Result.CreateCodeCompletionString(
+    assert(Items && "We need a non-null items container here");
+    Items->reserve(NumResults);
----------------
Move this assert in the `CompletionItemsCollector` constructor.


================
Comment at: clangd/ClangdUnit.cpp:322
+                            const CodeCompletionString &CCS) const {
+    // The object that we'll return.
+    CompletionItem Item;
----------------
This comment is unnecessary.


================
Comment at: clangd/ClangdUnit.cpp:339
+      }
+      for (unsigned j = 0; j < CCS.getAnnotationCount(); ++j) {
+        Item.documentation += CCS.getAnnotation(j);
----------------
In LLVM, prefer using an explicit variable for the limit of iteration. In this case, since you're using `getAnnotationCount` before, you could directly put it into a variable above.


https://reviews.llvm.org/D37101





More information about the cfe-commits mailing list