| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef TOOLS_CLANG_REWRITE_TO_CHROME_STYLE_EDIT_TRACKER_H_ | 5 #ifndef TOOLS_CLANG_REWRITE_TO_CHROME_STYLE_EDIT_TRACKER_H_ |
| 6 #define TOOLS_CLANG_REWRITE_TO_CHROME_STYLE_EDIT_TRACKER_H_ | 6 #define TOOLS_CLANG_REWRITE_TO_CHROME_STYLE_EDIT_TRACKER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "clang/Basic/SourceLocation.h" | 10 #include "clang/Basic/SourceLocation.h" |
| 11 #include "clang/Basic/SourceManager.h" | 11 #include "clang/Basic/SourceManager.h" |
| 12 #include "llvm/ADT/StringMap.h" | 12 #include "llvm/ADT/StringMap.h" |
| 13 #include "llvm/ADT/StringRef.h" | 13 #include "llvm/ADT/StringRef.h" |
| 14 #include "llvm/ADT/StringSet.h" | 14 #include "llvm/ADT/StringSet.h" |
| 15 | 15 |
| 16 namespace llvm { | 16 namespace llvm { |
| 17 class raw_ostream; | 17 class raw_ostream; |
| 18 } // namespace llvm | 18 } // namespace llvm |
| 19 | 19 |
| 20 struct EditInfo { | 20 struct EditInfo { |
| 21 std::string new_text; | 21 std::string new_text; |
| 22 llvm::StringSet<> filenames; | 22 llvm::StringSet<> filenames; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 enum class RenameCategory { |
| 26 kEnumValue, |
| 27 kField, |
| 28 kFunction, |
| 29 kUnresolved, |
| 30 kVariable, |
| 31 }; |
| 32 |
| 25 // Simple class that tracks the edits made by path. Used to dump the databaes | 33 // Simple class that tracks the edits made by path. Used to dump the databaes |
| 26 // used by the Blink rebase helper. | 34 // used by the Blink rebase helper. |
| 27 class EditTracker { | 35 class EditTracker { |
| 28 public: | 36 public: |
| 29 EditTracker() = default; | 37 explicit EditTracker(RenameCategory category); |
| 30 | 38 |
| 31 void Add(const clang::SourceManager& source_manager, | 39 void Add(const clang::SourceManager& source_manager, |
| 32 clang::SourceLocation location, | 40 clang::SourceLocation location, |
| 33 llvm::StringRef original_text, | 41 llvm::StringRef original_text, |
| 34 llvm::StringRef new_text); | 42 llvm::StringRef new_text); |
| 35 | 43 |
| 36 // Serializes the tracked edits to |output|. Emits: | 44 // Serializes the tracked edits to |output|. Emits: |
| 37 // <filename>:<tag>:<original text>:<new text> | 45 // <filename>:<tag>:<original text>:<new text> |
| 38 // for each distinct filename for each tracked edit. | 46 // for each distinct filename for each tracked edit. |
| 39 void SerializeTo(llvm::StringRef tag, llvm::raw_ostream& output) const; | 47 void SerializeTo(llvm::raw_ostream& output) const; |
| 40 | 48 |
| 41 private: | 49 private: |
| 42 EditTracker(const EditTracker&) = delete; | 50 EditTracker(const EditTracker&) = delete; |
| 43 EditTracker& operator=(const EditTracker&) = delete; | 51 EditTracker& operator=(const EditTracker&) = delete; |
| 44 | 52 |
| 45 // The string key is the original text. | 53 // The string key is the original text. |
| 46 llvm::StringMap<EditInfo> tracked_edits_; | 54 llvm::StringMap<EditInfo> tracked_edits_; |
| 55 |
| 56 RenameCategory category_; |
| 47 }; | 57 }; |
| 48 | 58 |
| 49 #endif // #define TOOLS_CLANG_REWRITE_TO_CHROME_STYLE_EDIT_TRACKER_H_ | 59 #endif // #define TOOLS_CLANG_REWRITE_TO_CHROME_STYLE_EDIT_TRACKER_H_ |
| OLD | NEW |