| 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 // Performs simple cleanups of base::ListValue API: | 5 // Handles various rewrites for base::ListValue::Append(). |
| 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 | 6 |
| 15 #ifndef TOOLS_CLANG_VALUE_CLEANUP_LIST_VALUE_REWRITER_H_ | 7 #ifndef TOOLS_CLANG_VALUE_CLEANUP_LIST_VALUE_REWRITER_H_ |
| 16 #define TOOLS_CLANG_VALUE_CLEANUP_LIST_VALUE_REWRITER_H_ | 8 #define TOOLS_CLANG_VALUE_CLEANUP_LIST_VALUE_REWRITER_H_ |
| 17 | 9 |
| 18 #include <memory> | 10 #include <memory> |
| 19 | 11 |
| 20 #include "clang/ASTMatchers/ASTMatchFinder.h" | 12 #include "clang/ASTMatchers/ASTMatchFinder.h" |
| 21 #include "clang/Tooling/Refactoring.h" | 13 #include "clang/Tooling/Refactoring.h" |
| 22 | 14 |
| 23 class ListValueRewriter { | 15 class ListValueRewriter { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 }; | 56 }; |
| 65 | 57 |
| 66 class AppendStringCallback : public AppendCallback { | 58 class AppendStringCallback : public AppendCallback { |
| 67 public: | 59 public: |
| 68 explicit AppendStringCallback(clang::tooling::Replacements* replacements); | 60 explicit AppendStringCallback(clang::tooling::Replacements* replacements); |
| 69 | 61 |
| 70 void run( | 62 void run( |
| 71 const clang::ast_matchers::MatchFinder::MatchResult& result) override; | 63 const clang::ast_matchers::MatchFinder::MatchResult& result) override; |
| 72 }; | 64 }; |
| 73 | 65 |
| 66 class AppendReleasedUniquePtrCallback |
| 67 : public clang::ast_matchers::MatchFinder::MatchCallback { |
| 68 public: |
| 69 explicit AppendReleasedUniquePtrCallback( |
| 70 clang::tooling::Replacements* replacements); |
| 71 |
| 72 void run( |
| 73 const clang::ast_matchers::MatchFinder::MatchResult& result) override; |
| 74 |
| 75 protected: |
| 76 clang::tooling::Replacements* const replacements_; |
| 77 }; |
| 78 |
| 74 AppendBooleanCallback append_boolean_callback_; | 79 AppendBooleanCallback append_boolean_callback_; |
| 75 AppendIntegerCallback append_integer_callback_; | 80 AppendIntegerCallback append_integer_callback_; |
| 76 AppendDoubleCallback append_double_callback_; | 81 AppendDoubleCallback append_double_callback_; |
| 77 AppendStringCallback append_string_callback_; | 82 AppendStringCallback append_string_callback_; |
| 83 AppendReleasedUniquePtrCallback append_released_unique_ptr_callback_; |
| 78 }; | 84 }; |
| 79 | 85 |
| 80 #endif // TOOLS_CLANG_VALUE_CLEANUP_LIST_VALUE_REWRITER_H_ | 86 #endif // TOOLS_CLANG_VALUE_CLEANUP_LIST_VALUE_REWRITER_H_ |
| OLD | NEW |