ValueRewriter.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef TOOLS_CLANG_VALUE_CLEANUP_VALUE_REWRITER_H_
  7. #define TOOLS_CLANG_VALUE_CLEANUP_VALUE_REWRITER_H_
  8. #include <set>
  9. #include <string>
  10. #include <utility>
  11. #include <vector>
  12. #include "clang/ASTMatchers/ASTMatchFinder.h"
  13. #include "clang/Tooling/Refactoring.h"
  14. class ValueRewriter {
  15. public:
  16. explicit ValueRewriter(std::set<clang::tooling::Replacement>* replacements);
  17. void RegisterMatchers(clang::ast_matchers::MatchFinder* match_finder);
  18. private:
  19. class ListValueCallback
  20. : public clang::ast_matchers::MatchFinder::MatchCallback {
  21. public:
  22. ListValueCallback(std::string method,
  23. std::string replacement,
  24. std::set<clang::tooling::Replacement>* replacements);
  25. void run(
  26. const clang::ast_matchers::MatchFinder::MatchResult& result) override;
  27. const std::string& method() const { return method_; }
  28. const std::string& replacement() const { return replacement_; }
  29. private:
  30. const std::string method_;
  31. const std::string replacement_;
  32. std::set<clang::tooling::Replacement>* const replacements_;
  33. };
  34. std::vector<ListValueCallback> list_value_callbacks_;
  35. };
  36. #endif // TOOLS_CLANG_VALUE_CLEANUP_VALUE_REWRITER_H_