@@ -146,11 +146,12 @@ open class SyntaxRewriter {
146
146
// nodes are being collected.
147
147
var newLayout : ContiguousArray < RawSyntax ? > ?
148
148
149
- let parentBox = SyntaxBox ( Syntax ( node) )
149
+ let syntaxNode = Syntax ( node)
150
+ let parentBox = SyntaxBox ( syntaxNode)
150
151
151
152
// Incrementing i manually is faster than using .enumerated()
152
153
var childIndex = 0
153
- for (raw, info) in RawSyntaxChildren ( Syntax ( node ) ) {
154
+ for (raw, info) in RawSyntaxChildren ( syntaxNode ) {
154
155
defer { childIndex += 1 }
155
156
guard let child = raw else {
156
157
// Node does not exist. If we are collecting rewritten nodes, we need to
@@ -383,16 +384,16 @@ private func _doVisitImpl${node.name}<Visitor>(
383
384
let node = Unknown${ node. name} ( data)
384
385
let needsChildren = ( visitor. visit ( node) == . visitChildren)
385
386
// Avoid calling into visitChildren if possible.
386
- if needsChildren && data . raw. numberOfChildren > 0 {
387
- visitChildren ( data , parent : Syntax ( node) , & visitor)
387
+ if needsChildren && node . raw. numberOfChildren > 0 {
388
+ visitChildren ( node, & visitor)
388
389
}
389
390
visitor. visitPost ( node)
390
391
% else :
391
392
let node = ${ node. name} ( data)
392
393
let needsChildren = ( visitor. visit ( node) == . visitChildren)
393
394
// Avoid calling into visitChildren if possible.
394
- if needsChildren && data . raw. numberOfChildren > 0 {
395
- visitChildren ( data , parent : Syntax ( node) , & visitor)
395
+ if needsChildren && node . raw. numberOfChildren > 0 {
396
+ visitChildren ( node, & visitor)
396
397
}
397
398
visitor. visitPost ( node)
398
399
% end
@@ -413,8 +414,8 @@ fileprivate func doVisit<Visitor>(
413
414
let node = UnknownSyntax ( data)
414
415
let needsChildren = ( visitor. visit ( node) == . visitChildren)
415
416
// Avoid calling into visitChildren if possible.
416
- if needsChildren && data . raw. numberOfChildren > 0 {
417
- visitChildren ( data , parent : Syntax ( node) , & visitor)
417
+ if needsChildren && node . raw. numberOfChildren > 0 {
418
+ visitChildren ( node, & visitor)
418
419
}
419
420
visitor. visitPost ( node)
420
421
// The implementation of every generated case goes into its own function. This
@@ -428,11 +429,13 @@ fileprivate func doVisit<Visitor>(
428
429
}
429
430
}
430
431
431
- fileprivate func visitChildren< Visitor> (
432
- _ data : SyntaxData , parent : Syntax , _ visitor: inout Visitor
432
+ fileprivate func visitChildren< SyntaxType : SyntaxProtocol , Visitor> (
433
+ _ syntax : SyntaxType , _ visitor: inout Visitor
433
434
) where Visitor : SyntaxVisitor {
434
- for childRaw in PresentRawSyntaxChildren ( data. absoluteRaw) {
435
- 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)
436
439
doVisit ( childData, & visitor)
437
440
}
438
441
}
0 commit comments