[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)
kadir çetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 5 02:38:58 PST 2024
================
@@ -569,8 +571,43 @@ renameWithinFile(ParsedAST &AST, const NamedDecl &RenameDecl,
// }
if (!isInsideMainFile(RenameLoc, SM))
continue;
+ Locs.push_back(RenameLoc);
+ }
+ if (const auto *MD = dyn_cast<ObjCMethodDecl>(&RenameDecl)) {
+ auto Code = SM.getBufferData(SM.getMainFileID());
+ auto RenameIdentifier = MD->getSelector().getNameForSlot(0).str();
+ llvm::SmallVector<llvm::StringRef, 8> NewNames;
+ NewName.split(NewNames, ":");
+ if (NewNames.empty())
+ NewNames.push_back(NewName);
+ std::vector<Range> Ranges;
+ const auto &LangOpts = RenameDecl.getASTContext().getLangOpts();
+ for (const auto &Loc : Locs)
+ Ranges.push_back(tokenRangeForLoc(Loc, SM, LangOpts));
+ auto FilePath = AST.tuPath();
+ auto RenameRanges =
+ adjustRenameRanges(Code, RenameIdentifier,
----------------
kadircet wrote:
we don't need to adjust ranges again in here. we're already using ranges from the AST (not from index)
https://github.com/llvm/llvm-project/pull/76466
More information about the cfe-commits
mailing list