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

Side by Side Diff: tools/clang/value_cleanup/ListValueRewriter.h

Issue 2032983002: base::Value cleanup: add simple Clang tool for structured cleanups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments. Created 4 years, 6 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 // Performs simple cleanups of base::ListValue API:
6 // - base::ListValue::Append(new base::FundamentalValue(bool))
7 // => base::ListValue::AppendBoolean(...)
8 // - base::ListValue::Append(new base::FundamentalValue(int))
9 // => base::ListValue::AppendInteger(...)
10 // - base::ListValue::Append(new base::FundamentalValue(double))
11 // => base::ListValue::AppendDouble(...)
12 // - base::ListValue::Append(new base::StringValue(...))
13 // => base::ListValue::AppendString(...)
14
15 #ifndef TOOLS_CLANG_VALUE_CLEANUP_LIST_VALUE_REWRITER_H_
16 #define TOOLS_CLANG_VALUE_CLEANUP_LIST_VALUE_REWRITER_H_
17
18 #include <memory>
19
20 #include "clang/ASTMatchers/ASTMatchFinder.h"
21 #include "clang/Tooling/Refactoring.h"
22
23 class ListValueRewriter {
24 public:
25 explicit ListValueRewriter(clang::tooling::Replacements* replacements);
26
27 void RegisterMatchers(clang::ast_matchers::MatchFinder* match_finder);
28
29 private:
30 class AppendCallback
31 : public clang::ast_matchers::MatchFinder::MatchCallback {
32 public:
33 explicit AppendCallback(clang::tooling::Replacements* replacements);
34
35 void run(
36 const clang::ast_matchers::MatchFinder::MatchResult& result) override;
37
38 protected:
39 clang::tooling::Replacements* const replacements_;
40 };
41
42 class AppendBooleanCallback : public AppendCallback {
43 public:
44 explicit AppendBooleanCallback(clang::tooling::Replacements* replacements);
45
46 void run(
47 const clang::ast_matchers::MatchFinder::MatchResult& result) override;
48 };
49
50 class AppendIntegerCallback : public AppendCallback {
51 public:
52 explicit AppendIntegerCallback(clang::tooling::Replacements* replacements);
53
54 void run(
55 const clang::ast_matchers::MatchFinder::MatchResult& result) override;
56 };
57
58 class AppendDoubleCallback : public AppendCallback {
59 public:
60 explicit AppendDoubleCallback(clang::tooling::Replacements* replacements);
61
62 void run(
63 const clang::ast_matchers::MatchFinder::MatchResult& result) override;
64 };
65
66 class AppendStringCallback : public AppendCallback {
67 public:
68 explicit AppendStringCallback(clang::tooling::Replacements* replacements);
69
70 void run(
71 const clang::ast_matchers::MatchFinder::MatchResult& result) override;
72 };
73
74 AppendBooleanCallback append_boolean_callback_;
75 AppendIntegerCallback append_integer_callback_;
76 AppendDoubleCallback append_double_callback_;
77 AppendStringCallback append_string_callback_;
78 };
79
80 #endif // TOOLS_CLANG_VALUE_CLEANUP_LIST_VALUE_REWRITER_H_
OLDNEW
« no previous file with comments | « tools/clang/value_cleanup/CMakeLists.txt ('k') | tools/clang/value_cleanup/ListValueRewriter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698