38 const std::vector<std::string> &NewNames,
39 const std::vector<std::string> &PrevNames,
40 const std::vector<std::vector<std::string>> &USRList,
41 std::map<std::string, tooling::Replacements> &FileToReplaces,
43 : NewNames(NewNames), PrevNames(PrevNames), USRList(USRList),
44 FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
47 for (
unsigned I = 0;
I < NewNames.size(); ++
I)
48 HandleOneRename(Context, NewNames[
I], PrevNames[I], USRList[I]);
53 const std::vector<std::string> &USRs) {
55 std::vector<SourceLocation> RenamingCandidates;
56 std::vector<SourceLocation> NewCandidates;
60 RenamingCandidates.insert(RenamingCandidates.end(), NewCandidates.begin(),
63 unsigned PrevNameLen = PrevName.length();
64 for (
const auto &Loc : RenamingCandidates) {
67 errs() <<
"clang-rename: renamed at: " << SourceMgr.
getFilename(Loc)
73 llvm::Error Err = FileToReplaces[Replace.
getFilePath()].add(Replace);
75 llvm::errs() <<
"Renaming failed in " << Replace.
getFilePath() <<
"! "
81 const std::vector<std::string> &NewNames, &PrevNames;
82 const std::vector<std::vector<std::string>> &USRList;
83 std::map<std::string, tooling::Replacements> &FileToReplaces;
94 const std::vector<std::vector<std::string>> &USRList,
95 std::map<std::string, tooling::Replacements> &FileToReplaces)
96 : NewNames(NewNames), USRList(USRList), FileToReplaces(FileToReplaces) {
97 assert(USRList.size() == NewNames.size());
101 for (
unsigned I = 0;
I < NewNames.size(); ++
I) {
108 llvm::Error Err = FileToReplaces[Replace.getFilePath()].add(Replace);
110 llvm::errs() <<
"Renaming failed in " << Replace.getFilePath()
119 const std::vector<std::string> &NewNames;
120 const std::vector<std::vector<std::string>> &USRList;
121 std::map<std::string, tooling::Replacements> &FileToReplaces;
124 std::unique_ptr<ASTConsumer> RenamingAction::newASTConsumer() {
125 return llvm::make_unique<RenamingASTConsumer>(NewNames, PrevNames, USRList,
126 FileToReplaces, PrintLocations);
129 std::unique_ptr<ASTConsumer> QualifiedRenamingAction::newASTConsumer() {
130 return llvm::make_unique<USRSymbolRenamer>(NewNames, USRList, FileToReplaces);
Defines the clang::ASTContext interface.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
Defines the clang::FileManager interface and associated types.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
detail::InMemoryDirectory::const_iterator I
const std::string PrevName
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
Provides functionality for finding all instances of a USR in a given AST.
TranslationUnitDecl * getTranslationUnitDecl() const
Defines the clang::Preprocessor interface.
unsigned getSpellingLineNumber(bool *Invalid=nullptr) const
std::string toString(const til::SExpr *E)
SourceManager & getSourceManager()
A SourceLocation and its associated SourceManager.
Defines the clang::FrontendAction interface and various convenience abstract classes (clang::ASTFront...
Provides an action to rename every symbol at a point.
This class handles loading and caching of source files into memory.
unsigned getSpellingColumnNumber(bool *Invalid=nullptr) const