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