File tree Expand file tree Collapse file tree 5 files changed +526
-417
lines changed Expand file tree Collapse file tree 5 files changed +526
-417
lines changed Original file line number Diff line number Diff line change @@ -729,6 +729,27 @@ bool isAFieldTag(StringRef Tag);
729
729
void dump (const MarkupASTNode *Node, llvm::raw_ostream &OS, unsigned indent = 0 );
730
730
void printInlinesUnder (const MarkupASTNode *Node, llvm::raw_ostream &OS,
731
731
bool PrintDecorators = false );
732
+
733
+
734
+ template <typename ImplClass, typename RetTy = void , typename ... Args>
735
+ class MarkupASTVisitor {
736
+ public:
737
+ RetTy visit (const MarkupASTNode *Node, Args... args) {
738
+ switch (Node->getKind ()) {
739
+ #define MARKUP_AST_NODE (Id, Parent ) \
740
+ case ASTNodeKind::Id: \
741
+ return static_cast <ImplClass*>(this ) \
742
+ ->visit ##Id (cast<const Id>(Node), \
743
+ ::std::forward<Args>(args)...);
744
+ #define ABSTRACT_MARKUP_AST_NODE (Id, Parent )
745
+ #define MARKUP_AST_NODE_RANGE (Id, FirstId, LastId )
746
+ #include " swift/Markup/ASTNodes.def"
747
+ }
748
+ }
749
+
750
+ virtual ~MarkupASTVisitor () {}
751
+ };
752
+
732
753
} // namespace markup
733
754
} // namespace swift
734
755
You can’t perform that action at this time.
0 commit comments