diff --git a/CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift b/CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift index c1cb111b100..7326c1d8f3a 100644 --- a/CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift +++ b/CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift @@ -122,7 +122,7 @@ public let KEYWORDS: [KeywordSpec] = [ KeywordSpec("do", isLexerClassified: true), KeywordSpec("dynamic"), KeywordSpec("each"), - KeywordSpec("else", isLexerClassified: true, requiresTrailingSpace: true), + KeywordSpec("else", isLexerClassified: true, requiresLeadingSpace: true, requiresTrailingSpace: true), KeywordSpec("enum", isLexerClassified: true, requiresTrailingSpace: true), KeywordSpec("escaping"), KeywordSpec("exclusivity"), diff --git a/Sources/SwiftBasicFormat/generated/BasicFormat.swift b/Sources/SwiftBasicFormat/generated/BasicFormat.swift index ea095d499bc..21958a7f635 100644 --- a/Sources/SwiftBasicFormat/generated/BasicFormat.swift +++ b/Sources/SwiftBasicFormat/generated/BasicFormat.swift @@ -198,6 +198,8 @@ open class BasicFormat: SyntaxRewriter { return true case .keyword(.`catch`): return true + case .keyword(.`else`): + return true case .keyword(.`in`): return true case .keyword(.`where`): diff --git a/Sources/SwiftSyntax/generated/SyntaxCollections.swift b/Sources/SwiftSyntax/generated/SyntaxCollections.swift index 1eef68f6e13..715791e6a21 100644 --- a/Sources/SwiftSyntax/generated/SyntaxCollections.swift +++ b/Sources/SwiftSyntax/generated/SyntaxCollections.swift @@ -2387,8 +2387,7 @@ public struct ClosureParameterListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -2420,7 +2419,7 @@ public struct ClosureParameterListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `ClosureParameterListSyntax` by replacing the underlying layout with @@ -4689,8 +4688,7 @@ public struct EnumCaseParameterListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -4722,7 +4720,7 @@ public struct EnumCaseParameterListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `EnumCaseParameterListSyntax` by replacing the underlying layout with diff --git a/Tests/SwiftSyntaxBuilderTest/IfStmtTests.swift b/Tests/SwiftSyntaxBuilderTest/IfStmtTests.swift index 4b4f20bd27a..802a37b88c3 100644 --- a/Tests/SwiftSyntaxBuilderTest/IfStmtTests.swift +++ b/Tests/SwiftSyntaxBuilderTest/IfStmtTests.swift @@ -45,6 +45,26 @@ final class IfStmtTests: XCTestCase { } """ ), + #line: ( + ExprSyntax( + """ + if foo == x { + return foo + } + else { + return bar + } + """ + ).cast(IfExprSyntax.self), + """ + if foo == x { + return foo + } + else { + return bar + } + """ + ), #line: ( try IfExprSyntax("if foo == x") { StmtSyntax("return foo") }, """ @@ -62,7 +82,7 @@ final class IfStmtTests: XCTestCase { """ if foo == x { return foo - }else { + } else { return bar } """ @@ -72,7 +92,7 @@ final class IfStmtTests: XCTestCase { """ if foo == x { return foo - }else if foo == z { + } else if foo == z { return baz } """