9#ifndef LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTIONRULESINTERNAL_H
10#define LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTIONRULESINTERNAL_H
17#include "llvm/Support/Error.h"
24inline llvm::Error
findError() {
return llvm::Error::success(); }
28template <
typename FirstT,
typename... RestT>
31 llvm::consumeError(
First.takeError());
37template <
typename FirstT,
typename... RestT>
41 return First.takeError();
46template <
typename RuleType,
typename... RequirementTypes,
size_t... Is>
49 const std::tuple<RequirementTypes...> &Requirements,
50 std::index_sequence<Is...>) {
53 std::make_tuple(std::get<Is>(Requirements).evaluate(Context)...);
54 auto Err =
findError(std::get<Is>(Values)...);
60 RuleType::initiate(Context, std::move((*std::get<Is>(Values)))...);
63 Rule->invoke(Consumer, Context);
70template <
typename FirstT,
typename... RestT>
72 const FirstT &
First,
const RestT &... Rest) {
73 struct OptionGatherer {
78 Option->passToVisitor(Visitor);
82 (OptionGatherer{Visitor})(
First);
86template <
typename... RequirementTypes,
size_t... Is>
89 const std::tuple<RequirementTypes...> &Requirements,
90 std::index_sequence<Is...>) {
96template <
typename Base,
typename First,
typename... Rest>
97struct HasBaseOf : std::conditional_t<HasBaseOf<Base, First>::value ||
98 HasBaseOf<Base, Rest...>::value,
99 std::true_type, std::false_type> {};
101template <
typename Base,
typename T>
106template <
typename Base,
typename First,
typename... Rest>
107struct AreBaseOf : std::conditional_t<AreBaseOf<Base, First>::value &&
108 AreBaseOf<Base, Rest...>::value,
109 std::true_type, std::false_type> {};
111template <
typename Base,
typename T>
116template <
typename RuleType,
typename... RequirementTypes>
117std::unique_ptr<RefactoringActionRule>
119 static_assert(std::is_base_of<RefactoringActionRuleBase, RuleType>::value,
120 "Expected a refactoring action rule type");
122 RequirementTypes...>::value,
123 "Expected a list of refactoring action rules");
127 Rule(std::tuple<RequirementTypes...> Requirements)
128 : Requirements(Requirements) {}
132 internal::invokeRuleAfterValidatingRequirements<RuleType>(
133 Consumer, Context, Requirements,
134 std::index_sequence_for<RequirementTypes...>());
137 bool hasSelectionRequirement()
override {
139 RequirementTypes...>::value;
143 internal::visitRefactoringOptions(
144 Visitor, Requirements,
145 std::index_sequence_for<RequirementTypes...>());
148 std::tuple<RequirementTypes...> Requirements;
151 return std::make_unique<Rule>(std::make_tuple(Requirements...));
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
The refactoring rule context stores all of the inputs that might be needed by a refactoring action ru...
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T