Line data Source code
1 : //===--- tools/extra/clang-rename/RenamingAction.h - Clang rename tool ----===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 : ///
10 : /// \file
11 : /// \brief Provides an action to rename every symbol at a point.
12 : ///
13 : //===----------------------------------------------------------------------===//
14 :
15 : #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_RENAMING_ACTION_H
16 : #define LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_RENAMING_ACTION_H
17 :
18 : #include "clang/Tooling/Refactoring.h"
19 :
20 : namespace clang {
21 : class ASTConsumer;
22 : class CompilerInstance;
23 :
24 : namespace rename {
25 :
26 : class RenamingAction {
27 : public:
28 : RenamingAction(const std::vector<std::string> &NewNames,
29 : const std::vector<std::string> &PrevNames,
30 : const std::vector<std::vector<std::string>> &USRList,
31 : std::map<std::string, tooling::Replacements> &FileToReplaces,
32 : bool PrintLocations = false)
33 : : NewNames(NewNames), PrevNames(PrevNames), USRList(USRList),
34 : FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
35 :
36 : std::unique_ptr<ASTConsumer> newASTConsumer();
37 :
38 : private:
39 : const std::vector<std::string> &NewNames, &PrevNames;
40 : const std::vector<std::vector<std::string>> &USRList;
41 : std::map<std::string, tooling::Replacements> &FileToReplaces;
42 : bool PrintLocations;
43 : };
44 :
45 : /// Rename all symbols identified by the given USRs.
46 : class QualifiedRenamingAction {
47 : public:
48 : QualifiedRenamingAction(
49 : const std::vector<std::string> &NewNames,
50 : const std::vector<std::vector<std::string>> &USRList,
51 : std::map<std::string, tooling::Replacements> &FileToReplaces)
52 101 : : NewNames(NewNames), USRList(USRList), FileToReplaces(FileToReplaces) {}
53 :
54 : std::unique_ptr<ASTConsumer> newASTConsumer();
55 :
56 : private:
57 : /// New symbol names.
58 : const std::vector<std::string> &NewNames;
59 :
60 : /// A list of USRs. Each element represents USRs of a symbol being renamed.
61 : const std::vector<std::vector<std::string>> &USRList;
62 :
63 : /// A file path to replacements map.
64 : std::map<std::string, tooling::Replacements> &FileToReplaces;
65 : };
66 :
67 : } // namespace rename
68 : } // namespace clang
69 :
70 : #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_RENAMING_ACTION_H
|