forked from OSchip/llvm-project
[clangd] Avoid redundant testcases in rename unittest, NFC.
Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73035
This commit is contained in:
parent
7fee4fed4c
commit
3de9a5db62
|
@ -215,7 +215,7 @@ std::vector<SourceLocation> findOccurrencesWithinFile(ParsedAST &AST,
|
||||||
// getUSRsForDeclaration will find other related symbols, e.g. virtual and its
|
// getUSRsForDeclaration will find other related symbols, e.g. virtual and its
|
||||||
// overriddens, primary template and all explicit specializations.
|
// overriddens, primary template and all explicit specializations.
|
||||||
// FIXME: Get rid of the remaining tooling APIs.
|
// FIXME: Get rid of the remaining tooling APIs.
|
||||||
const auto RenameDecl =
|
const auto *RenameDecl =
|
||||||
ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
|
ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
|
||||||
std::vector<std::string> RenameUSRs =
|
std::vector<std::string> RenameUSRs =
|
||||||
tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
|
tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
|
||||||
|
|
|
@ -722,7 +722,7 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
|
||||||
void onDiagnosticsReady(PathRef File,
|
void onDiagnosticsReady(PathRef File,
|
||||||
std::vector<Diag> Diagnostics) override {}
|
std::vector<Diag> Diagnostics) override {}
|
||||||
} DiagConsumer;
|
} 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.
|
// expected rename occurrences.
|
||||||
struct Case {
|
struct Case {
|
||||||
llvm::StringRef FooH;
|
llvm::StringRef FooH;
|
||||||
|
@ -763,28 +763,10 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
|
||||||
)cpp",
|
)cpp",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Constructor.
|
// rename on constructor and destructor.
|
||||||
R"cpp(
|
R"cpp(
|
||||||
class [[Foo]] {
|
class [[Foo]] {
|
||||||
[[^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^]]();
|
~[[Foo^]]();
|
||||||
};
|
};
|
||||||
)cpp",
|
)cpp",
|
||||||
|
@ -891,14 +873,17 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
|
||||||
runAddDocument(Server, FooCCPath, FooCC.code());
|
runAddDocument(Server, FooCCPath, FooCC.code());
|
||||||
|
|
||||||
llvm::StringRef NewName = "NewName";
|
llvm::StringRef NewName = "NewName";
|
||||||
|
for (const auto &RenamePos : FooH.points()) {
|
||||||
auto FileEditsList =
|
auto FileEditsList =
|
||||||
llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
|
llvm::cantFail(runRename(Server, FooHPath, RenamePos, NewName));
|
||||||
EXPECT_THAT(applyEdits(std::move(FileEditsList)),
|
EXPECT_THAT(
|
||||||
|
applyEdits(std::move(FileEditsList)),
|
||||||
UnorderedElementsAre(
|
UnorderedElementsAre(
|
||||||
Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
|
Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
|
||||||
Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName)))));
|
Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName)))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST(CrossFileRenameTests, CrossFileOnLocalSymbol) {
|
TEST(CrossFileRenameTests, CrossFileOnLocalSymbol) {
|
||||||
// cross-file rename should work for function-local symbols, even there is no
|
// cross-file rename should work for function-local symbols, even there is no
|
||||||
|
|
Loading…
Reference in New Issue