2017-10-30 03:47:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "clang/Tooling/Tooling.h"
|
|
|
|
|
#include "clang/Frontend/FrontendAction.h"
|
|
|
|
|
#include "clang/Tooling/Core/Replacement.h"
|
|
|
|
|
|
|
|
|
|
namespace ct = clang::tooling;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A FrontendActionFactory that propagates a set of Replacements into the FrontendAction.
|
|
|
|
|
* This is necessary boilerplate for using a custom FrontendAction with a RefactoringTool.
|
|
|
|
|
*
|
|
|
|
|
* @tparam T The FrontendAction to create.
|
|
|
|
|
*/
|
|
|
|
|
template <typename T>
|
|
|
|
|
class ReplacementsFrontendActionFactory : public ct::FrontendActionFactory {
|
|
|
|
|
ct::Replacements* replacements;
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
public:
|
|
|
|
|
explicit ReplacementsFrontendActionFactory(ct::Replacements* r)
|
|
|
|
|
: ct::FrontendActionFactory(), replacements(r) {}
|
2017-10-30 03:47:50 +00:00
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
clang::FrontendAction* create() override { return new T(replacements); }
|
2017-10-30 03:47:50 +00:00
|
|
|
};
|