forked from OSchip/llvm-project
[clangd] Retire the cross-file-rename command-line flag.
This patch only focuses on the flag. Removing actual single-file mode (and the flag in RenameOption) will come in a follow-up. Differential Revision: https://reviews.llvm.org/D96495
This commit is contained in:
parent
3cad308ce5
commit
573348ab9b
|
@ -29,7 +29,7 @@ using DirtyBufferGetter =
|
||||||
struct RenameOptions {
|
struct RenameOptions {
|
||||||
/// If true, enable cross-file rename; otherwise, only allows to rename a
|
/// If true, enable cross-file rename; otherwise, only allows to rename a
|
||||||
/// symbol that's only used in the current file.
|
/// symbol that's only used in the current file.
|
||||||
bool AllowCrossFile = false;
|
bool AllowCrossFile = true;
|
||||||
/// The maximum number of affected files (0 means no limit), only meaningful
|
/// The maximum number of affected files (0 means no limit), only meaningful
|
||||||
/// when AllowCrossFile = true.
|
/// when AllowCrossFile = true.
|
||||||
/// If the actual number exceeds the limit, rename is forbidden.
|
/// If the actual number exceeds the limit, rename is forbidden.
|
||||||
|
|
|
@ -286,6 +286,7 @@ RetiredFlag<bool> RecoveryAST("recovery-ast");
|
||||||
RetiredFlag<bool> RecoveryASTType("recovery-ast-type");
|
RetiredFlag<bool> RecoveryASTType("recovery-ast-type");
|
||||||
RetiredFlag<bool> AsyncPreamble("async-preamble");
|
RetiredFlag<bool> AsyncPreamble("async-preamble");
|
||||||
RetiredFlag<bool> CollectMainFileRefs("collect-main-file-refs");
|
RetiredFlag<bool> CollectMainFileRefs("collect-main-file-refs");
|
||||||
|
RetiredFlag<bool> CrossFileRename("cross-file-rename");
|
||||||
|
|
||||||
opt<int> LimitResults{
|
opt<int> LimitResults{
|
||||||
"limit-results",
|
"limit-results",
|
||||||
|
@ -295,7 +296,6 @@ opt<int> LimitResults{
|
||||||
init(100),
|
init(100),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
list<std::string> TweakList{
|
list<std::string> TweakList{
|
||||||
"tweaks",
|
"tweaks",
|
||||||
cat(Features),
|
cat(Features),
|
||||||
|
@ -304,13 +304,6 @@ list<std::string> TweakList{
|
||||||
CommaSeparated,
|
CommaSeparated,
|
||||||
};
|
};
|
||||||
|
|
||||||
opt<bool> CrossFileRename{
|
|
||||||
"cross-file-rename",
|
|
||||||
cat(Features),
|
|
||||||
desc("Enable cross-file rename feature."),
|
|
||||||
init(true),
|
|
||||||
};
|
|
||||||
|
|
||||||
opt<bool> FoldingRanges{
|
opt<bool> FoldingRanges{
|
||||||
"folding-ranges",
|
"folding-ranges",
|
||||||
cat(Features),
|
cat(Features),
|
||||||
|
@ -852,9 +845,6 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
|
||||||
if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
|
if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
|
||||||
Opts.Encoding = ForceOffsetEncoding;
|
Opts.Encoding = ForceOffsetEncoding;
|
||||||
|
|
||||||
// Shall we allow to customize the file limit?
|
|
||||||
Opts.Rename.AllowCrossFile = CrossFileRename;
|
|
||||||
|
|
||||||
if (CheckFile.getNumOccurrences()) {
|
if (CheckFile.getNumOccurrences()) {
|
||||||
llvm::SmallString<256> Path;
|
llvm::SmallString<256> Path;
|
||||||
llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true);
|
llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true);
|
||||||
|
|
|
@ -832,8 +832,12 @@ TEST(RenameTest, WithinFileRename) {
|
||||||
TU.ExtraArgs.push_back("-xobjective-c++");
|
TU.ExtraArgs.push_back("-xobjective-c++");
|
||||||
auto AST = TU.build();
|
auto AST = TU.build();
|
||||||
for (const auto &RenamePos : Code.points()) {
|
for (const auto &RenamePos : Code.points()) {
|
||||||
auto RenameResult =
|
auto RenameResult = rename({RenamePos,
|
||||||
rename({RenamePos, NewName, AST, testPath(TU.Filename)});
|
NewName,
|
||||||
|
AST,
|
||||||
|
testPath(TU.Filename),
|
||||||
|
/*Index*/ nullptr,
|
||||||
|
{/*CrossFile*/ false}});
|
||||||
ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
|
ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
|
||||||
ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
|
ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
|
@ -1133,8 +1137,12 @@ TEST(RenameTest, Renameable) {
|
||||||
}
|
}
|
||||||
auto AST = TU.build();
|
auto AST = TU.build();
|
||||||
llvm::StringRef NewName = Case.NewName;
|
llvm::StringRef NewName = Case.NewName;
|
||||||
auto Results =
|
auto Results = rename({T.point(),
|
||||||
rename({T.point(), NewName, AST, testPath(TU.Filename), Case.Index});
|
NewName,
|
||||||
|
AST,
|
||||||
|
testPath(TU.Filename),
|
||||||
|
Case.Index,
|
||||||
|
{/*CrossFile=*/false}});
|
||||||
bool WantRename = true;
|
bool WantRename = true;
|
||||||
if (T.ranges().empty())
|
if (T.ranges().empty())
|
||||||
WantRename = false;
|
WantRename = false;
|
||||||
|
|
Loading…
Reference in New Issue