Skip to content

Commit 33f0b37

Browse files
authored
Merge pull request swiftlang#217 from allevato/async-keyword
Add build-only support for the `async` keyword.
2 parents 35fdb4f + dde5eff commit 33f0b37

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
14011401
override func visit(_ node: FunctionTypeSyntax) -> SyntaxVisitorContinueKind {
14021402
after(node.leftParen, tokens: .break(.open, size: 0), .open)
14031403
before(node.rightParen, tokens: .break(.close, size: 0), .close)
1404+
before(node.asyncKeyword, tokens: .break)
14041405
before(node.throwsOrRethrowsKeyword, tokens: .break)
14051406
before(node.arrow, tokens: .break)
14061407
before(node.returnType.firstToken, tokens: .break)
@@ -1603,6 +1604,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
16031604
}
16041605

16051606
override func visit(_ node: FunctionSignatureSyntax) -> SyntaxVisitorContinueKind {
1607+
before(node.asyncKeyword, tokens: .break)
16061608
before(node.throwsOrRethrowsKeyword, tokens: .break)
16071609
before(node.output?.firstToken, tokens: .break)
16081610
return .visitChildren

Sources/SwiftFormatRules/UseShorthandTypeNames.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ public final class UseShorthandTypeNames: SyntaxFormatRule {
414414
leftParen: functionType.leftParen,
415415
argumentTypes: functionType.arguments,
416416
rightParen: functionType.rightParen,
417+
asyncKeyword: functionType.asyncKeyword,
417418
throwsOrRethrowsKeyword: functionType.throwsOrRethrowsKeyword,
418419
arrow: functionType.arrow,
419420
returnType: functionType.returnType
@@ -455,6 +456,7 @@ public final class UseShorthandTypeNames: SyntaxFormatRule {
455456
leftParen: TokenSyntax,
456457
argumentTypes: TupleTypeElementListSyntax,
457458
rightParen: TokenSyntax,
459+
asyncKeyword: TokenSyntax?,
458460
throwsOrRethrowsKeyword: TokenSyntax?,
459461
arrow: TokenSyntax,
460462
returnType: TypeSyntax
@@ -471,6 +473,7 @@ public final class UseShorthandTypeNames: SyntaxFormatRule {
471473
elementList: argumentTypeExprs,
472474
rightParen: rightParen)
473475
let arrowExpr = SyntaxFactory.makeArrowExpr(
476+
asyncKeyword: asyncKeyword,
474477
throwsToken: throwsOrRethrowsKeyword,
475478
arrowToken: arrow)
476479

0 commit comments

Comments
 (0)