[PATCH] D107365: clangd: Make documentation property of completion items more similar

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 12 15:18:41 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b28835b3754: clangd: Make documentation property of completion items more similar (authored by ckandeler, committed by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D107365?vs=364790&id=366128#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107365/new/

https://reviews.llvm.org/D107365

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -907,7 +907,7 @@
   auto Results = completions(
       R"cpp(
       // Non-doxygen comment.
-      int foo();
+      __attribute__((annotate("custom_annotation"))) int foo();
       /// Doxygen comment.
       /// \param int a
       int bar(int a);
@@ -919,7 +919,8 @@
       int x = ^
      )cpp");
   EXPECT_THAT(Results.Completions,
-              Contains(AllOf(Named("foo"), Doc("Non-doxygen comment."))));
+              Contains(AllOf(Named("foo"),
+              Doc("Annotation: custom_annotation\nNon-doxygen comment."))));
   EXPECT_THAT(
       Results.Completions,
       Contains(AllOf(Named("bar"), Doc("Doxygen comment.\n\\param int a"))));
Index: clang-tools-extra/clangd/CodeComplete.cpp
===================================================================
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -403,8 +403,9 @@
       if (C.IndexResult) {
         SetDoc(C.IndexResult->Documentation);
       } else if (C.SemaResult) {
-        SetDoc(getDocComment(*ASTCtx, *C.SemaResult,
-                             /*CommentsFromHeader=*/false));
+        const auto DocComment = getDocComment(*ASTCtx, *C.SemaResult,
+                                              /*CommentsFromHeader=*/false);
+        SetDoc(formatDocumentation(*SemaCCS, DocComment));
       }
     }
     if (Completion.Deprecated) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107365.366128.patch
Type: text/x-patch
Size: 1629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210812/1a6a4eb5/attachment-0001.bin>


More information about the cfe-commits mailing list