@@ -496,7 +496,11 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
496
496
}
497
497
}
498
498
499
- arrangeBracesAndContents ( of: node. elseBody? . as ( CodeBlockSyntax . self) , contentsKeyPath: \. statements)
499
+ arrangeBracesAndContents (
500
+ of: node. elseBody? . as ( CodeBlockSyntax . self) ,
501
+ contentsKeyPath: \. statements,
502
+ openBraceNewlineBehavior: config. lineBreakBeforeControlFlowBodies ? . hard : . elective
503
+ )
500
504
501
505
return . visitChildren
502
506
}
@@ -535,7 +539,11 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
535
539
after ( typeAnnotation. lastToken, tokens: . break( . close( mustBreak: false ) , size: 0 ) )
536
540
}
537
541
538
- arrangeBracesAndContents ( of: node. body, contentsKeyPath: \. statements)
542
+ arrangeBracesAndContents (
543
+ of: node. body,
544
+ contentsKeyPath: \. statements,
545
+ openBraceNewlineBehavior: config. lineBreakBeforeControlFlowBodies ? . hard : . elective
546
+ )
539
547
540
548
return . visitChildren
541
549
}
@@ -557,14 +565,22 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
557
565
after ( condition. lastToken, tokens: . break( . close( mustBreak: false ) , size: 0 ) )
558
566
}
559
567
560
- arrangeBracesAndContents ( of: node. body, contentsKeyPath: \. statements)
568
+ arrangeBracesAndContents (
569
+ of: node. body,
570
+ contentsKeyPath: \. statements,
571
+ openBraceNewlineBehavior: config. lineBreakBeforeControlFlowBodies ? . hard : . elective
572
+ )
561
573
562
574
return . visitChildren
563
575
}
564
576
565
577
override func visit( _ node: RepeatWhileStmtSyntax ) -> SyntaxVisitorContinueKind {
566
578
after ( node. labelColon, tokens: . space)
567
- arrangeBracesAndContents ( of: node. body, contentsKeyPath: \. statements)
579
+ arrangeBracesAndContents (
580
+ of: node. body,
581
+ contentsKeyPath: \. statements,
582
+ openBraceNewlineBehavior: config. lineBreakBeforeControlFlowBodies ? . hard : . elective
583
+ )
568
584
569
585
if config. lineBreakBeforeControlFlowKeywords {
570
586
before ( node. whileKeyword, tokens: . break( . same) , . open)
@@ -584,7 +600,11 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
584
600
585
601
override func visit( _ node: DoStmtSyntax ) -> SyntaxVisitorContinueKind {
586
602
after ( node. labelColon, tokens: . space)
587
- arrangeBracesAndContents ( of: node. body, contentsKeyPath: \. statements)
603
+ arrangeBracesAndContents (
604
+ of: node. body,
605
+ contentsKeyPath: \. statements,
606
+ openBraceNewlineBehavior: config. lineBreakBeforeControlFlowBodies ? . hard : . elective
607
+ )
588
608
return . visitChildren
589
609
}
590
610
@@ -607,7 +627,11 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
607
627
}
608
628
}
609
629
610
- arrangeBracesAndContents ( of: node. body, contentsKeyPath: \. statements)
630
+ arrangeBracesAndContents (
631
+ of: node. body,
632
+ contentsKeyPath: \. statements,
633
+ openBraceNewlineBehavior: config. lineBreakBeforeControlFlowBodies ? . hard : . elective
634
+ )
611
635
612
636
return . visitChildren
613
637
}
0 commit comments