Skip to content

Commit 288e7b4

Browse files
committed
Remove space for break stmt
1 parent d689cae commit 288e7b4

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

CodeGeneration/Sources/SyntaxSupport/gyb_generated/StmtNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public let STMT_NODES: [Node] = [
231231
kind: "Stmt",
232232
children: [
233233
Child(name: "BreakKeyword",
234-
kind: .token(choices: [.keyword(text: "break")])),
234+
kind: .token(choices: [.keyword(text: "break")], requiresTrailingSpace: false)),
235235
Child(name: "Label",
236236
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
237237
nameForDiagnostics: "label",

Sources/SwiftBasicFormat/generated/BasicFormat.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ open class BasicFormat: SyntaxRewriter {
178178
switch keyPath {
179179
case \AvailabilityArgumentSyntax.entry:
180180
return false
181+
case \BreakStmtSyntax.breakKeyword:
182+
return false
181183
case \DeclNameArgumentSyntax.colon:
182184
return false
183185
case \DictionaryExprSyntax.content:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import XCTest
14+
import SwiftSyntax
15+
import SwiftSyntaxBuilder
16+
17+
final class BreakStmtSyntaxTests: XCTestCase {
18+
func testBreakStmtSyntax() {
19+
let testCases: [UInt: (StmtSyntax, String)] = [
20+
#line: (BreakStmtSyntax().as(StmtSyntax.self)!, "break"),
21+
#line: (StmtSyntax("break"), "break"),
22+
]
23+
24+
for (line, testCase) in testCases {
25+
let (builder, expected) = testCase
26+
AssertBuildResult(builder, expected, trimTrailingWhitespace: false, line: line)
27+
}
28+
}
29+
}

gyb_syntax_support/StmtNodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
# break-stmt -> 'break' identifier? ';'?
144144
Node('BreakStmt', name_for_diagnostics="'break' statement", kind='Stmt',
145145
children=[
146-
Child('BreakKeyword', kind='KeywordToken', token_choices=['KeywordToken|break']),
146+
Child('BreakKeyword', kind='KeywordToken', token_choices=['KeywordToken|break'], requires_trailing_space=False),
147147
Child('Label', kind='IdentifierToken', name_for_diagnostics='label',
148148
is_optional=True),
149149
]),

0 commit comments

Comments
 (0)