Chromium Code Reviews| OLD | NEW |
|---|---|
| (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: | |
|
danakj
2016/06/02 20:15:08
Do you really want to maintain 2 copies of this co
dcheng
2016/06/02 20:48:29
Ah. No, not really =)
I've removed it from the .c
| |
| 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_ | |
| OLD | NEW |