Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: tools/clang/rewrite_to_chrome_style/EditTracker.h

Issue 2597863002: rewrite_to_chrome_style: associate replacements with the affected file (Closed)
Patch Set: actually implement stuff Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef TOOLS_CLANG_REWRITE_TO_CHROME_STYLE_EDIT_TRACKER_H_
6 #define TOOLS_CLANG_REWRITE_TO_CHROME_STYLE_EDIT_TRACKER_H_
7
8 #include <map>
9
10 #include "clang/Basic/SourceLocation.h"
11 #include "clang/Basic/SourceManager.h"
Łukasz Anforowicz 2016/12/22 17:34:36 very nitty nit / please ignore me: Can me forward
dcheng 2016/12/22 20:49:40 It could be. But I only bothered forward declaring
12 #include "llvm/ADT/StringMap.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/ADT/StringSet.h"
15
16 namespace llvm {
17 class raw_ostream;
18 } // namespace llvm
19
20 struct EditInfo {
21 std::string new_text;
22 llvm::StringSet<> filenames;
23 };
24
25 // Simple class that tracks the edits made by path. Used to dump the databaes
26 // used by the Blink rebase helper.
27 class EditTracker {
28 public:
29 EditTracker() = default;
30
31 void Add(const clang::SourceManager& source_manager,
32 clang::SourceLocation location,
33 llvm::StringRef original_text,
34 llvm::StringRef new_text);
35
36 // Serializes the tracked edits to |output|. Emits:
37 // <filename>:<prefix>:<original text>:<next text>
Łukasz Anforowicz 2016/12/22 17:34:36 typo:s/next/new/ nit/suggestion: s/<prefix>/<tag>
dcheng 2016/12/22 20:49:40 We already have a hack for newlines: https://cs.ch
38 // for each distinct filename for each tracked edit.
39 void SerializeTo(llvm::StringRef prefix, llvm::raw_ostream& output) const;
40
41 private:
42 EditTracker(const EditTracker&) = delete;
Łukasz Anforowicz 2016/12/22 17:34:36 Is this meant to be an equivalent of DISALLOW_COPY
dcheng 2016/12/22 20:49:40 Done.
43
44 // The string key is the original text.
45 llvm::StringMap<EditInfo> tracked_edits_;
dcheng 2016/12/22 10:26:22 Incidentally, LLVM solved the whole "std::map<std:
Łukasz Anforowicz 2016/12/22 17:34:36 I don't know what is meant by "sad situation" + I
dcheng 2016/12/22 20:49:40 It doesn't help with unordered sets, and the trans
46 };
47
48 #endif // #define TOOLS_CLANG_REWRITE_TO_CHROME_STYLE_EDIT_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698