forked from OSchip/llvm-project
[clangd] Do not offer "Add using" tweak in header files.
Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D79488
This commit is contained in:
parent
5010b5b7e6
commit
319787315d
|
@ -175,6 +175,12 @@ findInsertionPoint(const Tweak::Selection &Inputs,
|
|||
|
||||
bool AddUsing::prepare(const Selection &Inputs) {
|
||||
auto &SM = Inputs.AST->getSourceManager();
|
||||
|
||||
// Do not suggest "using" in header files. That way madness lies.
|
||||
if (isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
|
||||
Inputs.AST->getLangOpts()))
|
||||
return false;
|
||||
|
||||
auto *Node = Inputs.ASTSelection.commonAncestor();
|
||||
if (Node == nullptr)
|
||||
return false;
|
||||
|
|
|
@ -2463,6 +2463,13 @@ public:
|
|||
// test that we don't crash.
|
||||
EXPECT_UNAVAILABLE(Header +
|
||||
"template<typename TT> using foo = one::tt<T^T>;");
|
||||
|
||||
// Check that we do not trigger in header files.
|
||||
FileName = "test.h";
|
||||
ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.
|
||||
EXPECT_UNAVAILABLE(Header + "void fun() { one::two::f^f(); }");
|
||||
FileName = "test.hpp";
|
||||
EXPECT_UNAVAILABLE(Header + "void fun() { one::two::f^f(); }");
|
||||
}
|
||||
|
||||
TEST_F(AddUsingTest, Apply) {
|
||||
|
|
Loading…
Reference in New Issue