Skip to content

Commit 4e025d2

Browse files
committed
Add comments to cases
1 parent 915b9ae commit 4e025d2

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

CodeGeneration/Sources/generate-swiftsyntax/templates/basicformat/BasicFormatFile.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ let basicFormatFile = SourceFile {
124124
FunctionDecl("open func requiresLeadingSpace(_ token: TokenSyntax) -> Bool") {
125125
SwitchStmt("""
126126
switch (token.previousToken(viewMode: .sourceAccurate)?.tokenKind, token.tokenKind) {
127-
case (.postfixQuestionMark, .rightAngle):
127+
case (.postfixQuestionMark, .rightAngle): // Ensures there is not space in `?>`
128128
return false
129129
case (.leftParen, .spacedBinaryOperator("*")):
130130
return false
@@ -150,17 +150,17 @@ let basicFormatFile = SourceFile {
150150
FunctionDecl("open func requiresTrailingSpace(_ token: TokenSyntax) -> Bool") {
151151
SwitchStmt("""
152152
switch (token.tokenKind, token.nextToken(viewMode: .sourceAccurate)?.tokenKind) {
153-
case (.asKeyword, .exclamationMark),
154-
(.asKeyword, .postfixQuestionMark),
155-
(.exclamationMark, .leftParen),
156-
(.exclamationMark, .period),
157-
(.initKeyword, .leftParen),
158-
(.initKeyword, .postfixQuestionMark),
159-
(.postfixQuestionMark, .leftParen),
160-
(.postfixQuestionMark, .rightAngle),
161-
(.postfixQuestionMark, .rightParen),
162-
(.tryKeyword, .exclamationMark),
163-
(.tryKeyword, .postfixQuestionMark):
153+
case (.asKeyword, .exclamationMark), // Ensures there is not space in `as!`
154+
(.asKeyword, .postfixQuestionMark), // Ensures there is not space in `as?`
155+
(.exclamationMark, .leftParen), // Ensures there is not space in `!(`
156+
(.exclamationMark, .period), // Ensures there is not space in `!.`
157+
(.initKeyword, .leftParen), // Ensures there is not space in `init(`
158+
(.initKeyword, .postfixQuestionMark), // Ensures there is not space in `init?`
159+
(.postfixQuestionMark, .leftParen), // Ensures there is not space in `?(`
160+
(.postfixQuestionMark, .rightAngle), // Ensures there is not space in `?<`
161+
(.postfixQuestionMark, .rightParen), // Ensures there is not space in `?(`
162+
(.tryKeyword, .exclamationMark), // Ensures there is not space in `try!`
163+
(.tryKeyword, .postfixQuestionMark): // Ensures there is not space in `try?`
164164
return false
165165
case (.spacedBinaryOperator("*"), .comma):
166166
return false

Sources/SwiftBasicFormat/generated/BasicFormat.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ open class BasicFormat: SyntaxRewriter {
125125

126126
open func requiresLeadingSpace(_ token: TokenSyntax) -> Bool {
127127
switch (token.previousToken(viewMode: .sourceAccurate)?.tokenKind, token.tokenKind) {
128-
case (.postfixQuestionMark, .rightAngle):
128+
case (.postfixQuestionMark, .rightAngle): // Ensures there is not space in `?>`
129129
return false
130130
case (.leftParen, .spacedBinaryOperator("*")):
131131
return false
@@ -154,17 +154,17 @@ open class BasicFormat: SyntaxRewriter {
154154

155155
open func requiresTrailingSpace(_ token: TokenSyntax) -> Bool {
156156
switch (token.tokenKind, token.nextToken(viewMode: .sourceAccurate)?.tokenKind) {
157-
case (.asKeyword, .exclamationMark),
158-
(.asKeyword, .postfixQuestionMark),
159-
(.exclamationMark, .leftParen),
160-
(.exclamationMark, .period),
161-
(.initKeyword, .leftParen),
162-
(.initKeyword, .postfixQuestionMark),
163-
(.postfixQuestionMark, .leftParen),
164-
(.postfixQuestionMark, .rightAngle),
165-
(.postfixQuestionMark, .rightParen),
166-
(.tryKeyword, .exclamationMark),
167-
(.tryKeyword, .postfixQuestionMark):
157+
case (.asKeyword, .exclamationMark), // Ensures there is not space in `as!`
158+
(.asKeyword, .postfixQuestionMark), // Ensures there is not space in `as?`
159+
(.exclamationMark, .leftParen), // Ensures there is not space in `!(`
160+
(.exclamationMark, .period), // Ensures there is not space in `!.`
161+
(.initKeyword, .leftParen), // Ensures there is not space in `init(`
162+
(.initKeyword, .postfixQuestionMark), // Ensures there is not space in `init?`
163+
(.postfixQuestionMark, .leftParen), // Ensures there is not space in `?(`
164+
(.postfixQuestionMark, .rightAngle), // Ensures there is not space in `?<`
165+
(.postfixQuestionMark, .rightParen), // Ensures there is not space in `?(`
166+
(.tryKeyword, .exclamationMark), // Ensures there is not space in `try!`
167+
(.tryKeyword, .postfixQuestionMark): // Ensures there is not space in `try?`
168168
return false
169169
case (.spacedBinaryOperator("*"), .comma):
170170
return false

0 commit comments

Comments
 (0)