@@ -61,12 +61,23 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
61
61
/// Visit a ``TokenSyntax``.
62
62
/// - Parameter node: the node that is being visited
63
63
/// - Returns: the rewritten node
64
- open func visitTokenSyntax (_ token: TokenSyntax) -> TokenSyntax {
64
+ open func visit (_ token: TokenSyntax) -> TokenSyntax {
65
65
return token
66
66
}
67
67
"""
68
68
)
69
69
70
+ DeclSyntax (
71
+ """
72
+ /// Forwards call to self.visit(_ token: TokenSyntax).
73
+ /// - Parameter node: the node that is being visited
74
+ /// - Returns: the rewritten node
75
+ private func visitTokenSyntax(_ token: TokenSyntax) -> TokenSyntax {
76
+ self.visit(token)
77
+ }
78
+ """
79
+ )
80
+
70
81
DeclSyntax (
71
82
"""
72
83
/// The function called before visiting the node and its descendants.
@@ -126,7 +137,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
126
137
/// - Parameter node: the node that is being visited
127
138
/// - Returns: the rewritten node
128
139
\( node. apiAttributes ( ) ) \
129
- open func visit \( node . kind . syntaxType ) (_ node: \( node. kind. syntaxType) ) -> \( node. kind. syntaxType) {
140
+ open func visit(_ node: \( node. kind. syntaxType) ) -> \( node. kind. syntaxType) {
130
141
return visitChildren(node)
131
142
}
132
143
"""
@@ -138,7 +149,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
138
149
/// - Parameter node: the node that is being visited
139
150
/// - Returns: the rewritten node
140
151
\( node. apiAttributes ( ) ) \
141
- open func visit \( node . kind . syntaxType ) (_ node: \( node. kind. syntaxType) ) -> \( node. baseType. syntaxBaseName) {
152
+ open func visit(_ node: \( node. kind. syntaxType) ) -> \( node. baseType. syntaxBaseName) {
142
153
return \( node. baseType. syntaxBaseName) (visitChildren(node))
143
154
}
144
155
"""
@@ -154,13 +165,53 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
154
165
/// - Parameter node: the node that is being visited
155
166
/// - Returns: the rewritten node
156
167
\( baseNode. apiAttributes ( ) ) \
157
- public func visit \( baseKind . syntaxType ) (_ node: \( baseKind. syntaxType) ) -> \( baseKind. syntaxType) {
168
+ public func visit(_ node: \( baseKind. syntaxType) ) -> \( baseKind. syntaxType) {
158
169
return dispatchVisit(Syntax(node)).cast( \( baseKind. syntaxType) .self)
159
170
}
160
171
"""
161
172
)
162
173
}
163
174
175
+ for node in SYNTAX_NODES where !node. kind. isBase {
176
+ if ( node. base == . syntax || node. base == . syntaxCollection) && node. kind != . missing {
177
+ DeclSyntax (
178
+ """
179
+ /// Forward call to self.visit(_ node: `` \( node. kind. syntaxType) ``).
180
+ /// - Parameter node: the node that is being visited
181
+ /// - Returns: the rewritten node
182
+ private func visit \( node. kind. syntaxType) (_ node: \( node. kind. syntaxType) ) -> \( node. kind. syntaxType) {
183
+ visit(node)
184
+ }
185
+ """
186
+ )
187
+ } else {
188
+ DeclSyntax (
189
+ """
190
+ /// Forward call to self.visit(_ node: `` \( node. kind. syntaxType) ``).
191
+ /// - Parameter node: the node that is being visited
192
+ /// - Returns: the rewritten node
193
+ private func visit \( node. kind. syntaxType) (_ node: \( node. kind. syntaxType) ) -> \( node. baseType. syntaxBaseName) {
194
+ visit(node)
195
+ }
196
+ """
197
+ )
198
+ }
199
+ }
200
+
201
+ for baseNode in SYNTAX_NODES where baseNode. kind. isBase && baseNode. kind != . syntax && baseNode. kind != . syntaxCollection {
202
+ let baseKind = baseNode. kind
203
+ DeclSyntax (
204
+ """
205
+ /// Forward call to self.visit(_ node: `` \( baseKind. syntaxType) ``).
206
+ /// - Parameter node: the node that is being visited
207
+ /// - Returns: the rewritten node
208
+ private func visit \( baseKind. syntaxType) (_ node: \( baseKind. syntaxType) ) -> \( baseKind. syntaxType) {
209
+ visit(node)
210
+ }
211
+ """
212
+ )
213
+ }
214
+
164
215
DeclSyntax (
165
216
"""
166
217
/// Interpret `node` as a node of type `nodeType`, visit it, calling
0 commit comments