[PATCH] D73035: [clangd] Avoid redundant testcases in rename unittest, NFC.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 20 08:04:24 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3de9a5db629a: [clangd] Avoid redundant testcases in rename unittest, NFC. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73035/new/
https://reviews.llvm.org/D73035
Files:
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -722,7 +722,7 @@
void onDiagnosticsReady(PathRef File,
std::vector<Diag> Diagnostics) override {}
} DiagConsumer;
- // rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
+ // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
// expected rename occurrences.
struct Case {
llvm::StringRef FooH;
@@ -763,28 +763,10 @@
)cpp",
},
{
- // Constructor.
+ // rename on constructor and destructor.
R"cpp(
class [[Foo]] {
[[^Foo]]();
- ~[[Foo]]();
- };
- )cpp",
- R"cpp(
- #include "foo.h"
- [[Foo]]::[[Foo]]() {}
- [[Foo]]::~[[Foo]]() {}
-
- void func() {
- [[Foo]] foo;
- }
- )cpp",
- },
- {
- // Destructor (selecting before the identifier).
- R"cpp(
- class [[Foo]] {
- [[Foo]]();
~[[Foo^]]();
};
)cpp",
@@ -891,12 +873,15 @@
runAddDocument(Server, FooCCPath, FooCC.code());
llvm::StringRef NewName = "NewName";
- auto FileEditsList =
- llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
- EXPECT_THAT(applyEdits(std::move(FileEditsList)),
- UnorderedElementsAre(
- Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
- Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName)))));
+ for (const auto &RenamePos : FooH.points()) {
+ auto FileEditsList =
+ llvm::cantFail(runRename(Server, FooHPath, RenamePos, NewName));
+ EXPECT_THAT(
+ applyEdits(std::move(FileEditsList)),
+ UnorderedElementsAre(
+ Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
+ Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName)))));
+ }
}
}
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -215,7 +215,7 @@
// getUSRsForDeclaration will find other related symbols, e.g. virtual and its
// overriddens, primary template and all explicit specializations.
// FIXME: Get rid of the remaining tooling APIs.
- const auto RenameDecl =
+ const auto *RenameDecl =
ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
std::vector<std::string> RenameUSRs =
tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73035.239138.patch
Type: text/x-patch
Size: 2825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200120/15830403/attachment-0001.bin>
More information about the cfe-commits
mailing list