[PATCH] D154068: [clangd] Don't show header for namespace decl in Hover

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 29 05:04:10 PDT 2023


hokein created this revision.
hokein added a reviewer: VitaNuo.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

The header for namespace symbol is barely useful.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154068

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3059,7 +3059,13 @@
                   }
                   ns::F^oo d;
                 )cpp",
-                [](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }}};
+                [](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+                {R"cpp(
+                  namespace foo {};
+                  using namespace fo^o;
+                )cpp",
+                [](HoverInfo &HI) { HI.Provider = ""; }},        
+                };
 
   for (const auto &Case : Cases) {
     Annotations Code{Case.Code};
Index: clang-tools-extra/clangd/Hover.cpp
===================================================================
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -1374,7 +1374,10 @@
         if (!HI->Value)
           HI->Value = printExprValue(N, AST.getASTContext()).PrintedValue;
         maybeAddCalleeArgInfo(N, *HI, PP);
-        maybeAddSymbolProviders(AST, *HI, include_cleaner::Symbol{*DeclToUse});
+
+        if (!isa<NamespaceDecl>(DeclToUse))
+          maybeAddSymbolProviders(AST, *HI,
+                                  include_cleaner::Symbol{*DeclToUse});
       } else if (const Expr *E = N->ASTNode.get<Expr>()) {
         HoverCountMetric.record(1, "expr");
         HI = getHoverContents(N, E, AST, PP, Index);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154068.535732.patch
Type: text/x-patch
Size: 1516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230629/34087d8f/attachment.bin>


More information about the cfe-commits mailing list