From 21b6da35f1d5c8ee50c14fa4e498b6c46ac4bc0f Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 29 Jun 2023 13:57:36 +0200 Subject: [PATCH] [clangd] Don't show header for namespace decl in Hover The header for namespace symbol is barely useful. Differential Revision: https://reviews.llvm.org/D154068 --- clang-tools-extra/clangd/Hover.cpp | 5 ++++- clang-tools-extra/clangd/unittests/HoverTests.cpp | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 5184fcb..fbd0be0 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -1374,7 +1374,10 @@ std::optional getHover(ParsedAST &AST, Position Pos, if (!HI->Value) HI->Value = printExprValue(N, AST.getASTContext()).PrintedValue; maybeAddCalleeArgInfo(N, *HI, PP); - maybeAddSymbolProviders(AST, *HI, include_cleaner::Symbol{*DeclToUse}); + + if (!isa(DeclToUse)) + maybeAddSymbolProviders(AST, *HI, + include_cleaner::Symbol{*DeclToUse}); } else if (const Expr *E = N->ASTNode.get()) { HoverCountMetric.record(1, "expr"); HI = getHoverContents(N, E, AST, PP, Index); diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 7002e27..0f45e78 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -3059,7 +3059,13 @@ TEST(Hover, Providers) { } 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}; -- 2.7.4