@@ -450,17 +450,17 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
450
450
override func visit( _ node: AccessorDeclSyntax ) -> SyntaxVisitorContinueKind {
451
451
arrangeAttributeList ( node. attributes)
452
452
453
- if let asyncKeyword = node. asyncKeyword {
454
- if node. throwsKeyword != nil {
453
+ if let asyncKeyword = node. effectSpecifiers ? . asyncSpecifier {
454
+ if node. effectSpecifiers ? . throwsSpecifier != nil {
455
455
before ( asyncKeyword, tokens: . break, . open)
456
456
} else {
457
457
before ( asyncKeyword, tokens: . break)
458
458
}
459
459
}
460
460
461
- if let throwsKeyword = node. throwsKeyword {
462
- before ( node. throwsKeyword , tokens: . break)
463
- if node. asyncKeyword != nil {
461
+ if let throwsKeyword = node. effectSpecifiers ? . throwsSpecifier {
462
+ before ( node. effectSpecifiers ? . throwsSpecifier , tokens: . break)
463
+ if node. effectSpecifiers ? . asyncSpecifier != nil {
464
464
after ( throwsKeyword, tokens: . close)
465
465
}
466
466
}
@@ -1132,9 +1132,9 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
1132
1132
}
1133
1133
}
1134
1134
1135
- before ( node. asyncKeyword , tokens: . break)
1136
- before ( node. throwsTok , tokens: . break)
1137
- if let asyncKeyword = node. asyncKeyword , let throwsTok = node. throwsTok {
1135
+ before ( node. effectSpecifiers ? . asyncSpecifier , tokens: . break)
1136
+ before ( node. effectSpecifiers ? . throwsSpecifier , tokens: . break)
1137
+ if let asyncKeyword = node. effectSpecifiers ? . asyncSpecifier , let throwsTok = node. effectSpecifiers ? . throwsSpecifier {
1138
1138
before ( asyncKeyword, tokens: . open)
1139
1139
after ( throwsTok, tokens: . close)
1140
1140
}
@@ -1256,7 +1256,16 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
1256
1256
}
1257
1257
1258
1258
override func visit( _ node: ReturnClauseSyntax ) -> SyntaxVisitorContinueKind {
1259
- after ( node. arrow, tokens: . space)
1259
+ if node. parent? . is ( FunctionTypeSyntax . self) ?? false {
1260
+ // `FunctionTypeSyntax` used to not use `ReturnClauseSyntax` and had
1261
+ // slightly different formatting behavior than the normal
1262
+ // `ReturnClauseSyntax`. To maintain the previous formatting behavior,
1263
+ // add a special case.
1264
+ before ( node. arrow, tokens: . break)
1265
+ before ( node. returnType. firstToken, tokens: . break)
1266
+ } else {
1267
+ after ( node. arrow, tokens: . space)
1268
+ }
1260
1269
1261
1270
// Member type identifier is used when the return type is a member of another type. Add a group
1262
1271
// here so that the base, dot, and member type are kept together when they fit.
@@ -1500,10 +1509,8 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
1500
1509
override func visit( _ node: FunctionTypeSyntax ) -> SyntaxVisitorContinueKind {
1501
1510
after ( node. leftParen, tokens: . break( . open, size: 0 ) , . open)
1502
1511
before ( node. rightParen, tokens: . break( . close, size: 0 ) , . close)
1503
- before ( node. asyncKeyword, tokens: . break)
1504
- before ( node. throwsOrRethrowsKeyword, tokens: . break)
1505
- before ( node. arrow, tokens: . break)
1506
- before ( node. returnType. firstToken, tokens: . break)
1512
+ before ( node. effectSpecifiers? . asyncSpecifier, tokens: . break)
1513
+ before ( node. effectSpecifiers? . throwsSpecifier, tokens: . break)
1507
1514
return . visitChildren
1508
1515
}
1509
1516
@@ -1723,10 +1730,10 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
1723
1730
}
1724
1731
1725
1732
override func visit( _ node: FunctionSignatureSyntax ) -> SyntaxVisitorContinueKind {
1726
- before ( node. asyncOrReasyncKeyword , tokens: . break)
1727
- before ( node. throwsOrRethrowsKeyword , tokens: . break)
1728
- if let asyncOrReasyncKeyword = node. asyncOrReasyncKeyword ,
1729
- let throwsOrRethrowsKeyword = node. throwsOrRethrowsKeyword
1733
+ before ( node. effectSpecifiers ? . asyncSpecifier , tokens: . break)
1734
+ before ( node. effectSpecifiers ? . throwsSpecifier , tokens: . break)
1735
+ if let asyncOrReasyncKeyword = node. effectSpecifiers ? . asyncSpecifier ,
1736
+ let throwsOrRethrowsKeyword = node. effectSpecifiers ? . throwsSpecifier
1730
1737
{
1731
1738
before ( asyncOrReasyncKeyword, tokens: . open)
1732
1739
after ( throwsOrRethrowsKeyword, tokens: . close)
@@ -1868,7 +1875,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
1868
1875
override func visit( _ node: ArrowExprSyntax ) -> SyntaxVisitorContinueKind {
1869
1876
// The break before the `throws` keyword is inserted at the `InfixOperatorExpr` level so that it
1870
1877
// is placed in the correct relative position to the group surrounding the "operator".
1871
- after ( node. throwsToken , tokens: . break)
1878
+ after ( node. effectSpecifiers ? . throwsSpecifier , tokens: . break)
1872
1879
return . visitChildren
1873
1880
}
1874
1881
0 commit comments