File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
CodeGeneration/Sources/generate-swiftbasicformat
Sources/SwiftBasicFormat/generated Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ private func createTokenFormatFunction() -> FunctionDecl {
168
168
) {
169
169
VariableDecl ( " var node = node " )
170
170
SwitchStmt ( expression: MemberAccessExpr ( base: " node " , name: " tokenKind " ) ) {
171
- for token in SYNTAX_TOKENS {
171
+ for token in SYNTAX_TOKENS where token . name != " ContextualKeyword " {
172
172
SwitchCase ( label: SwitchCaseLabel ( caseItems: CaseItem ( pattern: ExpressionPattern ( expression: MemberAccessExpr ( name: token. swiftKind) ) ) ) ) {
173
173
if token. requiresLeadingSpace {
174
174
IfStmt (
@@ -196,6 +196,20 @@ private func createTokenFormatFunction() -> FunctionDecl {
196
196
SwitchCase ( label: SwitchCaseLabel ( caseItems: CaseItem ( pattern: ExpressionPattern ( expression: MemberAccessExpr ( name: " eof " ) ) ) ) ) {
197
197
BreakStmt ( " break " )
198
198
}
199
+ SwitchCase ( label: SwitchCaseLabel ( caseItems: CaseItem ( pattern: ExpressionPattern ( expression: MemberAccessExpr ( name: " contextualKeyword " ) ) ) ) ) {
200
+ SwitchStmt (
201
+ """
202
+ switch node.text {
203
+ case " async " :
204
+ if node.trailingTrivia.isEmpty {
205
+ node.trailingTrivia += .space
206
+ }
207
+ default:
208
+ break
209
+ }
210
+ """
211
+ )
212
+ }
199
213
}
200
214
SequenceExpr ( " node.leadingTrivia = node.leadingTrivia.indented(indentation: indentation) " )
201
215
SequenceExpr ( " node.trailingTrivia = node.trailingTrivia.indented(indentation: indentation) " )
Original file line number Diff line number Diff line change @@ -3147,8 +3147,6 @@ open class BasicFormat: SyntaxRewriter {
3147
3147
break
3148
3148
case . dollarIdentifier:
3149
3149
break
3150
- case . contextualKeyword:
3151
- break
3152
3150
case . rawStringDelimiter:
3153
3151
break
3154
3152
case . stringSegment:
@@ -3159,6 +3157,15 @@ open class BasicFormat: SyntaxRewriter {
3159
3157
break
3160
3158
case . eof:
3161
3159
break
3160
+ case . contextualKeyword:
3161
+ switch node. text {
3162
+ case " async " :
3163
+ if node. trailingTrivia. isEmpty {
3164
+ node. trailingTrivia += . space
3165
+ }
3166
+ default :
3167
+ break
3168
+ }
3162
3169
}
3163
3170
node. leadingTrivia = node. leadingTrivia. indented ( indentation: indentation)
3164
3171
node. trailingTrivia = node. trailingTrivia. indented ( indentation: indentation)
You can’t perform that action at this time.
0 commit comments