• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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 // Handles the rewriting of base::Value::GetType() to base::Value::type().
6 
7 #ifndef TOOLS_CLANG_VALUE_CLEANUP_VALUE_REWRITER_H_
8 #define TOOLS_CLANG_VALUE_CLEANUP_VALUE_REWRITER_H_
9 
10 #include <set>
11 #include <string>
12 #include <utility>
13 #include <vector>
14 
15 #include "clang/ASTMatchers/ASTMatchFinder.h"
16 #include "clang/Tooling/Refactoring.h"
17 
18 class ValueRewriter {
19  public:
20   explicit ValueRewriter(std::set<clang::tooling::Replacement>* replacements);
21 
22   void RegisterMatchers(clang::ast_matchers::MatchFinder* match_finder);
23 
24  private:
25   class ListValueCallback
26       : public clang::ast_matchers::MatchFinder::MatchCallback {
27    public:
28     ListValueCallback(std::string method,
29                       std::string replacement,
30                       std::set<clang::tooling::Replacement>* replacements);
31 
32     void run(
33         const clang::ast_matchers::MatchFinder::MatchResult& result) override;
34 
method()35     const std::string& method() const { return method_; }
replacement()36     const std::string& replacement() const { return replacement_; }
37 
38    private:
39     const std::string method_;
40     const std::string replacement_;
41     std::set<clang::tooling::Replacement>* const replacements_;
42   };
43 
44   std::vector<ListValueCallback> list_value_callbacks_;
45 };
46 
47 #endif  // TOOLS_CLANG_VALUE_CLEANUP_VALUE_REWRITER_H_
48