@@ -151,7 +151,7 @@ open class SyntaxRewriter {
151
151
152
152
// Incrementing i manually is faster than using .enumerated()
153
153
var childIndex = 0
154
- for (raw, info) in RawSyntaxChildren ( Syntax ( node ) ) {
154
+ for (raw, info) in RawSyntaxChildren ( syntaxNode ) {
155
155
defer { childIndex += 1 }
156
156
guard let child = raw else {
157
157
// Node does not exist. If we are collecting rewritten nodes, we need to
@@ -310,26 +310,26 @@ public extension SyntaxAnyVisitor {
310
310
% for node in SYNTAX_NODES:
311
311
% if is_visitable ( node) :
312
312
mutating func visit( _ node: ${ node. name} ) -> SyntaxVisitorContinueKind {
313
- return visitAny ( Syntax ( node) )
313
+ return visitAny ( node. _syntaxNode )
314
314
}
315
315
mutating func visitPost( _ node: ${ node. name} ) {
316
- return visitAnyPost ( Syntax ( node) )
316
+ return visitAnyPost ( node. _syntaxNode )
317
317
}
318
318
% end
319
319
% end
320
320
321
321
mutating func visit( _ token: TokenSyntax ) -> SyntaxVisitorContinueKind {
322
- return visitAny ( Syntax ( token) )
322
+ return visitAny ( token. _syntaxNode )
323
323
}
324
324
mutating func visitPost( _ node: TokenSyntax ) {
325
- return visitAnyPost ( Syntax ( node) )
325
+ return visitAnyPost ( node. _syntaxNode )
326
326
}
327
327
328
328
mutating func visit( _ node: UnknownSyntax ) -> SyntaxVisitorContinueKind {
329
- return visitAny ( Syntax ( node) )
329
+ return visitAny ( node. _syntaxNode )
330
330
}
331
331
mutating func visitPost( _ node: UnknownSyntax ) {
332
- return visitAnyPost ( Syntax ( node) )
332
+ return visitAnyPost ( node. _syntaxNode )
333
333
}
334
334
}
335
335
@@ -384,16 +384,16 @@ private func _doVisitImpl${node.name}<Visitor>(
384
384
let node = Unknown${ node. name} ( data)
385
385
let needsChildren = ( visitor. visit ( node) == . visitChildren)
386
386
// Avoid calling into visitChildren if possible.
387
- if needsChildren && data . raw. numberOfChildren > 0 {
388
- visitChildren ( data , parent : Syntax ( node) , & visitor)
387
+ if needsChildren && node . raw. numberOfChildren > 0 {
388
+ visitChildren ( node, & visitor)
389
389
}
390
390
visitor. visitPost ( node)
391
391
% else :
392
392
let node = ${ node. name} ( data)
393
393
let needsChildren = ( visitor. visit ( node) == . visitChildren)
394
394
// Avoid calling into visitChildren if possible.
395
- if needsChildren && data . raw. numberOfChildren > 0 {
396
- visitChildren ( data , parent : Syntax ( node) , & visitor)
395
+ if needsChildren && node . raw. numberOfChildren > 0 {
396
+ visitChildren ( node, & visitor)
397
397
}
398
398
visitor. visitPost ( node)
399
399
% end
@@ -414,8 +414,8 @@ fileprivate func doVisit<Visitor>(
414
414
let node = UnknownSyntax ( data)
415
415
let needsChildren = ( visitor. visit ( node) == . visitChildren)
416
416
// Avoid calling into visitChildren if possible.
417
- if needsChildren && data . raw. numberOfChildren > 0 {
418
- visitChildren ( data , parent : Syntax ( node) , & visitor)
417
+ if needsChildren && node . raw. numberOfChildren > 0 {
418
+ visitChildren ( node, & visitor)
419
419
}
420
420
visitor. visitPost ( node)
421
421
// The implementation of every generated case goes into its own function. This
@@ -429,11 +429,13 @@ fileprivate func doVisit<Visitor>(
429
429
}
430
430
}
431
431
432
- fileprivate func visitChildren< Visitor> (
433
- _ data : SyntaxData , parent : Syntax , _ visitor: inout Visitor
432
+ fileprivate func visitChildren< SyntaxType : SyntaxProtocol , Visitor> (
433
+ _ syntax : SyntaxType , _ visitor: inout Visitor
434
434
) where Visitor : SyntaxVisitor {
435
- for childRaw in PresentRawSyntaxChildren ( data. absoluteRaw) {
436
- let childData = SyntaxData ( childRaw, parent: parent)
435
+ let syntaxNode = Syntax ( syntax)
436
+ let parentBox = SyntaxBox ( syntaxNode)
437
+ for childRaw in PresentRawSyntaxChildren ( syntaxNode) {
438
+ let childData = SyntaxData ( childRaw, parentBox: parentBox)
437
439
doVisit ( childData, & visitor)
438
440
}
439
441
}
0 commit comments