| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | #ifndef LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_OPTION_VISITOR_H |
| 10 | #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_OPTION_VISITOR_H |
| 11 | |
| 12 | #include "clang/Basic/LLVM.h" |
| 13 | #include <type_traits> |
| 14 | |
| 15 | namespace clang { |
| 16 | namespace tooling { |
| 17 | |
| 18 | class RefactoringOption; |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | class RefactoringOptionVisitor { |
| 26 | public: |
| 27 | virtual ~RefactoringOptionVisitor() {} |
| 28 | |
| 29 | virtual void visit(const RefactoringOption &Opt, |
| 30 | Optional<std::string> &Value) = 0; |
| 31 | }; |
| 32 | |
| 33 | namespace traits { |
| 34 | namespace internal { |
| 35 | |
| 36 | template <typename T> struct HasHandle { |
| 37 | private: |
| 38 | template <typename ClassT> |
| 39 | static auto check(ClassT *) -> typename std::is_same< |
| 40 | decltype(std::declval<RefactoringOptionVisitor>().visit( |
| 41 | std::declval<RefactoringOption>(), *std::declval<Optional<T> *>())), |
| 42 | void>::type; |
| 43 | |
| 44 | template <typename> static std::false_type check(...); |
| 45 | |
| 46 | public: |
| 47 | using Type = decltype(check<RefactoringOptionVisitor>(nullptr)); |
| 48 | }; |
| 49 | |
| 50 | } |
| 51 | |
| 52 | |
| 53 | |
| 54 | template <typename T> |
| 55 | struct IsValidOptionType : internal::HasHandle<T>::Type {}; |
| 56 | |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | #endif |
| 62 | |