This revision was automatically updated to reflect the committed changes.
Closed by commit rL335718: [clangd] Do not show namespace comments. (authored 
by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48211

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


Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -1179,6 +1179,10 @@
   ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
 
   Annotations Source(R"cpp(
+    // We ignore namespace comments, for rationale see CodeCompletionStrings.h.
+    namespace comments_ns {
+    }
+
     // ------------------
     int comments_foo();
 
@@ -1223,6 +1227,7 @@
       UnorderedElementsAre(AllOf(Not(IsDocumented()), Named("comments_foo")),
                            AllOf(IsDocumented(), Named("comments_baz")),
                            AllOf(IsDocumented(), Named("comments_quux")),
+                           AllOf(Not(IsDocumented()), Named("comments_ns")),
                            // FIXME(ibiryukov): the following items should have
                            // empty documentation, since they are separated 
from
                            // a comment with an empty line. Unfortunately, I
Index: clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp
+++ clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp
@@ -80,8 +80,16 @@
   if (Result.Kind != CodeCompletionResult::RK_Declaration)
     return "";
   auto *Decl = Result.getDeclaration();
-  if (!Decl || !canRequestComment(Ctx, *Decl, CommentsFromHeaders))
+  if (!Decl || llvm::isa<NamespaceDecl>(Decl)) {
+    // Namespaces often have too many redecls for any particular redecl comment
+    // to be useful. Moreover, we often confuse file headers or generated
+    // comments with namespace comments. Therefore we choose to just ignore
+    // the comments for namespaces.
     return "";
+  }
+  if (!canRequestComment(Ctx, *Decl, CommentsFromHeaders))
+    return "";
+
   const RawComment *RC = getCompletionComment(Ctx, Decl);
   if (!RC)
     return "";


Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -1179,6 +1179,10 @@
   ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
 
   Annotations Source(R"cpp(
+    // We ignore namespace comments, for rationale see CodeCompletionStrings.h.
+    namespace comments_ns {
+    }
+
     // ------------------
     int comments_foo();
 
@@ -1223,6 +1227,7 @@
       UnorderedElementsAre(AllOf(Not(IsDocumented()), Named("comments_foo")),
                            AllOf(IsDocumented(), Named("comments_baz")),
                            AllOf(IsDocumented(), Named("comments_quux")),
+                           AllOf(Not(IsDocumented()), Named("comments_ns")),
                            // FIXME(ibiryukov): the following items should have
                            // empty documentation, since they are separated from
                            // a comment with an empty line. Unfortunately, I
Index: clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp
+++ clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp
@@ -80,8 +80,16 @@
   if (Result.Kind != CodeCompletionResult::RK_Declaration)
     return "";
   auto *Decl = Result.getDeclaration();
-  if (!Decl || !canRequestComment(Ctx, *Decl, CommentsFromHeaders))
+  if (!Decl || llvm::isa<NamespaceDecl>(Decl)) {
+    // Namespaces often have too many redecls for any particular redecl comment
+    // to be useful. Moreover, we often confuse file headers or generated
+    // comments with namespace comments. Therefore we choose to just ignore
+    // the comments for namespaces.
     return "";
+  }
+  if (!canRequestComment(Ctx, *Decl, CommentsFromHeaders))
+    return "";
+
   const RawComment *RC = getCompletionComment(Ctx, Decl);
   if (!RC)
     return "";
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to