clang  5.0.0
RenamingAction.h
Go to the documentation of this file.
1 //===--- RenamingAction.h - Clang refactoring library ---------------------===//
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_TOOLING_REFACTOR_RENAME_RENAMING_ACTION_H
16 #define LLVM_CLANG_TOOLING_REFACTOR_RENAME_RENAMING_ACTION_H
17 
19 
20 namespace clang {
21 class ASTConsumer;
22 class CompilerInstance;
23 
24 namespace tooling {
25 
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.
47 public:
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  : 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 } // end namespace tooling
68 } // end namespace clang
69 
70 #endif // LLVM_CLANG_TOOLING_REFACTOR_RENAME_RENAMING_ACTION_H
RenamingAction(const std::vector< std::string > &NewNames, const std::vector< std::string > &PrevNames, const std::vector< std::vector< std::string >> &USRList, std::map< std::string, tooling::Replacements > &FileToReplaces, bool PrintLocations=false)
std::unique_ptr< ASTConsumer > newASTConsumer()
QualifiedRenamingAction(const std::vector< std::string > &NewNames, const std::vector< std::vector< std::string >> &USRList, std::map< std::string, tooling::Replacements > &FileToReplaces)
Rename all symbols identified by the given USRs.
std::unique_ptr< ASTConsumer > newASTConsumer()