From 0ab6e775f3e6165efc4f168596bbc55ae8312160 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 9 Aug 2023 18:29:57 -0700 Subject: [PATCH 1/5] Make `SyntaxCollection` conform to `ExpressibleByArrayLiteral` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This hoists the ability to create syntax collections from `SwiftSyntaxBuilder` to the `SwiftSyntax` module. Impact on API compatibility: Initializing an `ExprListSyntax` or `UnexpectedNodesSyntax` now requires the nodes to be `ExprSyntax` and `Syntax` opposed to `ExprSyntaxProtocol` or `SyntaxProtocol`, respectively. `ExprListSyntax` is used as the child of a `SequenceExprSyntax`. I think this is OK because - Users don’t genrally construct `UnexpectedNodesSyntax` - To construct a `SequenceExprSyntax`, you can use the result builder on `SequenceExprSyntax`, which takes `ExprSyntaxProtocol` --- .../GenerateSwiftSyntax.swift | 1 - .../BuildableCollectionNodesFile.swift | 60 ---- Sources/SwiftSyntax/SyntaxCollection.swift | 7 +- Sources/SwiftSyntaxBuilder/CMakeLists.txt | 1 - .../ResultBuilderExtensions.swift | 18 + .../generated/BuildableCollectionNodes.swift | 321 ------------------ Tests/SwiftParserTest/RegexLiteralTests.swift | 12 +- Tests/SwiftParserTest/StatementTests.swift | 24 +- .../translated/ForwardSlashRegexTests.swift | 24 +- 9 files changed, 50 insertions(+), 418 deletions(-) delete mode 100644 CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/BuildableCollectionNodesFile.swift delete mode 100644 Sources/SwiftSyntaxBuilder/generated/BuildableCollectionNodes.swift diff --git a/CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift b/CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift index 11ce3f445c2..1a9ba2184d7 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift @@ -120,7 +120,6 @@ struct GenerateSwiftSyntax: ParsableCommand { GeneratedFileSpec(swiftSyntaxGeneratedDir + ["TriviaPieces.swift"], triviaPiecesFile), // SwiftSyntaxBuilder - GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["BuildableCollectionNodes.swift"], buildableCollectionNodesFile), GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["BuildableNodes.swift"], buildableNodesFile), GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["ResultBuilders.swift"], resultBuildersFile), GeneratedFileSpec( diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/BuildableCollectionNodesFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/BuildableCollectionNodesFile.swift deleted file mode 100644 index 3648d3da8ef..00000000000 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/BuildableCollectionNodesFile.swift +++ /dev/null @@ -1,60 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import SwiftSyntax -import SwiftSyntaxBuilder -import SyntaxSupport -import Utils -import SwiftBasicFormat - -let buildableCollectionNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { - DeclSyntax("import SwiftSyntax") - - for node in SYNTAX_NODES.compactMap(\.collectionNode) { - let elementType = node.collectionElementType - - try! ExtensionDeclSyntax( - """ - extension \(raw: node.type.syntaxBaseName): ExpressibleByArrayLiteral - """ - ) { - // Generate initializers - if elementType.isBaseType && node.elementChoices.count == 1 { - DeclSyntax( - """ - public init(_ elements: \(ArrayTypeSyntax(element: elementType.parameterType))) { - self = \(raw: node.type.syntaxBaseName)(elements.map { - \(elementType.syntax)(fromProtocol: $0) - } as [\(elementType.syntax)]) - } - """ - ) - - DeclSyntax( - """ - public init(arrayLiteral elements: \(elementType.parameterType)...) { - self.init(elements) - } - """ - ) - } else { - DeclSyntax( - """ - public init(arrayLiteral elements: Element...) { - self.init(elements) - } - """ - ) - } - } - } -} diff --git a/Sources/SwiftSyntax/SyntaxCollection.swift b/Sources/SwiftSyntax/SyntaxCollection.swift index da1d346f0ef..1623234ad56 100644 --- a/Sources/SwiftSyntax/SyntaxCollection.swift +++ b/Sources/SwiftSyntax/SyntaxCollection.swift @@ -10,7 +10,8 @@ // //===----------------------------------------------------------------------===// -public protocol SyntaxCollection: SyntaxProtocol, BidirectionalCollection where Element: SyntaxProtocol, Index == SyntaxChildrenIndex { +public protocol SyntaxCollection: SyntaxProtocol, BidirectionalCollection, ExpressibleByArrayLiteral +where Element: SyntaxProtocol, Index == SyntaxChildrenIndex { associatedtype Iterator = SyntaxCollectionIterator /// The ``SyntaxKind`` of the syntax node that conforms to ``SyntaxCollection``. @@ -58,6 +59,10 @@ extension SyntaxCollection { self.init(SyntaxData.forRoot(raw, rawNodeArena: arena)) } + public init(arrayLiteral elements: Element...) { + self.init(elements) + } + /// The number of elements, `present` or `missing`, in this collection. public var count: Int { return layoutView.children.count diff --git a/Sources/SwiftSyntaxBuilder/CMakeLists.txt b/Sources/SwiftSyntaxBuilder/CMakeLists.txt index 895f8eee63e..36f5f1c9008 100644 --- a/Sources/SwiftSyntaxBuilder/CMakeLists.txt +++ b/Sources/SwiftSyntaxBuilder/CMakeLists.txt @@ -19,7 +19,6 @@ add_swift_host_library(SwiftSyntaxBuilder WithTrailingCommaSyntax+EnsuringTrailingComma.swift - generated/BuildableCollectionNodes.swift generated/BuildableNodes.swift generated/ResultBuilders.swift generated/RenamedChildrenBuilderCompatibility.swift diff --git a/Sources/SwiftSyntaxBuilder/ResultBuilderExtensions.swift b/Sources/SwiftSyntaxBuilder/ResultBuilderExtensions.swift index 4ea1a20407f..ebf0a04690d 100644 --- a/Sources/SwiftSyntaxBuilder/ResultBuilderExtensions.swift +++ b/Sources/SwiftSyntaxBuilder/ResultBuilderExtensions.swift @@ -49,3 +49,21 @@ extension MemberBlockItemListBuilder { return buildExpression(MemberBlockItemSyntax(decl: expression)) } } + +// MARK: Initializing collections from protocols +// These initializers allow the creation of syntax collections that have a base +// node as their element from the corresponding protocol type. +// These are used by the result builders. +// Since we only have two of these, it doesn’t make sense to generate them. + +extension ExprListSyntax { + init(_ elements: [ExprSyntaxProtocol]) { + self = ExprListSyntax(elements.map { ExprSyntax(fromProtocol: $0) } as [ExprSyntax]) + } +} + +extension UnexpectedNodesSyntax { + public init(_ elements: [SyntaxProtocol]) { + self = UnexpectedNodesSyntax(elements.map { Syntax(fromProtocol: $0) } as [Syntax]) + } +} diff --git a/Sources/SwiftSyntaxBuilder/generated/BuildableCollectionNodes.swift b/Sources/SwiftSyntaxBuilder/generated/BuildableCollectionNodes.swift deleted file mode 100644 index e419047fe38..00000000000 --- a/Sources/SwiftSyntaxBuilder/generated/BuildableCollectionNodes.swift +++ /dev/null @@ -1,321 +0,0 @@ -//// Automatically generated by generate-swiftsyntax -//// Do not edit directly! -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import SwiftSyntax - -extension AccessorDeclListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension ArrayElementListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension AttributeListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension AvailabilityArgumentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension CatchClauseListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension CatchItemListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension ClosureCaptureListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension ClosureParameterListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension ClosureShorthandParameterListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension CodeBlockItemListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension CompositionTypeElementListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension ConditionElementListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension DeclModifierListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension DeclNameArgumentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension DesignatedTypeListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension DictionaryElementListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension DifferentiabilityArgumentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension DocumentationAttributeArgumentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension EffectsAttributeArgumentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension EnumCaseElementListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension EnumCaseParameterListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension ExprListSyntax: ExpressibleByArrayLiteral { - public init(_ elements: [ExprSyntaxProtocol]) { - self = ExprListSyntax(elements.map { - ExprSyntax(fromProtocol: $0) - } as [ExprSyntax]) - } - - public init(arrayLiteral elements: ExprSyntaxProtocol...) { - self.init(elements) - } -} - -extension FunctionParameterListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension GenericArgumentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension GenericParameterListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension GenericRequirementListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension IfConfigClauseListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension ImportPathComponentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension InheritedTypeListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension KeyPathComponentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension LabeledExprListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension MemberBlockItemListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension MultipleTrailingClosureElementListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension ObjCSelectorPieceListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension PatternBindingListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension PlatformVersionItemListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension PrecedenceGroupAttributeListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension PrecedenceGroupNameListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension PrimaryAssociatedTypeListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension SimpleStringLiteralSegmentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension SpecializeAttributeArgumentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension StringLiteralSegmentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension SwitchCaseItemListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension SwitchCaseListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension TuplePatternElementListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension TupleTypeElementListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension UnexpectedNodesSyntax: ExpressibleByArrayLiteral { - public init(_ elements: [SyntaxProtocol]) { - self = UnexpectedNodesSyntax(elements.map { - Syntax(fromProtocol: $0) - } as [Syntax]) - } - - public init(arrayLiteral elements: SyntaxProtocol...) { - self.init(elements) - } -} - -extension VersionComponentListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} - -extension YieldedExpressionListSyntax: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: Element...) { - self.init(elements) - } -} diff --git a/Tests/SwiftParserTest/RegexLiteralTests.swift b/Tests/SwiftParserTest/RegexLiteralTests.swift index 30fc6feeb63..dabcbfff912 100644 --- a/Tests/SwiftParserTest/RegexLiteralTests.swift +++ b/Tests/SwiftParserTest/RegexLiteralTests.swift @@ -1255,13 +1255,11 @@ final class RegexLiteralTests: ParserTestCase { """ let x = true ?/abc/ : /def/ """, - substructure: SequenceExprSyntax( - elements: .init([ - BooleanLiteralExprSyntax(booleanLiteral: true), - UnresolvedTernaryExprSyntax(thenExpression: RegexLiteralExprSyntax(regex: .regexLiteralPattern("abc"))), - RegexLiteralExprSyntax(regex: .regexLiteralPattern("def")), - ]) - ) + substructure: SequenceExprSyntax { + BooleanLiteralExprSyntax(booleanLiteral: true) + UnresolvedTernaryExprSyntax(thenExpression: RegexLiteralExprSyntax(regex: .regexLiteralPattern("abc"))) + RegexLiteralExprSyntax(regex: .regexLiteralPattern("def")) + } ) } diff --git a/Tests/SwiftParserTest/StatementTests.swift b/Tests/SwiftParserTest/StatementTests.swift index f1ea85d05fc..314e35a5314 100644 --- a/Tests/SwiftParserTest/StatementTests.swift +++ b/Tests/SwiftParserTest/StatementTests.swift @@ -537,13 +537,11 @@ final class StatementTests: ParserTestCase { 1️⃣yield & 5 } """, - substructure: SequenceExprSyntax( - elements: ExprListSyntax([ - DeclReferenceExprSyntax(baseName: .identifier("yield")), - BinaryOperatorExprSyntax(operator: .binaryOperator("&")), - IntegerLiteralExprSyntax(5), - ]) - ), + substructure: SequenceExprSyntax { + DeclReferenceExprSyntax(baseName: .identifier("yield")) + BinaryOperatorExprSyntax(operator: .binaryOperator("&")) + IntegerLiteralExprSyntax(5) + }, substructureAfterMarker: "1️⃣" ) @@ -553,13 +551,11 @@ final class StatementTests: ParserTestCase { 1️⃣yield&5 } """, - substructure: SequenceExprSyntax( - elements: ExprListSyntax([ - DeclReferenceExprSyntax(baseName: .identifier("yield")), - BinaryOperatorExprSyntax(operator: .binaryOperator("&")), - IntegerLiteralExprSyntax(5), - ]) - ), + substructure: SequenceExprSyntax { + DeclReferenceExprSyntax(baseName: .identifier("yield")) + BinaryOperatorExprSyntax(operator: .binaryOperator("&")) + IntegerLiteralExprSyntax(5) + }, substructureAfterMarker: "1️⃣" ) } diff --git a/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift b/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift index 1b0a9e7cbd9..11f45f1d34b 100644 --- a/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift +++ b/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift @@ -361,19 +361,17 @@ final class ForwardSlashRegexTests: ParserTestCase { """ _ = /x/??/x/ """, - substructure: SequenceExprSyntax( - elements: .init([ - DiscardAssignmentExprSyntax(), - AssignmentExprSyntax(), - OptionalChainingExprSyntax( - expression: OptionalChainingExprSyntax( - expression: RegexLiteralExprSyntax(regex: .regexLiteralPattern("x")) - ) - ), - BinaryOperatorExprSyntax(operator: .binaryOperator("/")), - PostfixOperatorExprSyntax(expression: DeclReferenceExprSyntax(baseName: "x"), operator: .postfixOperator("/")), - ]) - ) + substructure: SequenceExprSyntax { + DiscardAssignmentExprSyntax() + AssignmentExprSyntax() + OptionalChainingExprSyntax( + expression: OptionalChainingExprSyntax( + expression: RegexLiteralExprSyntax(regex: .regexLiteralPattern("x")) + ) + ) + BinaryOperatorExprSyntax(operator: .binaryOperator("/")) + PostfixOperatorExprSyntax(expression: DeclReferenceExprSyntax(baseName: "x"), operator: .postfixOperator("/")) + } ) } From 33e6274f5294aab452d2b4f833ffadcb6a5c917a Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 9 Aug 2023 18:34:52 -0700 Subject: [PATCH 2/5] Make all `AdditionalTrailingClosures` children non-optional --- .../Sources/SyntaxSupport/Child.swift | 8 ++--- .../Sources/SyntaxSupport/DeclNodes.swift | 3 +- .../Sources/SyntaxSupport/ExprNodes.swift | 13 +++----- .../SyntaxSupport/GrammarGenerator.swift | 2 +- .../Sources/SyntaxSupport/Node.swift | 2 +- .../Sources/SyntaxSupport/Traits.swift | 2 +- .../Sources/Utils/SyntaxBuildableChild.swift | 5 ++- .../RenamedChildrenCompatibilityFile.swift | 3 +- .../swiftsyntax/SyntaxNodesFile.swift | 2 +- .../ValidateSyntaxNodes.swift | 6 ++-- Sources/SwiftParser/Declarations.swift | 4 +-- Sources/SwiftParser/Expressions.swift | 19 ++++++----- Sources/SwiftParser/Parser.swift | 13 ++++++++ .../CallToTrailingClosures.swift | 2 +- .../RenamedChildrenCompatibility.swift | 8 ++--- .../SwiftSyntax/generated/SyntaxTraits.swift | 2 +- .../generated/raw/RawSyntaxNodes.swift | 32 +++++++++---------- .../generated/raw/RawSyntaxValidation.swift | 8 ++--- .../syntaxNodes/SyntaxDeclNodes.swift | 10 +++--- .../syntaxNodes/SyntaxExprNodes.swift | 30 ++++++++--------- .../ConvenienceInitializers.swift | 2 +- .../generated/BuildableNodes.swift | 8 ++--- .../RenamedChildrenBuilderCompatibility.swift | 8 ++--- .../ExprListTests.swift | 18 +++++++++-- .../DebugDescriptionTests.swift | 6 ++-- 25 files changed, 124 insertions(+), 92 deletions(-) diff --git a/CodeGeneration/Sources/SyntaxSupport/Child.swift b/CodeGeneration/Sources/SyntaxSupport/Child.swift index 53360817d14..2d6493bc6b0 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Child.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Child.swift @@ -32,7 +32,7 @@ public enum ChildKind { /// The child always contains a node that matches one of the `choices`. case nodeChoices(choices: [Child]) /// The child is a collection of `kind`. - case collection(kind: SyntaxNodeKind, collectionElementName: String, deprecatedCollectionElementName: String? = nil) + case collection(kind: SyntaxNodeKind, collectionElementName: String, defaultsToEmpty: Bool = false, deprecatedCollectionElementName: String? = nil) /// The child is a token that matches one of the given `choices`. /// If `requiresLeadingSpace` or `requiresTrailingSpace` is not `nil`, it /// overrides the default leading/trailing space behavior of the token. @@ -91,7 +91,7 @@ public class Child { return kind case .nodeChoices: return .syntax - case .collection(kind: let kind, _, _): + case .collection(kind: let kind, _, _, _): return kind case .token: return .token @@ -150,7 +150,7 @@ public class Child { /// Whether this child has syntax kind `UnexpectedNodes`. public var isUnexpectedNodes: Bool { switch kind { - case .collection(kind: .unexpectedNodes, _, _): + case .collection(kind: .unexpectedNodes, _, _, _): return true default: return false @@ -165,7 +165,7 @@ public class Child { return choices.isEmpty case .node(let kind): return kind.isBase - case .collection(let kind, _, _): + case .collection(kind: let kind, _, _, _): return kind.isBase case .token: return false diff --git a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift index 33e776dfd7e..a5b08ef4b36 100644 --- a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift @@ -1450,8 +1450,7 @@ public let DECL_NODES: [Node] = [ ), Child( name: "AdditionalTrailingClosures", - kind: .collection(kind: .multipleTrailingClosureElementList, collectionElementName: "AdditionalTrailingClosure"), - isOptional: true + kind: .collection(kind: .multipleTrailingClosureElementList, collectionElementName: "AdditionalTrailingClosure", defaultsToEmpty: true) ), ] ), diff --git a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift index 6840d714c1f..15f8917a9d1 100644 --- a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift @@ -828,9 +828,8 @@ public let EXPR_NODES: [Node] = [ ), Child( name: "AdditionalTrailingClosures", - kind: .collection(kind: .multipleTrailingClosureElementList, collectionElementName: "AdditionalTrailingClosure"), - nameForDiagnostics: "trailing closures", - isOptional: true + kind: .collection(kind: .multipleTrailingClosureElementList, collectionElementName: "AdditionalTrailingClosure", defaultsToEmpty: true), + nameForDiagnostics: "trailing closures" ), ] ), @@ -1179,8 +1178,7 @@ public let EXPR_NODES: [Node] = [ ), Child( name: "AdditionalTrailingClosures", - kind: .collection(kind: .multipleTrailingClosureElementList, collectionElementName: "AdditionalTrailingClosure"), - isOptional: true + kind: .collection(kind: .multipleTrailingClosureElementList, collectionElementName: "AdditionalTrailingClosure", defaultsToEmpty: true) ), ] ), @@ -1583,9 +1581,8 @@ public let EXPR_NODES: [Node] = [ ), Child( name: "AdditionalTrailingClosures", - kind: .collection(kind: .multipleTrailingClosureElementList, collectionElementName: "AdditionalTrailingClosure"), - nameForDiagnostics: "trailing closures", - isOptional: true + kind: .collection(kind: .multipleTrailingClosureElementList, collectionElementName: "AdditionalTrailingClosure", defaultsToEmpty: true), + nameForDiagnostics: "trailing closures" ), ] ), diff --git a/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift b/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift index 283a0f91dc4..421a8462aa9 100644 --- a/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift +++ b/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift @@ -36,7 +36,7 @@ struct GrammarGenerator { case .nodeChoices(let choices): let choicesDescriptions = choices.map { grammar(for: $0) } return "(\(choicesDescriptions.joined(separator: " | ")))\(optionality)" - case .collection(let kind, _, _): + case .collection(kind: let kind, _, _, _): return "``\(kind.syntaxType)``" case .token(let choices, _, _): if choices.count == 1 { diff --git a/CodeGeneration/Sources/SyntaxSupport/Node.swift b/CodeGeneration/Sources/SyntaxSupport/Node.swift index 4bd81cc6f33..5728e968c67 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Node.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Node.swift @@ -367,7 +367,7 @@ fileprivate extension Child { return [kind] case .nodeChoices(let choices): return choices.flatMap(\.kinds) - case .collection(let kind, _, _): + case .collection(kind: let kind, _, _, _): return [kind] case .token: return [.token] diff --git a/CodeGeneration/Sources/SyntaxSupport/Traits.swift b/CodeGeneration/Sources/SyntaxSupport/Traits.swift index b2570ee1962..e2495b3ba57 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Traits.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Traits.swift @@ -69,7 +69,7 @@ public let TRAITS: [Trait] = [ Child(name: "ArgumentList", kind: .node(kind: .labeledExprList)), Child(name: "RightParen", kind: .token(choices: [.token(.rightParen)]), isOptional: true), Child(name: "TrailingClosure", kind: .node(kind: .closureExpr), isOptional: true), - Child(name: "AdditionalTrailingClosures", kind: .node(kind: .multipleTrailingClosureElementList), isOptional: true), + Child(name: "AdditionalTrailingClosures", kind: .node(kind: .multipleTrailingClosureElementList)), ] ), Trait( diff --git a/CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift b/CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift index 7b70ed78bee..c33653f7d4a 100644 --- a/CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift +++ b/CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift @@ -33,7 +33,7 @@ public extension Child { buildableKind = .node(kind: kind) case .nodeChoices: buildableKind = .node(kind: .syntax) - case .collection(let kind, _, _): + case .collection(kind: let kind, _, _, _): buildableKind = .node(kind: kind) case .token: buildableKind = .token(self.tokenKind!) @@ -65,6 +65,9 @@ public extension Child { return ExprSyntax("nil") } } + if case .collection(_, _, defaultsToEmpty: true, _) = kind { + return ExprSyntax("[]") + } guard let token = token, isToken else { return type.defaultValue } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RenamedChildrenCompatibilityFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RenamedChildrenCompatibilityFile.swift index 33cb492a96f..c490be7f7cb 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RenamedChildrenCompatibilityFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RenamedChildrenCompatibilityFile.swift @@ -38,7 +38,8 @@ let renamedChildrenCompatibilityFile = try! SourceFileSyntax(leadingTrivia: copy ) if let childNode = SYNTAX_NODE_MAP[child.syntaxNodeKind]?.collectionNode, !child.isUnexpectedNodes, - case .collection(_, let collectionElementName, let deprecatedCollectionElementName) = child.kind, + case .collection(_, collectionElementName: let collectionElementName, _, deprecatedCollectionElementName: let deprecatedCollectionElementName) = + child.kind, let deprecatedCollectionElementName { let childEltType = childNode.collectionElementType.syntaxBaseName diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift index 666136cc9f3..9a55078c94c 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift @@ -193,7 +193,7 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax { // If needed, this could be added in the future, but for now withUnexpected should be sufficient. if let childNode = SYNTAX_NODE_MAP[child.syntaxNodeKind]?.collectionNode, !child.isUnexpectedNodes, - case .collection(_, let childElt, _) = child.kind + case .collection(_, collectionElementName: let childElt, _, _) = child.kind { let childEltType = childNode.collectionElementType.syntaxBaseName diff --git a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift index 22c1ed2cdd1..9852ce51fb9 100644 --- a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift +++ b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift @@ -56,13 +56,13 @@ fileprivate extension ChildKind { return kind == otherKind case (.nodeChoices(let choices), .nodeChoices(let otherChoices)): return choices.count == otherChoices.count && zip(choices, otherChoices).allSatisfy { $0.hasSameType(as: $1) } - case (.collection(let kind, _, _), .collection(let otherKind, _, _)): + case (.collection(kind: let kind, _, _, _), .collection(kind: let otherKind, _, _, _)): return kind == otherKind case (.token(let choices, _, _), .token(let otherChoices, _, _)): return choices == otherChoices - case (.node(let kind), .collection(let otherKind, _, _)): + case (.node(let kind), .collection(kind: let otherKind, _, _, _)): return kind == otherKind - case (.collection(let kind, _, _), .node(let otherKind)): + case (.collection(kind: let kind, _, _, _), .node(let otherKind)): return kind == otherKind default: return false diff --git a/Sources/SwiftParser/Declarations.swift b/Sources/SwiftParser/Declarations.swift index ed1b8384b52..085f9ad758e 100644 --- a/Sources/SwiftParser/Declarations.swift +++ b/Sources/SwiftParser/Declarations.swift @@ -1917,7 +1917,7 @@ extension Parser { // Parse the optional trailing closures. let trailingClosure: RawClosureExprSyntax? - let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax? + let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax if self.at(.leftBrace), self.withLookahead({ $0.atValidTrailingClosure(.trailingClosure) }) { @@ -1925,7 +1925,7 @@ extension Parser { self.parseTrailingClosures(.trailingClosure) } else { trailingClosure = nil - additionalTrailingClosures = nil + additionalTrailingClosures = self.emptyCollection(RawMultipleTrailingClosureElementListSyntax.self) } return RawMacroExpansionDeclSyntax( diff --git a/Sources/SwiftParser/Expressions.swift b/Sources/SwiftParser/Expressions.swift index 496615a097c..a7abea4af32 100644 --- a/Sources/SwiftParser/Expressions.swift +++ b/Sources/SwiftParser/Expressions.swift @@ -733,12 +733,12 @@ extension Parser { // If we can parse trailing closures, do so. let trailingClosure: RawClosureExprSyntax? - let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax? + let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax if case .trailingClosure = flavor, self.at(.leftBrace), self.withLookahead({ $0.atValidTrailingClosure(flavor) }) { (trailingClosure, additionalTrailingClosures) = self.parseTrailingClosures(flavor) } else { trailingClosure = nil - additionalTrailingClosures = nil + additionalTrailingClosures = self.emptyCollection(RawMultipleTrailingClosureElementListSyntax.self) } leadingExpr = RawExprSyntax( @@ -769,12 +769,12 @@ extension Parser { // If we can parse trailing closures, do so. let trailingClosure: RawClosureExprSyntax? - let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax? + let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax if case .trailingClosure = flavor, self.at(.leftBrace), self.withLookahead({ $0.atValidTrailingClosure(flavor) }) { (trailingClosure, additionalTrailingClosures) = self.parseTrailingClosures(flavor) } else { trailingClosure = nil - additionalTrailingClosures = nil + additionalTrailingClosures = self.emptyCollection(RawMultipleTrailingClosureElementListSyntax.self) } leadingExpr = RawExprSyntax( @@ -1320,12 +1320,12 @@ extension Parser { // Parse the optional trailing closures. let trailingClosure: RawClosureExprSyntax? - let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax? + let additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax if case .trailingClosure = flavor, self.at(.leftBrace), self.withLookahead({ $0.atValidTrailingClosure(flavor) }) { (trailingClosure, additionalTrailingClosures) = self.parseTrailingClosures(flavor) } else { trailingClosure = nil - additionalTrailingClosures = nil + additionalTrailingClosures = self.emptyCollection(RawMultipleTrailingClosureElementListSyntax.self) } return RawMacroExpansionExprSyntax( @@ -1908,7 +1908,7 @@ extension Parser { extension Parser { /// Parse the trailing closure(s) following a call expression. - mutating func parseTrailingClosures(_ flavor: ExprFlavor) -> (RawClosureExprSyntax, RawMultipleTrailingClosureElementListSyntax?) { + mutating func parseTrailingClosures(_ flavor: ExprFlavor) -> (RawClosureExprSyntax, RawMultipleTrailingClosureElementListSyntax) { // Parse the closure. let closure = self.parseClosureExpression() @@ -1931,7 +1931,10 @@ extension Parser { ) } - let trailing = elements.isEmpty ? nil : RawMultipleTrailingClosureElementListSyntax(elements: elements, arena: self.arena) + let trailing = + elements.isEmpty + ? self.emptyCollection(RawMultipleTrailingClosureElementListSyntax.self) + : RawMultipleTrailingClosureElementListSyntax(elements: elements, arena: self.arena) return (closure, trailing) } } diff --git a/Sources/SwiftParser/Parser.swift b/Sources/SwiftParser/Parser.swift index 876b7d614cb..a83968b1c2e 100644 --- a/Sources/SwiftParser/Parser.swift +++ b/Sources/SwiftParser/Parser.swift @@ -129,6 +129,19 @@ public struct Parser { static let defaultMaximumNestingLevel = 256 #endif + var _emptyRawMultipleTrailingClosureElementListSyntax: RawMultipleTrailingClosureElementListSyntax? + + /// Create an empty collection of the given type. + /// + /// These empty collections are only created once and the same node is returned + /// on subsequent calls, reducing memory usage. + mutating func emptyCollection(_: RawMultipleTrailingClosureElementListSyntax.Type) -> RawMultipleTrailingClosureElementListSyntax { + if _emptyRawMultipleTrailingClosureElementListSyntax == nil { + _emptyRawMultipleTrailingClosureElementListSyntax = RawMultipleTrailingClosureElementListSyntax(elements: [], arena: self.arena) + } + return _emptyRawMultipleTrailingClosureElementListSyntax! + } + /// The delegated initializer for the parser. /// /// - Parameters diff --git a/Sources/SwiftRefactor/CallToTrailingClosures.swift b/Sources/SwiftRefactor/CallToTrailingClosures.swift index 459fc861ef0..96bbbdcd3cf 100644 --- a/Sources/SwiftRefactor/CallToTrailingClosures.swift +++ b/Sources/SwiftRefactor/CallToTrailingClosures.swift @@ -54,7 +54,7 @@ public struct CallToTrailingClosures: SyntaxRefactoringProvider { extension FunctionCallExprSyntax { fileprivate func convertToTrailingClosures(from startAtArgument: Int) -> FunctionCallExprSyntax? { - guard trailingClosure == nil, additionalTrailingClosures == nil, leftParen != nil, rightParen != nil else { + guard trailingClosure == nil, additionalTrailingClosures.isEmpty, leftParen != nil, rightParen != nil else { // Already have trailing closures return nil } diff --git a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift index 9c2360f2fec..d8d8c6541c4 100644 --- a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift +++ b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift @@ -3024,7 +3024,7 @@ extension FunctionCallExprSyntax { _ unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], _ unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -4949,7 +4949,7 @@ extension MacroExpansionDeclSyntax { _ unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], _ unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -5102,7 +5102,7 @@ extension MacroExpansionExprSyntax { _ unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], _ unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -7573,7 +7573,7 @@ extension SubscriptCallExprSyntax { _ unexpectedBetweenRightBracketAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], _ unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil diff --git a/Sources/SwiftSyntax/generated/SyntaxTraits.swift b/Sources/SwiftSyntax/generated/SyntaxTraits.swift index 202c9889808..9657face265 100644 --- a/Sources/SwiftSyntax/generated/SyntaxTraits.swift +++ b/Sources/SwiftSyntax/generated/SyntaxTraits.swift @@ -208,7 +208,7 @@ public protocol FreestandingMacroExpansionSyntax: SyntaxProtocol { set } - var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? { + var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax { get set } diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift index 5190988515e..4e74fca7a4f 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift @@ -9118,7 +9118,7 @@ public struct RawFunctionCallExprSyntax: RawExprSyntaxNodeProtocol { _ unexpectedBetweenRightParenAndTrailingClosure: RawUnexpectedNodesSyntax? = nil, trailingClosure: RawClosureExprSyntax?, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: RawUnexpectedNodesSyntax? = nil, - additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax?, + additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax, _ unexpectedAfterAdditionalTrailingClosures: RawUnexpectedNodesSyntax? = nil, arena: __shared SyntaxArena ) { @@ -9136,7 +9136,7 @@ public struct RawFunctionCallExprSyntax: RawExprSyntaxNodeProtocol { layout[8] = unexpectedBetweenRightParenAndTrailingClosure?.raw layout[9] = trailingClosure?.raw layout[10] = unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures?.raw - layout[11] = additionalTrailingClosures?.raw + layout[11] = additionalTrailingClosures.raw layout[12] = unexpectedAfterAdditionalTrailingClosures?.raw } self.init(unchecked: raw) @@ -9186,8 +9186,8 @@ public struct RawFunctionCallExprSyntax: RawExprSyntaxNodeProtocol { layoutView.children[10].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax? { - layoutView.children[11].map(RawMultipleTrailingClosureElementListSyntax.init(raw:)) + public var additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax { + layoutView.children[11].map(RawMultipleTrailingClosureElementListSyntax.init(raw:))! } public var unexpectedAfterAdditionalTrailingClosures: RawUnexpectedNodesSyntax? { @@ -13497,7 +13497,7 @@ public struct RawMacroExpansionDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBetweenRightParenAndTrailingClosure: RawUnexpectedNodesSyntax? = nil, trailingClosure: RawClosureExprSyntax?, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: RawUnexpectedNodesSyntax? = nil, - additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax?, + additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax, _ unexpectedAfterAdditionalTrailingClosures: RawUnexpectedNodesSyntax? = nil, arena: __shared SyntaxArena ) { @@ -13523,7 +13523,7 @@ public struct RawMacroExpansionDeclSyntax: RawDeclSyntaxNodeProtocol { layout[16] = unexpectedBetweenRightParenAndTrailingClosure?.raw layout[17] = trailingClosure?.raw layout[18] = unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures?.raw - layout[19] = additionalTrailingClosures?.raw + layout[19] = additionalTrailingClosures.raw layout[20] = unexpectedAfterAdditionalTrailingClosures?.raw } self.init(unchecked: raw) @@ -13605,8 +13605,8 @@ public struct RawMacroExpansionDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[18].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax? { - layoutView.children[19].map(RawMultipleTrailingClosureElementListSyntax.init(raw:)) + public var additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax { + layoutView.children[19].map(RawMultipleTrailingClosureElementListSyntax.init(raw:))! } public var unexpectedAfterAdditionalTrailingClosures: RawUnexpectedNodesSyntax? { @@ -13659,7 +13659,7 @@ public struct RawMacroExpansionExprSyntax: RawExprSyntaxNodeProtocol { _ unexpectedBetweenRightParenAndTrailingClosure: RawUnexpectedNodesSyntax? = nil, trailingClosure: RawClosureExprSyntax?, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: RawUnexpectedNodesSyntax? = nil, - additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax?, + additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax, _ unexpectedAfterAdditionalTrailingClosures: RawUnexpectedNodesSyntax? = nil, arena: __shared SyntaxArena ) { @@ -13681,7 +13681,7 @@ public struct RawMacroExpansionExprSyntax: RawExprSyntaxNodeProtocol { layout[12] = unexpectedBetweenRightParenAndTrailingClosure?.raw layout[13] = trailingClosure?.raw layout[14] = unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures?.raw - layout[15] = additionalTrailingClosures?.raw + layout[15] = additionalTrailingClosures.raw layout[16] = unexpectedAfterAdditionalTrailingClosures?.raw } self.init(unchecked: raw) @@ -13747,8 +13747,8 @@ public struct RawMacroExpansionExprSyntax: RawExprSyntaxNodeProtocol { layoutView.children[14].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax? { - layoutView.children[15].map(RawMultipleTrailingClosureElementListSyntax.init(raw:)) + public var additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax { + layoutView.children[15].map(RawMultipleTrailingClosureElementListSyntax.init(raw:))! } public var unexpectedAfterAdditionalTrailingClosures: RawUnexpectedNodesSyntax? { @@ -19326,7 +19326,7 @@ public struct RawSubscriptCallExprSyntax: RawExprSyntaxNodeProtocol { _ unexpectedBetweenRightSquareAndTrailingClosure: RawUnexpectedNodesSyntax? = nil, trailingClosure: RawClosureExprSyntax?, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: RawUnexpectedNodesSyntax? = nil, - additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax?, + additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax, _ unexpectedAfterAdditionalTrailingClosures: RawUnexpectedNodesSyntax? = nil, arena: __shared SyntaxArena ) { @@ -19344,7 +19344,7 @@ public struct RawSubscriptCallExprSyntax: RawExprSyntaxNodeProtocol { layout[8] = unexpectedBetweenRightSquareAndTrailingClosure?.raw layout[9] = trailingClosure?.raw layout[10] = unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures?.raw - layout[11] = additionalTrailingClosures?.raw + layout[11] = additionalTrailingClosures.raw layout[12] = unexpectedAfterAdditionalTrailingClosures?.raw } self.init(unchecked: raw) @@ -19394,8 +19394,8 @@ public struct RawSubscriptCallExprSyntax: RawExprSyntaxNodeProtocol { layoutView.children[10].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax? { - layoutView.children[11].map(RawMultipleTrailingClosureElementListSyntax.init(raw:)) + public var additionalTrailingClosures: RawMultipleTrailingClosureElementListSyntax { + layoutView.children[11].map(RawMultipleTrailingClosureElementListSyntax.init(raw:))! } public var unexpectedAfterAdditionalTrailingClosures: RawUnexpectedNodesSyntax? { diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift index a3b14137bfd..0a92075eaac 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift @@ -1220,7 +1220,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 8, verify(layout[8], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 9, verify(layout[9], as: RawClosureExprSyntax?.self)) assertNoError(kind, 10, verify(layout[10], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 11, verify(layout[11], as: RawMultipleTrailingClosureElementListSyntax?.self)) + assertNoError(kind, 11, verify(layout[11], as: RawMultipleTrailingClosureElementListSyntax.self)) assertNoError(kind, 12, verify(layout[12], as: RawUnexpectedNodesSyntax?.self)) case .functionDecl: assert(layout.count == 17) @@ -1737,7 +1737,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 16, verify(layout[16], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 17, verify(layout[17], as: RawClosureExprSyntax?.self)) assertNoError(kind, 18, verify(layout[18], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 19, verify(layout[19], as: RawMultipleTrailingClosureElementListSyntax?.self)) + assertNoError(kind, 19, verify(layout[19], as: RawMultipleTrailingClosureElementListSyntax.self)) assertNoError(kind, 20, verify(layout[20], as: RawUnexpectedNodesSyntax?.self)) case .macroExpansionExpr: assert(layout.count == 17) @@ -1756,7 +1756,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 12, verify(layout[12], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 13, verify(layout[13], as: RawClosureExprSyntax?.self)) assertNoError(kind, 14, verify(layout[14], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 15, verify(layout[15], as: RawMultipleTrailingClosureElementListSyntax?.self)) + assertNoError(kind, 15, verify(layout[15], as: RawMultipleTrailingClosureElementListSyntax.self)) assertNoError(kind, 16, verify(layout[16], as: RawUnexpectedNodesSyntax?.self)) case .matchingPatternCondition: assert(layout.count == 9) @@ -2348,7 +2348,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 8, verify(layout[8], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 9, verify(layout[9], as: RawClosureExprSyntax?.self)) assertNoError(kind, 10, verify(layout[10], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 11, verify(layout[11], as: RawMultipleTrailingClosureElementListSyntax?.self)) + assertNoError(kind, 11, verify(layout[11], as: RawMultipleTrailingClosureElementListSyntax.self)) assertNoError(kind, 12, verify(layout[12], as: RawUnexpectedNodesSyntax?.self)) case .subscriptDecl: assert(layout.count == 17) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift index a5b2d19624e..6144c306528 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift @@ -4317,7 +4317,7 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], _ unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -4367,7 +4367,7 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBetweenRightParenAndTrailingClosure?.raw, trailingClosure?.raw, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures?.raw, - additionalTrailingClosures?.raw, + additionalTrailingClosures.raw, unexpectedAfterAdditionalTrailingClosures?.raw ] let raw = RawSyntax.makeLayout( @@ -4633,12 +4633,12 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? { + public var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax { get { - return data.child(at: 19, parent: Syntax(self)).map(MultipleTrailingClosureElementListSyntax.init) + return MultipleTrailingClosureElementListSyntax(data.child(at: 19, parent: Syntax(self))!) } set(value) { - self = MacroExpansionDeclSyntax(data.replacingChild(at: 19, with: value?.data, arena: SyntaxArena())) + self = MacroExpansionDeclSyntax(data.replacingChild(at: 19, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift index 1cd01393618..fbf051226e6 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift @@ -2572,7 +2572,7 @@ public struct FunctionCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable { _ unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], _ unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -2606,7 +2606,7 @@ public struct FunctionCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable { unexpectedBetweenRightParenAndTrailingClosure?.raw, trailingClosure?.raw, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures?.raw, - additionalTrailingClosures?.raw, + additionalTrailingClosures.raw, unexpectedAfterAdditionalTrailingClosures?.raw ] let raw = RawSyntax.makeLayout( @@ -2747,12 +2747,12 @@ public struct FunctionCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable { } } - public var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? { + public var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax { get { - return data.child(at: 11, parent: Syntax(self)).map(MultipleTrailingClosureElementListSyntax.init) + return MultipleTrailingClosureElementListSyntax(data.child(at: 11, parent: Syntax(self))!) } set(value) { - self = FunctionCallExprSyntax(data.replacingChild(at: 11, with: value?.data, arena: SyntaxArena())) + self = FunctionCallExprSyntax(data.replacingChild(at: 11, with: value.data, arena: SyntaxArena())) } } @@ -3960,7 +3960,7 @@ public struct MacroExpansionExprSyntax: ExprSyntaxProtocol, SyntaxHashable { _ unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], _ unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -4002,7 +4002,7 @@ public struct MacroExpansionExprSyntax: ExprSyntaxProtocol, SyntaxHashable { unexpectedBetweenRightParenAndTrailingClosure?.raw, trailingClosure?.raw, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures?.raw, - additionalTrailingClosures?.raw, + additionalTrailingClosures.raw, unexpectedAfterAdditionalTrailingClosures?.raw ] let raw = RawSyntax.makeLayout( @@ -4180,12 +4180,12 @@ public struct MacroExpansionExprSyntax: ExprSyntaxProtocol, SyntaxHashable { } } - public var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? { + public var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax { get { - return data.child(at: 15, parent: Syntax(self)).map(MultipleTrailingClosureElementListSyntax.init) + return MultipleTrailingClosureElementListSyntax(data.child(at: 15, parent: Syntax(self))!) } set(value) { - self = MacroExpansionExprSyntax(data.replacingChild(at: 15, with: value?.data, arena: SyntaxArena())) + self = MacroExpansionExprSyntax(data.replacingChild(at: 15, with: value.data, arena: SyntaxArena())) } } @@ -6182,7 +6182,7 @@ public struct SubscriptCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable { _ unexpectedBetweenRightSquareAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, _ unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], _ unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -6216,7 +6216,7 @@ public struct SubscriptCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable { unexpectedBetweenRightSquareAndTrailingClosure?.raw, trailingClosure?.raw, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures?.raw, - additionalTrailingClosures?.raw, + additionalTrailingClosures.raw, unexpectedAfterAdditionalTrailingClosures?.raw ] let raw = RawSyntax.makeLayout( @@ -6357,12 +6357,12 @@ public struct SubscriptCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable { } } - public var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? { + public var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax { get { - return data.child(at: 11, parent: Syntax(self)).map(MultipleTrailingClosureElementListSyntax.init) + return MultipleTrailingClosureElementListSyntax(data.child(at: 11, parent: Syntax(self))!) } set(value) { - self = SubscriptCallExprSyntax(data.replacingChild(at: 11, with: value?.data, arena: SyntaxArena())) + self = SubscriptCallExprSyntax(data.replacingChild(at: 11, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift index 5152d73097f..7ddffb0a9a0 100644 --- a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift +++ b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift @@ -172,7 +172,7 @@ extension FunctionCallExprSyntax { public init( callee: some ExprSyntaxProtocol, trailingClosure: ClosureExprSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], @LabeledExprListBuilder argumentList: () -> LabeledExprListSyntax = { [] } ) { let argumentList = argumentList() diff --git a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift index ea96496583d..e583bfd4564 100644 --- a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift +++ b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift @@ -600,7 +600,7 @@ extension FunctionCallExprSyntax { unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, @LabeledExprListBuilder argumentsBuilder: () throws -> LabeledExprListSyntax, trailingTrivia: Trivia? = nil @@ -969,7 +969,7 @@ extension MacroExpansionDeclSyntax { unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, @LabeledExprListBuilder argumentsBuilder: () throws -> LabeledExprListSyntax, trailingTrivia: Trivia? = nil @@ -1020,7 +1020,7 @@ extension MacroExpansionExprSyntax { unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, @LabeledExprListBuilder argumentsBuilder: () throws -> LabeledExprListSyntax, trailingTrivia: Trivia? = nil @@ -1257,7 +1257,7 @@ extension SubscriptCallExprSyntax { unexpectedBetweenRightSquareAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, @LabeledExprListBuilder argumentsBuilder: () throws -> LabeledExprListSyntax, trailingTrivia: Trivia? = nil diff --git a/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift b/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift index 7a9d25c9d3e..93091cd62fd 100644 --- a/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift +++ b/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift @@ -343,7 +343,7 @@ extension FunctionCallExprSyntax { unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, @LabeledExprListBuilder argumentListBuilder: () throws -> LabeledExprListSyntax, trailingTrivia: Trivia? = nil @@ -613,7 +613,7 @@ extension MacroExpansionDeclSyntax { unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, @LabeledExprListBuilder argumentListBuilder: () throws -> LabeledExprListSyntax, trailingTrivia: Trivia? = nil @@ -666,7 +666,7 @@ extension MacroExpansionExprSyntax { unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, @LabeledExprListBuilder argumentListBuilder: () throws -> LabeledExprListSyntax, trailingTrivia: Trivia? = nil @@ -834,7 +834,7 @@ extension SubscriptCallExprSyntax { unexpectedBetweenRightBracketAndTrailingClosure: UnexpectedNodesSyntax? = nil, trailingClosure: ClosureExprSyntax? = nil, unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, - additionalTrailingClosures: MultipleTrailingClosureElementListSyntax? = nil, + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax = [], unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax? = nil, @LabeledExprListBuilder argumentListBuilder: () throws -> LabeledExprListSyntax, trailingTrivia: Trivia? = nil diff --git a/Tests/SwiftSyntaxBuilderTest/ExprListTests.swift b/Tests/SwiftSyntaxBuilderTest/ExprListTests.swift index 6ac366ac0ab..77e974d4903 100644 --- a/Tests/SwiftSyntaxBuilderTest/ExprListTests.swift +++ b/Tests/SwiftSyntaxBuilderTest/ExprListTests.swift @@ -17,8 +17,22 @@ import SwiftSyntaxBuilder final class ExprListTests: XCTestCase { func testExprList() { let testCases: [UInt: (ExprListSyntax, String)] = [ - #line: (ExprListSyntax([IntegerLiteralExprSyntax(1), BinaryOperatorExprSyntax(text: "+"), FloatLiteralExprSyntax(2.34)]), "1 + 2.34"), - #line: ([IntegerLiteralExprSyntax(1), BinaryOperatorExprSyntax(text: "+"), FloatLiteralExprSyntax(2.34)], "1 + 2.34"), + #line: ( + ExprListSyntax( + [ + ExprSyntax(IntegerLiteralExprSyntax(1)), + ExprSyntax(BinaryOperatorExprSyntax(text: "+")), + ExprSyntax(FloatLiteralExprSyntax(2.34)), + ] + ), "1 + 2.34" + ), + #line: ( + [ + ExprSyntax(IntegerLiteralExprSyntax(1)), + ExprSyntax(BinaryOperatorExprSyntax(text: "+")), + ExprSyntax(FloatLiteralExprSyntax(2.34)), + ], "1 + 2.34" + ), ] for (line, testCase) in testCases { diff --git a/Tests/SwiftSyntaxTest/DebugDescriptionTests.swift b/Tests/SwiftSyntaxTest/DebugDescriptionTests.swift index e47ec588499..f92c75487ba 100644 --- a/Tests/SwiftSyntaxTest/DebugDescriptionTests.swift +++ b/Tests/SwiftSyntaxTest/DebugDescriptionTests.swift @@ -192,7 +192,8 @@ public class DebugDescriptionTests: XCTestCase { ), LabeledExprSyntax(expression: ExprSyntax(IntegerLiteralExprSyntax(literal: .integerLiteral("2")))) ]), - rightParen: .rightParenToken() + rightParen: .rightParenToken(), + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax([]) ))) ]), endOfFileToken: .endOfFileToken() @@ -215,7 +216,8 @@ public class DebugDescriptionTests: XCTestCase { ), LabeledExprSyntax(expression: ExprSyntax(IntegerLiteralExprSyntax(literal: .integerLiteral("2")))) ]), - rightParen: .rightParenToken() + rightParen: .rightParenToken(), + additionalTrailingClosures: MultipleTrailingClosureElementListSyntax([]) ))) ]), endOfFileToken: .endOfFileToken() From 5446b660748ec308c8d88fcf2d14b8e2500874c3 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 9 Aug 2023 11:45:46 -0700 Subject: [PATCH 3/5] Make `DeclModifierList` children non-optional --- .../Sources/SyntaxSupport/CommonNodes.swift | 5 +- .../Sources/SyntaxSupport/DeclNodes.swift | 105 ++++----- .../Sources/SyntaxSupport/ExprNodes.swift | 5 +- .../Sources/SyntaxSupport/Traits.swift | 4 +- .../swiftparser/ParserEntryFile.swift | 2 +- .../CollectionNodes+Parsable.swift | 2 +- Sources/SwiftParser/Declarations.swift | 59 +++--- Sources/SwiftParser/Modifiers.swift | 4 +- Sources/SwiftParser/Nominals.swift | 12 +- Sources/SwiftParser/Parameters.swift | 4 +- Sources/SwiftParser/Parser.swift | 13 ++ .../generated/LayoutNodes+Parsable.swift | 2 +- .../MissingNodesError.swift | 2 +- .../ParseDiagnosticsGenerator.swift | 4 +- .../ParserDiagnosticMessages.swift | 2 +- .../SwiftSyntax/MissingNodeInitializers.swift | 4 +- .../RenamedChildrenCompatibility.swift | 34 +-- .../SwiftSyntax/generated/SyntaxTraits.swift | 4 +- .../generated/raw/RawSyntaxNodes.swift | 184 ++++++++-------- .../generated/raw/RawSyntaxValidation.swift | 46 ++-- .../syntaxNodes/SyntaxDeclNodes.swift | 200 +++++++++--------- .../generated/syntaxNodes/SyntaxNodes.swift | 30 +-- .../ConvenienceInitializers.swift | 2 +- .../generated/BuildableNodes.swift | 24 +-- .../RenamedChildrenBuilderCompatibility.swift | 16 +- .../MacroExpansion.swift | 4 +- Tests/SwiftSyntaxTest/RawSyntaxTests.swift | 2 +- 27 files changed, 385 insertions(+), 390 deletions(-) diff --git a/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift b/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift index d5ba294bed9..6189dc93092 100644 --- a/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift @@ -172,9 +172,8 @@ public let COMMON_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - documentation: "If there were standalone modifiers without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these.", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + documentation: "If there were standalone modifiers without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these." ), Child( name: "Placeholder", diff --git a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift index a5b08ef4b36..281f4bb9e59 100644 --- a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift @@ -192,9 +192,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "ActorKeyword", @@ -283,10 +282,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "Modifiers attached to the associated type declaration.", - isOptional: true + documentation: "Modifiers attached to the associated type declaration." ), Child( name: "AssociatedtypeKeyword", @@ -375,10 +373,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "Modifiers attached to the class declaration, such as `public`.", - isOptional: true + documentation: "Modifiers attached to the class declaration, such as `public`." ), Child( name: "ClassKeyword", @@ -525,10 +522,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "Modifiers that are attached to the deinitializer.", - isOptional: true + documentation: "Modifiers that are attached to the deinitializer." ), Child( name: "DeinitKeyword", @@ -594,9 +590,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - documentation: "If there were modifiers before the editor placeholder, the `EditorPlaceholderDecl` will contain these.", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + documentation: "If there were modifiers before the editor placeholder, the `EditorPlaceholderDecl` will contain these." ), Child( name: "Placeholder", @@ -653,9 +648,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "FirstName", @@ -715,10 +709,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "The declaration modifiers applied to the case declaration.", - isOptional: true + documentation: "The declaration modifiers applied to the case declaration." ), Child( name: "CaseKeyword", @@ -802,10 +795,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "The declaration modifiers applied to the enum declaration.", - isOptional: true + documentation: "The declaration modifiers applied to the enum declaration." ), Child( name: "EnumKeyword", @@ -873,9 +865,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "ExtensionKeyword", @@ -924,9 +915,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "FuncKeyword", @@ -994,9 +984,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "FirstName", @@ -1163,10 +1152,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "Modifiers attached to the import declaration. Currently, no modifiers are supported by Swift.", - isOptional: true + documentation: "Modifiers attached to the import declaration. Currently, no modifiers are supported by Swift." ), Child( name: "ImportKeyword", @@ -1279,10 +1267,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "Modifiers attached to the initializer", - isOptional: true + documentation: "Modifiers attached to the initializer" ), Child( name: "InitKeyword", @@ -1347,9 +1334,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "MacroKeyword", @@ -1407,9 +1393,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "Pound", @@ -1849,10 +1834,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "The declaration modifiers applied to the 'precedencegroup' declaration.", - isOptional: true + documentation: "The declaration modifiers applied to the 'precedencegroup' declaration." ), Child( name: "PrecedencegroupKeyword", @@ -1966,10 +1950,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "Modifiers attached to the protocol declaration, such as `public`.", - isOptional: true + documentation: "Modifiers attached to the protocol declaration, such as `public`." ), Child( name: "ProtocolKeyword", @@ -2138,10 +2121,9 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), nameForDiagnostics: "modifiers", - documentation: "Modifiers that are attached to the struct declaration.", - isOptional: true + documentation: "Modifiers that are attached to the struct declaration." ), Child( name: "StructKeyword", @@ -2202,9 +2184,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "SubscriptKeyword", @@ -2302,9 +2283,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "TypealiasKeyword", @@ -2359,9 +2339,8 @@ public let DECL_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "BindingSpecifier", diff --git a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift index 15f8917a9d1..4df951af4db 100644 --- a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift @@ -379,9 +379,8 @@ public let EXPR_NODES: [Node] = [ ), Child( name: "Modifiers", - kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"), - nameForDiagnostics: "modifiers", - isOptional: true + kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), + nameForDiagnostics: "modifiers" ), Child( name: "FirstName", diff --git a/CodeGeneration/Sources/SyntaxSupport/Traits.swift b/CodeGeneration/Sources/SyntaxSupport/Traits.swift index e2495b3ba57..c9933335810 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Traits.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Traits.swift @@ -38,7 +38,7 @@ public let TRAITS: [Trait] = [ traitName: "DeclGroup", children: [ Child(name: "Attributes", kind: .node(kind: .attributeList), isOptional: true), - Child(name: "Modifiers", kind: .node(kind: .declModifierList), isOptional: true), + Child(name: "Modifiers", kind: .node(kind: .declModifierList)), Child(name: "InheritanceClause", kind: .node(kind: .inheritanceClause), isOptional: true), Child( name: "GenericWhereClause", @@ -140,7 +140,7 @@ public let TRAITS: [Trait] = [ Trait( traitName: "WithModifiers", children: [ - Child(name: "Modifiers", kind: .node(kind: .declModifierList), isOptional: true) + Child(name: "Modifiers", kind: .node(kind: .declModifierList)) ] ), Trait( diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserEntryFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserEntryFile.swift index c982516f477..d32cfa34525 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserEntryFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserEntryFile.swift @@ -57,7 +57,7 @@ let parserEntryFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { // The missing item is not necessary to be a declaration, // which is just a placeholder here return RawCodeBlockItemSyntax( - item: .decl(RawDeclSyntax(RawMissingDeclSyntax(attributes: nil, modifiers: nil, arena: self.arena))), + item: .decl(RawDeclSyntax(RawMissingDeclSyntax(attributes: nil, modifiers: self.emptyCollection(RawDeclModifierListSyntax.self), arena: self.arena))), semicolon: nil, arena: self.arena ) diff --git a/Sources/SwiftParser/CollectionNodes+Parsable.swift b/Sources/SwiftParser/CollectionNodes+Parsable.swift index a3b75e47f4d..14f76550625 100644 --- a/Sources/SwiftParser/CollectionNodes+Parsable.swift +++ b/Sources/SwiftParser/CollectionNodes+Parsable.swift @@ -107,7 +107,7 @@ extension MemberBlockItemListSyntax: SyntaxParseable { } makeMissing: { remainingTokens, arena in let missingDecl = RawMissingDeclSyntax( attributes: nil, - modifiers: nil, + modifiers: RawDeclModifierListSyntax(elements: [], arena: arena), placeholder: RawTokenSyntax(missing: .identifier, text: "<#declaration#>", arena: arena), RawUnexpectedNodesSyntax(remainingTokens, arena: arena), arena: arena diff --git a/Sources/SwiftParser/Declarations.swift b/Sources/SwiftParser/Declarations.swift index 085f9ad758e..1ec6cb0dbaa 100644 --- a/Sources/SwiftParser/Declarations.swift +++ b/Sources/SwiftParser/Declarations.swift @@ -158,9 +158,9 @@ extension TokenConsumer { extension Parser { struct DeclAttributes { var attributes: RawAttributeListSyntax? - var modifiers: RawDeclModifierListSyntax? + var modifiers: RawDeclModifierListSyntax - init(attributes: RawAttributeListSyntax?, modifiers: RawDeclModifierListSyntax?) { + init(attributes: RawAttributeListSyntax?, modifiers: RawDeclModifierListSyntax) { self.attributes = attributes self.modifiers = modifiers } @@ -676,7 +676,13 @@ extension Parser { if let remainingTokens = remainingTokensIfMaximumNestingLevelReached() { let item = RawMemberBlockItemSyntax( remainingTokens, - decl: RawDeclSyntax(RawMissingDeclSyntax(attributes: nil, modifiers: nil, arena: self.arena)), + decl: RawDeclSyntax( + RawMissingDeclSyntax( + attributes: nil, + modifiers: self.emptyCollection(RawDeclModifierListSyntax.self), + arena: self.arena + ) + ), semicolon: nil, arena: self.arena ) @@ -1532,33 +1538,32 @@ extension Parser { var fixity: RawTokenSyntax? var unexpectedAfterFixity: RawUnexpectedNodesSyntax? - if let modifiers = attrs.modifiers?.elements { - if let firstFixityIndex = modifiers.firstIndex(where: { isFixity($0) }) { - let fixityModifier = modifiers[firstFixityIndex] - fixity = fixityModifier.name + let modifiers = attrs.modifiers.elements + if let firstFixityIndex = modifiers.firstIndex(where: { isFixity($0) }) { + let fixityModifier = modifiers[firstFixityIndex] + fixity = fixityModifier.name - unexpectedBeforeFixity = RawUnexpectedNodesSyntax( - combining: unexpectedBeforeFixity, - RawUnexpectedNodesSyntax(Array(modifiers[0.. RawDeclModifierListSyntax? { + mutating func parseDeclModifierList() -> RawDeclModifierListSyntax { var elements = [RawDeclModifierSyntax]() var modifierLoopProgress = LoopProgressCondition() MODIFIER_LOOP: while self.hasProgressed(&modifierLoopProgress) { @@ -93,7 +93,7 @@ extension Parser { break MODIFIER_LOOP } } - return elements.isEmpty ? nil : RawDeclModifierListSyntax(elements: elements, arena: arena) + return elements.isEmpty ? self.emptyCollection(RawDeclModifierListSyntax.self) : RawDeclModifierListSyntax(elements: elements, arena: arena) } } diff --git a/Sources/SwiftParser/Nominals.swift b/Sources/SwiftParser/Nominals.swift index 4c8b7a67138..b680289d189 100644 --- a/Sources/SwiftParser/Nominals.swift +++ b/Sources/SwiftParser/Nominals.swift @@ -17,7 +17,7 @@ protocol NominalTypeDeclarationTrait { init( attributes: RawAttributeListSyntax?, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, _ unexpectedBeforeIdentifier: RawUnexpectedNodesSyntax?, @@ -35,7 +35,7 @@ protocol NominalTypeDeclarationTrait { extension RawProtocolDeclSyntax: NominalTypeDeclarationTrait { init( attributes: RawAttributeListSyntax?, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, _ unexpectedBeforeIdentifier: RawUnexpectedNodesSyntax?, @@ -69,7 +69,7 @@ extension RawProtocolDeclSyntax: NominalTypeDeclarationTrait { extension RawClassDeclSyntax: NominalTypeDeclarationTrait { init( attributes: RawAttributeListSyntax?, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, _ unexpectedBeforeIdentifier: RawUnexpectedNodesSyntax?, @@ -103,7 +103,7 @@ extension RawClassDeclSyntax: NominalTypeDeclarationTrait { extension RawActorDeclSyntax: NominalTypeDeclarationTrait { init( attributes: RawAttributeListSyntax?, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, _ unexpectedBeforeIdentifier: RawUnexpectedNodesSyntax?, @@ -137,7 +137,7 @@ extension RawActorDeclSyntax: NominalTypeDeclarationTrait { extension RawStructDeclSyntax: NominalTypeDeclarationTrait { init( attributes: RawAttributeListSyntax?, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, _ unexpectedBeforeIdentifier: RawUnexpectedNodesSyntax?, @@ -171,7 +171,7 @@ extension RawStructDeclSyntax: NominalTypeDeclarationTrait { extension RawEnumDeclSyntax: NominalTypeDeclarationTrait { init( attributes: RawAttributeListSyntax?, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, _ unexpectedBeforeIdentifier: RawUnexpectedNodesSyntax?, diff --git a/Sources/SwiftParser/Parameters.swift b/Sources/SwiftParser/Parameters.swift index b8c0c7d2c24..b4e23a40771 100644 --- a/Sources/SwiftParser/Parameters.swift +++ b/Sources/SwiftParser/Parameters.swift @@ -234,7 +234,7 @@ extension Parser { // MARK: - Parameter Modifiers extension Parser { - mutating func parseParameterModifiers(isClosure: Bool) -> RawDeclModifierListSyntax? { + mutating func parseParameterModifiers(isClosure: Bool) -> RawDeclModifierListSyntax { var elements = [RawDeclModifierSyntax]() var loopProgress = LoopProgressCondition() MODIFIER_LOOP: while self.hasProgressed(&loopProgress) { @@ -248,7 +248,7 @@ extension Parser { } } if elements.isEmpty { - return nil + return self.emptyCollection(RawDeclModifierListSyntax.self) } else { return RawDeclModifierListSyntax(elements: elements, arena: self.arena) } diff --git a/Sources/SwiftParser/Parser.swift b/Sources/SwiftParser/Parser.swift index a83968b1c2e..a445a3b9e26 100644 --- a/Sources/SwiftParser/Parser.swift +++ b/Sources/SwiftParser/Parser.swift @@ -142,6 +142,19 @@ public struct Parser { return _emptyRawMultipleTrailingClosureElementListSyntax! } + var _emptyRawDeclModifierListSyntax: RawDeclModifierListSyntax? + + /// Create an empty collection of the given type. + /// + /// These empty collections are only created once and the same node is returned + /// on subsequent calls, reducing memory usage. + mutating func emptyCollection(_: RawDeclModifierListSyntax.Type) -> RawDeclModifierListSyntax { + if _emptyRawDeclModifierListSyntax == nil { + _emptyRawDeclModifierListSyntax = RawDeclModifierListSyntax(elements: [], arena: self.arena) + } + return _emptyRawDeclModifierListSyntax! + } + /// The delegated initializer for the parser. /// /// - Parameters diff --git a/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift b/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift index 22dd88571c9..8ed6613c2a1 100644 --- a/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift +++ b/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift @@ -330,7 +330,7 @@ fileprivate extension Parser { // The missing item is not necessary to be a declaration, // which is just a placeholder here return RawCodeBlockItemSyntax( - item: .decl(RawDeclSyntax(RawMissingDeclSyntax(attributes: nil, modifiers: nil, arena: self.arena))), + item: .decl(RawDeclSyntax(RawMissingDeclSyntax(attributes: nil, modifiers: self.emptyCollection(RawDeclModifierListSyntax.self), arena: self.arena))), semicolon: nil, arena: self.arena ) diff --git a/Sources/SwiftParserDiagnostics/MissingNodesError.swift b/Sources/SwiftParserDiagnostics/MissingNodesError.swift index 03f9a137d8d..7b8b94cf70d 100644 --- a/Sources/SwiftParserDiagnostics/MissingNodesError.swift +++ b/Sources/SwiftParserDiagnostics/MissingNodesError.swift @@ -251,7 +251,7 @@ public struct MissingNodesError: ParserError { return nil } if let missingDecl = firstMissingNode.as(MissingDeclSyntax.self) { - if let lastModifier = missingDecl.modifiers?.last { + if let lastModifier = missingDecl.modifiers.last { return "after '\(lastModifier.name.text)' modifier" } else if missingDecl.attributes != nil { return "after attribute" diff --git a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift index a8439b74148..a7bd8b4ce84 100644 --- a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift +++ b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift @@ -1926,8 +1926,8 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor { return .skipChildren } - if let modifiers = node.modifiers, modifiers.hasError { - for modifier in modifiers { + if node.modifiers.hasError { + for modifier in node.modifiers { guard let detail = modifier.detail else { continue } diff --git a/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift b/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift index a9b6e2276b2..6b43127801b 100644 --- a/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift +++ b/Sources/SwiftParserDiagnostics/ParserDiagnosticMessages.swift @@ -511,7 +511,7 @@ public struct UnexpectedNodesError: ParserError { var message = "unexpected \(unexpectedNodes.shortSingleLineContentDescription)" if let parent = unexpectedNodes.parent { if let parentTypeName = parent.nodeTypeNameForDiagnostics(allowBlockNames: false), - parent.children(viewMode: .sourceAccurate).first?.id == unexpectedNodes.id + parent.children(viewMode: .sourceAccurate).first(where: { $0.totalLength.utf8Length > 0 })?.id == unexpectedNodes.id { message += " before \(parentTypeName)" } else if let parentTypeName = parent.ancestorOrSelf(mapping: { $0.nodeTypeNameForDiagnostics(allowBlockNames: false) }) { diff --git a/Sources/SwiftSyntax/MissingNodeInitializers.swift b/Sources/SwiftSyntax/MissingNodeInitializers.swift index 5df2d6d9d36..5c3614683d2 100644 --- a/Sources/SwiftSyntax/MissingNodeInitializers.swift +++ b/Sources/SwiftSyntax/MissingNodeInitializers.swift @@ -13,7 +13,7 @@ public extension MissingDeclSyntax { init( attributes: AttributeListSyntax?, - modifiers: DeclModifierListSyntax?, + modifiers: DeclModifierListSyntax, arena: __shared SyntaxArena ) { self.init( @@ -69,7 +69,7 @@ public extension MissingSyntax { public extension RawMissingDeclSyntax { init( attributes: RawAttributeListSyntax?, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, arena: __shared SyntaxArena ) { self.init( diff --git a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift index d8d8c6541c4..edbb8b2db5c 100644 --- a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift +++ b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift @@ -141,7 +141,7 @@ extension ActorDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndActorKeyword: UnexpectedNodesSyntax? = nil, actorKeyword: TokenSyntax = .keyword(.actor), _ unexpectedBetweenActorKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -607,7 +607,7 @@ extension AssociatedTypeDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndAssociatedtypeKeyword: UnexpectedNodesSyntax? = nil, associatedtypeKeyword: TokenSyntax = .keyword(.associatedtype), _ unexpectedBetweenAssociatedtypeKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -1126,7 +1126,7 @@ extension ClassDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndClassKeyword: UnexpectedNodesSyntax? = nil, classKeyword: TokenSyntax = .keyword(.class), _ unexpectedBetweenClassKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -2385,7 +2385,7 @@ extension EditorPlaceholderDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndIdentifier: UnexpectedNodesSyntax? = nil, identifier: TokenSyntax, _ unexpectedAfterIdentifier: UnexpectedNodesSyntax? = nil, @@ -2635,7 +2635,7 @@ extension EnumCaseParameterSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax? = nil, firstName: TokenSyntax? = nil, _ unexpectedBetweenFirstNameAndSecondName: UnexpectedNodesSyntax? = nil, @@ -2732,7 +2732,7 @@ extension EnumDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndEnumKeyword: UnexpectedNodesSyntax? = nil, enumKeyword: TokenSyntax = .keyword(.enum), _ unexpectedBetweenEnumKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -3087,7 +3087,7 @@ extension FunctionDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFuncKeyword: UnexpectedNodesSyntax? = nil, funcKeyword: TokenSyntax = .keyword(.func), _ unexpectedBetweenFuncKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -3225,7 +3225,7 @@ extension FunctionParameterSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax? = nil, firstName: TokenSyntax, _ unexpectedBetweenFirstNameAndSecondName: UnexpectedNodesSyntax? = nil, @@ -4021,7 +4021,7 @@ extension ImportDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndImportTok: UnexpectedNodesSyntax? = nil, importTok: TokenSyntax = .keyword(.import), _ unexpectedBetweenImportTokAndImportKind: UnexpectedNodesSyntax? = nil, @@ -4784,7 +4784,7 @@ extension MacroDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndMacroKeyword: UnexpectedNodesSyntax? = nil, macroKeyword: TokenSyntax = .keyword(.macro), _ unexpectedBetweenMacroKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -4933,7 +4933,7 @@ extension MacroExpansionDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPoundToken: UnexpectedNodesSyntax? = nil, poundToken: TokenSyntax = .poundToken(), _ unexpectedBetweenPoundTokenAndMacro: UnexpectedNodesSyntax? = nil, @@ -6271,7 +6271,7 @@ extension PrecedenceGroupDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPrecedencegroupKeyword: UnexpectedNodesSyntax? = nil, precedencegroupKeyword: TokenSyntax = .keyword(.precedencegroup), _ unexpectedBetweenPrecedencegroupKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -6609,7 +6609,7 @@ extension ProtocolDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndProtocolKeyword: UnexpectedNodesSyntax? = nil, protocolKeyword: TokenSyntax = .keyword(.protocol), _ unexpectedBetweenProtocolKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -7446,7 +7446,7 @@ extension StructDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndStructKeyword: UnexpectedNodesSyntax? = nil, structKeyword: TokenSyntax = .keyword(.struct), _ unexpectedBetweenStructKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -7686,7 +7686,7 @@ extension SubscriptDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndSubscriptKeyword: UnexpectedNodesSyntax? = nil, subscriptKeyword: TokenSyntax = .keyword(.subscript), _ unexpectedBetweenSubscriptKeywordAndGenericParameterClause: UnexpectedNodesSyntax? = nil, @@ -8320,7 +8320,7 @@ extension TypeAliasDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndTypealiasKeyword: UnexpectedNodesSyntax? = nil, typealiasKeyword: TokenSyntax = .keyword(.typealias), _ unexpectedBetweenTypealiasKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -8655,7 +8655,7 @@ extension VariableDeclSyntax { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndBindingKeyword: UnexpectedNodesSyntax? = nil, bindingKeyword: TokenSyntax, _ unexpectedBetweenBindingKeywordAndBindings: UnexpectedNodesSyntax? = nil, diff --git a/Sources/SwiftSyntax/generated/SyntaxTraits.swift b/Sources/SwiftSyntax/generated/SyntaxTraits.swift index 9657face265..170fe078314 100644 --- a/Sources/SwiftSyntax/generated/SyntaxTraits.swift +++ b/Sources/SwiftSyntax/generated/SyntaxTraits.swift @@ -63,7 +63,7 @@ public protocol DeclGroupSyntax: SyntaxProtocol { set } - var modifiers: DeclModifierListSyntax? { + var modifiers: DeclModifierListSyntax { get set } @@ -484,7 +484,7 @@ public extension SyntaxProtocol { public protocol WithModifiersSyntax: SyntaxProtocol { - var modifiers: DeclModifierListSyntax? { + var modifiers: DeclModifierListSyntax { get set } diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift index 4e74fca7a4f..d9ce5d944d9 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift @@ -492,7 +492,7 @@ public struct RawActorDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndActorKeyword: RawUnexpectedNodesSyntax? = nil, actorKeyword: RawTokenSyntax, _ unexpectedBetweenActorKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -514,7 +514,7 @@ public struct RawActorDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndActorKeyword?.raw layout[5] = actorKeyword.raw layout[6] = unexpectedBetweenActorKeywordAndName?.raw @@ -544,8 +544,8 @@ public struct RawActorDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndActorKeyword: RawUnexpectedNodesSyntax? { @@ -1140,7 +1140,7 @@ public struct RawAssociatedTypeDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndAssociatedtypeKeyword: RawUnexpectedNodesSyntax? = nil, associatedtypeKeyword: RawTokenSyntax, _ unexpectedBetweenAssociatedtypeKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -1160,7 +1160,7 @@ public struct RawAssociatedTypeDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndAssociatedtypeKeyword?.raw layout[5] = associatedtypeKeyword.raw layout[6] = unexpectedBetweenAssociatedtypeKeywordAndName?.raw @@ -1188,8 +1188,8 @@ public struct RawAssociatedTypeDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndAssociatedtypeKeyword: RawUnexpectedNodesSyntax? { @@ -2929,7 +2929,7 @@ public struct RawClassDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndClassKeyword: RawUnexpectedNodesSyntax? = nil, classKeyword: RawTokenSyntax, _ unexpectedBetweenClassKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -2951,7 +2951,7 @@ public struct RawClassDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndClassKeyword?.raw layout[5] = classKeyword.raw layout[6] = unexpectedBetweenClassKeywordAndName?.raw @@ -2981,8 +2981,8 @@ public struct RawClassDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndClassKeyword: RawUnexpectedNodesSyntax? { @@ -3687,7 +3687,7 @@ public struct RawClosureParameterSyntax: RawSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndFirstName: RawUnexpectedNodesSyntax? = nil, firstName: RawTokenSyntax, _ unexpectedBetweenFirstNameAndSecondName: RawUnexpectedNodesSyntax? = nil, @@ -3709,7 +3709,7 @@ public struct RawClosureParameterSyntax: RawSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndFirstName?.raw layout[5] = firstName.raw layout[6] = unexpectedBetweenFirstNameAndSecondName?.raw @@ -3739,8 +3739,8 @@ public struct RawClosureParameterSyntax: RawSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndFirstName: RawUnexpectedNodesSyntax? { @@ -5741,7 +5741,7 @@ public struct RawDeinitializerDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndDeinitKeyword: RawUnexpectedNodesSyntax? = nil, deinitKeyword: RawTokenSyntax, _ unexpectedBetweenDeinitKeywordAndEffectSpecifiers: RawUnexpectedNodesSyntax? = nil, @@ -5757,7 +5757,7 @@ public struct RawDeinitializerDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndDeinitKeyword?.raw layout[5] = deinitKeyword.raw layout[6] = unexpectedBetweenDeinitKeywordAndEffectSpecifiers?.raw @@ -5781,8 +5781,8 @@ public struct RawDeinitializerDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndDeinitKeyword: RawUnexpectedNodesSyntax? { @@ -7403,7 +7403,7 @@ public struct RawEditorPlaceholderDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndPlaceholder: RawUnexpectedNodesSyntax? = nil, placeholder: RawTokenSyntax, _ unexpectedAfterPlaceholder: RawUnexpectedNodesSyntax? = nil, @@ -7415,7 +7415,7 @@ public struct RawEditorPlaceholderDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndPlaceholder?.raw layout[5] = placeholder.raw layout[6] = unexpectedAfterPlaceholder?.raw @@ -7435,8 +7435,8 @@ public struct RawEditorPlaceholderDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndPlaceholder: RawUnexpectedNodesSyntax? { @@ -7593,7 +7593,7 @@ public struct RawEnumCaseDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndCaseKeyword: RawUnexpectedNodesSyntax? = nil, caseKeyword: RawTokenSyntax, _ unexpectedBetweenCaseKeywordAndElements: RawUnexpectedNodesSyntax? = nil, @@ -7607,7 +7607,7 @@ public struct RawEnumCaseDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndCaseKeyword?.raw layout[5] = caseKeyword.raw layout[6] = unexpectedBetweenCaseKeywordAndElements?.raw @@ -7629,8 +7629,8 @@ public struct RawEnumCaseDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndCaseKeyword: RawUnexpectedNodesSyntax? { @@ -7961,7 +7961,7 @@ public struct RawEnumCaseParameterSyntax: RawSyntaxNodeProtocol { public init( _ unexpectedBeforeModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndFirstName: RawUnexpectedNodesSyntax? = nil, firstName: RawTokenSyntax?, _ unexpectedBetweenFirstNameAndSecondName: RawUnexpectedNodesSyntax? = nil, @@ -7981,7 +7981,7 @@ public struct RawEnumCaseParameterSyntax: RawSyntaxNodeProtocol { kind: .enumCaseParameter, uninitializedCount: 15, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeModifiers?.raw - layout[1] = modifiers?.raw + layout[1] = modifiers.raw layout[2] = unexpectedBetweenModifiersAndFirstName?.raw layout[3] = firstName?.raw layout[4] = unexpectedBetweenFirstNameAndSecondName?.raw @@ -8003,8 +8003,8 @@ public struct RawEnumCaseParameterSyntax: RawSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[1].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[1].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndFirstName: RawUnexpectedNodesSyntax? { @@ -8093,7 +8093,7 @@ public struct RawEnumDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndEnumKeyword: RawUnexpectedNodesSyntax? = nil, enumKeyword: RawTokenSyntax, _ unexpectedBetweenEnumKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -8115,7 +8115,7 @@ public struct RawEnumDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndEnumKeyword?.raw layout[5] = enumKeyword.raw layout[6] = unexpectedBetweenEnumKeywordAndName?.raw @@ -8145,8 +8145,8 @@ public struct RawEnumDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndEnumKeyword: RawUnexpectedNodesSyntax? { @@ -8628,7 +8628,7 @@ public struct RawExtensionDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndExtensionKeyword: RawUnexpectedNodesSyntax? = nil, extensionKeyword: RawTokenSyntax, _ unexpectedBetweenExtensionKeywordAndExtendedType: RawUnexpectedNodesSyntax? = nil, @@ -8648,7 +8648,7 @@ public struct RawExtensionDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndExtensionKeyword?.raw layout[5] = extensionKeyword.raw layout[6] = unexpectedBetweenExtensionKeywordAndExtendedType?.raw @@ -8676,8 +8676,8 @@ public struct RawExtensionDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndExtensionKeyword: RawUnexpectedNodesSyntax? { @@ -9228,7 +9228,7 @@ public struct RawFunctionDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndFuncKeyword: RawUnexpectedNodesSyntax? = nil, funcKeyword: RawTokenSyntax, _ unexpectedBetweenFuncKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -9250,7 +9250,7 @@ public struct RawFunctionDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndFuncKeyword?.raw layout[5] = funcKeyword.raw layout[6] = unexpectedBetweenFuncKeywordAndName?.raw @@ -9280,8 +9280,8 @@ public struct RawFunctionDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndFuncKeyword: RawUnexpectedNodesSyntax? { @@ -9572,7 +9572,7 @@ public struct RawFunctionParameterSyntax: RawSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndFirstName: RawUnexpectedNodesSyntax? = nil, firstName: RawTokenSyntax, _ unexpectedBetweenFirstNameAndSecondName: RawUnexpectedNodesSyntax? = nil, @@ -9596,7 +9596,7 @@ public struct RawFunctionParameterSyntax: RawSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndFirstName?.raw layout[5] = firstName.raw layout[6] = unexpectedBetweenFirstNameAndSecondName?.raw @@ -9628,8 +9628,8 @@ public struct RawFunctionParameterSyntax: RawSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndFirstName: RawUnexpectedNodesSyntax? { @@ -11438,7 +11438,7 @@ public struct RawImportDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndImportKeyword: RawUnexpectedNodesSyntax? = nil, importKeyword: RawTokenSyntax, _ unexpectedBetweenImportKeywordAndImportKindSpecifier: RawUnexpectedNodesSyntax? = nil, @@ -11454,7 +11454,7 @@ public struct RawImportDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndImportKeyword?.raw layout[5] = importKeyword.raw layout[6] = unexpectedBetweenImportKeywordAndImportKindSpecifier?.raw @@ -11478,8 +11478,8 @@ public struct RawImportDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndImportKeyword: RawUnexpectedNodesSyntax? { @@ -12076,7 +12076,7 @@ public struct RawInitializerDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndInitKeyword: RawUnexpectedNodesSyntax? = nil, initKeyword: RawTokenSyntax, _ unexpectedBetweenInitKeywordAndOptionalMark: RawUnexpectedNodesSyntax? = nil, @@ -12098,7 +12098,7 @@ public struct RawInitializerDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndInitKeyword?.raw layout[5] = initKeyword.raw layout[6] = unexpectedBetweenInitKeywordAndOptionalMark?.raw @@ -12128,8 +12128,8 @@ public struct RawInitializerDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndInitKeyword: RawUnexpectedNodesSyntax? { @@ -13339,7 +13339,7 @@ public struct RawMacroDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndMacroKeyword: RawUnexpectedNodesSyntax? = nil, macroKeyword: RawTokenSyntax, _ unexpectedBetweenMacroKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -13361,7 +13361,7 @@ public struct RawMacroDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndMacroKeyword?.raw layout[5] = macroKeyword.raw layout[6] = unexpectedBetweenMacroKeywordAndName?.raw @@ -13391,8 +13391,8 @@ public struct RawMacroDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndMacroKeyword: RawUnexpectedNodesSyntax? { @@ -13481,7 +13481,7 @@ public struct RawMacroExpansionDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndPound: RawUnexpectedNodesSyntax? = nil, pound: RawTokenSyntax, _ unexpectedBetweenPoundAndMacroName: RawUnexpectedNodesSyntax? = nil, @@ -13507,7 +13507,7 @@ public struct RawMacroExpansionDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndPound?.raw layout[5] = pound.raw layout[6] = unexpectedBetweenPoundAndMacroName?.raw @@ -13541,8 +13541,8 @@ public struct RawMacroExpansionDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndPound: RawUnexpectedNodesSyntax? { @@ -14343,7 +14343,7 @@ public struct RawMissingDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndPlaceholder: RawUnexpectedNodesSyntax? = nil, placeholder: RawTokenSyntax, _ unexpectedAfterPlaceholder: RawUnexpectedNodesSyntax? = nil, @@ -14355,7 +14355,7 @@ public struct RawMissingDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndPlaceholder?.raw layout[5] = placeholder.raw layout[6] = unexpectedAfterPlaceholder?.raw @@ -14375,8 +14375,8 @@ public struct RawMissingDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndPlaceholder: RawUnexpectedNodesSyntax? { @@ -17031,7 +17031,7 @@ public struct RawPrecedenceGroupDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndPrecedencegroupKeyword: RawUnexpectedNodesSyntax? = nil, precedencegroupKeyword: RawTokenSyntax, _ unexpectedBetweenPrecedencegroupKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -17051,7 +17051,7 @@ public struct RawPrecedenceGroupDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndPrecedencegroupKeyword?.raw layout[5] = precedencegroupKeyword.raw layout[6] = unexpectedBetweenPrecedencegroupKeywordAndName?.raw @@ -17079,8 +17079,8 @@ public struct RawPrecedenceGroupDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndPrecedencegroupKeyword: RawUnexpectedNodesSyntax? { @@ -17635,7 +17635,7 @@ public struct RawProtocolDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndProtocolKeyword: RawUnexpectedNodesSyntax? = nil, protocolKeyword: RawTokenSyntax, _ unexpectedBetweenProtocolKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -17657,7 +17657,7 @@ public struct RawProtocolDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndProtocolKeyword?.raw layout[5] = protocolKeyword.raw layout[6] = unexpectedBetweenProtocolKeywordAndName?.raw @@ -17687,8 +17687,8 @@ public struct RawProtocolDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndProtocolKeyword: RawUnexpectedNodesSyntax? { @@ -19176,7 +19176,7 @@ public struct RawStructDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndStructKeyword: RawUnexpectedNodesSyntax? = nil, structKeyword: RawTokenSyntax, _ unexpectedBetweenStructKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -19198,7 +19198,7 @@ public struct RawStructDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndStructKeyword?.raw layout[5] = structKeyword.raw layout[6] = unexpectedBetweenStructKeywordAndName?.raw @@ -19228,8 +19228,8 @@ public struct RawStructDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndStructKeyword: RawUnexpectedNodesSyntax? { @@ -19436,7 +19436,7 @@ public struct RawSubscriptDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndSubscriptKeyword: RawUnexpectedNodesSyntax? = nil, subscriptKeyword: RawTokenSyntax, _ unexpectedBetweenSubscriptKeywordAndGenericParameterClause: RawUnexpectedNodesSyntax? = nil, @@ -19458,7 +19458,7 @@ public struct RawSubscriptDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndSubscriptKeyword?.raw layout[5] = subscriptKeyword.raw layout[6] = unexpectedBetweenSubscriptKeywordAndGenericParameterClause?.raw @@ -19488,8 +19488,8 @@ public struct RawSubscriptDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndSubscriptKeyword: RawUnexpectedNodesSyntax? { @@ -21116,7 +21116,7 @@ public struct RawTypeAliasDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndTypealiasKeyword: RawUnexpectedNodesSyntax? = nil, typealiasKeyword: RawTokenSyntax, _ unexpectedBetweenTypealiasKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -21136,7 +21136,7 @@ public struct RawTypeAliasDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndTypealiasKeyword?.raw layout[5] = typealiasKeyword.raw layout[6] = unexpectedBetweenTypealiasKeywordAndName?.raw @@ -21164,8 +21164,8 @@ public struct RawTypeAliasDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndTypealiasKeyword: RawUnexpectedNodesSyntax? { @@ -22047,7 +22047,7 @@ public struct RawVariableDeclSyntax: RawDeclSyntaxNodeProtocol { _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, attributes: RawAttributeListSyntax?, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, - modifiers: RawDeclModifierListSyntax?, + modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndBindingSpecifier: RawUnexpectedNodesSyntax? = nil, bindingSpecifier: RawTokenSyntax, _ unexpectedBetweenBindingSpecifierAndBindings: RawUnexpectedNodesSyntax? = nil, @@ -22061,7 +22061,7 @@ public struct RawVariableDeclSyntax: RawDeclSyntaxNodeProtocol { layout[0] = unexpectedBeforeAttributes?.raw layout[1] = attributes?.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw - layout[3] = modifiers?.raw + layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndBindingSpecifier?.raw layout[5] = bindingSpecifier.raw layout[6] = unexpectedBetweenBindingSpecifierAndBindings?.raw @@ -22083,8 +22083,8 @@ public struct RawVariableDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var modifiers: RawDeclModifierListSyntax? { - layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:)) + public var modifiers: RawDeclModifierListSyntax { + layoutView.children[3].map(RawDeclModifierListSyntax.init(raw:))! } public var unexpectedBetweenModifiersAndBindingSpecifier: RawUnexpectedNodesSyntax? { diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift index 0a92075eaac..2dc1bad71ad 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift @@ -269,7 +269,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("actor")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -340,7 +340,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("associatedtype")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -523,7 +523,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("class")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -608,7 +608,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.identifier), .tokenKind(.wildcard)])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -853,7 +853,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("deinit")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1026,7 +1026,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.identifier)])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1044,7 +1044,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("case")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1081,7 +1081,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .enumCaseParameter: assert(layout.count == 15) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawTokenSyntax?.self, tokenChoices: [.tokenKind(.identifier), .tokenKind(.wildcard)])) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1100,7 +1100,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("enum")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1155,7 +1155,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("extension")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1227,7 +1227,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("func")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1271,7 +1271,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.identifier), .tokenKind(.wildcard)])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1470,7 +1470,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("import")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1550,7 +1550,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("init")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1702,7 +1702,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("macro")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1721,7 +1721,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.pound)])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -1823,7 +1823,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.identifier)])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -2095,7 +2095,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("precedencegroup")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -2159,7 +2159,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("protocol")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -2321,7 +2321,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("struct")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -2355,7 +2355,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("subscript")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -2536,7 +2536,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("typealias")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -2629,7 +2629,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.keyword("let"), .keyword("var"), .keyword("inout")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift index 6144c306528..c656e04ccf3 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift @@ -314,7 +314,7 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndActorKeyword: UnexpectedNodesSyntax? = nil, actorKeyword: TokenSyntax = .keyword(.actor), _ unexpectedBetweenActorKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -356,7 +356,7 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndActorKeyword?.raw, actorKeyword.raw, unexpectedBetweenActorKeywordAndName?.raw, @@ -437,12 +437,12 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = ActorDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = ActorDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -685,7 +685,7 @@ public struct AssociatedTypeDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndAssociatedtypeKeyword: UnexpectedNodesSyntax? = nil, associatedtypeKeyword: TokenSyntax = .keyword(.associatedtype), _ unexpectedBetweenAssociatedtypeKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -723,7 +723,7 @@ public struct AssociatedTypeDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndAssociatedtypeKeyword?.raw, associatedtypeKeyword.raw, unexpectedBetweenAssociatedtypeKeywordAndName?.raw, @@ -804,12 +804,12 @@ public struct AssociatedTypeDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Modifiers attached to the associated type declaration. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = AssociatedTypeDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = AssociatedTypeDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -1035,7 +1035,7 @@ public struct ClassDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndClassKeyword: UnexpectedNodesSyntax? = nil, classKeyword: TokenSyntax = .keyword(.class), _ unexpectedBetweenClassKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -1077,7 +1077,7 @@ public struct ClassDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndClassKeyword?.raw, classKeyword.raw, unexpectedBetweenClassKeywordAndName?.raw, @@ -1160,12 +1160,12 @@ public struct ClassDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Modifiers attached to the class declaration, such as `public`. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = ClassDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = ClassDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -1390,7 +1390,7 @@ public struct DeinitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndDeinitKeyword: UnexpectedNodesSyntax? = nil, deinitKeyword: TokenSyntax = .keyword(.deinit), _ unexpectedBetweenDeinitKeywordAndEffectSpecifiers: UnexpectedNodesSyntax? = nil, @@ -1420,7 +1420,7 @@ public struct DeinitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndDeinitKeyword?.raw, deinitKeyword.raw, unexpectedBetweenDeinitKeywordAndEffectSpecifiers?.raw, @@ -1497,12 +1497,12 @@ public struct DeinitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Modifiers that are attached to the deinitializer. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = DeinitializerDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = DeinitializerDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -1653,7 +1653,7 @@ public struct EditorPlaceholderDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPlaceholder: UnexpectedNodesSyntax? = nil, placeholder: TokenSyntax, _ unexpectedAfterPlaceholder: UnexpectedNodesSyntax? = nil, @@ -1675,7 +1675,7 @@ public struct EditorPlaceholderDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndPlaceholder?.raw, placeholder.raw, unexpectedAfterPlaceholder?.raw @@ -1748,12 +1748,12 @@ public struct EditorPlaceholderDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// If there were modifiers before the editor placeholder, the `EditorPlaceholderDecl` will contain these. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = EditorPlaceholderDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = EditorPlaceholderDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -1865,7 +1865,7 @@ public struct EnumCaseDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndCaseKeyword: UnexpectedNodesSyntax? = nil, caseKeyword: TokenSyntax = .keyword(.case), _ unexpectedBetweenCaseKeywordAndElements: UnexpectedNodesSyntax? = nil, @@ -1891,7 +1891,7 @@ public struct EnumCaseDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndCaseKeyword?.raw, caseKeyword.raw, unexpectedBetweenCaseKeywordAndElements?.raw, @@ -1966,12 +1966,12 @@ public struct EnumCaseDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// The declaration modifiers applied to the case declaration. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = EnumCaseDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = EnumCaseDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -2138,7 +2138,7 @@ public struct EnumDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndEnumKeyword: UnexpectedNodesSyntax? = nil, enumKeyword: TokenSyntax = .keyword(.enum), _ unexpectedBetweenEnumKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -2180,7 +2180,7 @@ public struct EnumDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndEnumKeyword?.raw, enumKeyword.raw, unexpectedBetweenEnumKeywordAndName?.raw, @@ -2263,12 +2263,12 @@ public struct EnumDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// The declaration modifiers applied to the enum declaration. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = EnumDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = EnumDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -2483,7 +2483,7 @@ public struct ExtensionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndExtensionKeyword: UnexpectedNodesSyntax? = nil, extensionKeyword: TokenSyntax = .keyword(.extension), _ unexpectedBetweenExtensionKeywordAndExtendedType: UnexpectedNodesSyntax? = nil, @@ -2521,7 +2521,7 @@ public struct ExtensionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndExtensionKeyword?.raw, extensionKeyword.raw, unexpectedBetweenExtensionKeywordAndExtendedType?.raw, @@ -2600,12 +2600,12 @@ public struct ExtensionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = ExtensionDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = ExtensionDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -2797,7 +2797,7 @@ public struct FunctionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFuncKeyword: UnexpectedNodesSyntax? = nil, funcKeyword: TokenSyntax = .keyword(.func), _ unexpectedBetweenFuncKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -2839,7 +2839,7 @@ public struct FunctionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndFuncKeyword?.raw, funcKeyword.raw, unexpectedBetweenFuncKeywordAndName?.raw, @@ -2920,12 +2920,12 @@ public struct FunctionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = FunctionDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = FunctionDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -3301,7 +3301,7 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndImportKeyword: UnexpectedNodesSyntax? = nil, importKeyword: TokenSyntax = .keyword(.import), _ unexpectedBetweenImportKeywordAndImportKindSpecifier: UnexpectedNodesSyntax? = nil, @@ -3331,7 +3331,7 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndImportKeyword?.raw, importKeyword.raw, unexpectedBetweenImportKeywordAndImportKindSpecifier?.raw, @@ -3408,12 +3408,12 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Modifiers attached to the import declaration. Currently, no modifiers are supported by Swift. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = ImportDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = ImportDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -3612,7 +3612,7 @@ public struct InitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndInitKeyword: UnexpectedNodesSyntax? = nil, initKeyword: TokenSyntax = .keyword(.`init`), _ unexpectedBetweenInitKeywordAndOptionalMark: UnexpectedNodesSyntax? = nil, @@ -3654,7 +3654,7 @@ public struct InitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndInitKeyword?.raw, initKeyword.raw, unexpectedBetweenInitKeywordAndOptionalMark?.raw, @@ -3737,12 +3737,12 @@ public struct InitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Modifiers attached to the initializer - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = InitializerDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = InitializerDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -3959,7 +3959,7 @@ public struct MacroDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndMacroKeyword: UnexpectedNodesSyntax? = nil, macroKeyword: TokenSyntax = .keyword(.macro), _ unexpectedBetweenMacroKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -4001,7 +4001,7 @@ public struct MacroDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndMacroKeyword?.raw, macroKeyword.raw, unexpectedBetweenMacroKeywordAndName?.raw, @@ -4082,12 +4082,12 @@ public struct MacroDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = MacroDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = MacroDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -4301,7 +4301,7 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPound: UnexpectedNodesSyntax? = nil, pound: TokenSyntax = .poundToken(), _ unexpectedBetweenPoundAndMacroName: UnexpectedNodesSyntax? = nil, @@ -4351,7 +4351,7 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndPound?.raw, pound.raw, unexpectedBetweenPoundAndMacroName?.raw, @@ -4436,12 +4436,12 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = MacroExpansionDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = MacroExpansionDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -4743,7 +4743,7 @@ public struct MissingDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPlaceholder: UnexpectedNodesSyntax? = nil, placeholder: TokenSyntax, _ unexpectedAfterPlaceholder: UnexpectedNodesSyntax? = nil, @@ -4765,7 +4765,7 @@ public struct MissingDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndPlaceholder?.raw, placeholder.raw, unexpectedAfterPlaceholder?.raw @@ -4838,12 +4838,12 @@ public struct MissingDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// If there were standalone modifiers without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = MissingDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = MissingDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -5320,7 +5320,7 @@ public struct PrecedenceGroupDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPrecedencegroupKeyword: UnexpectedNodesSyntax? = nil, precedencegroupKeyword: TokenSyntax = .keyword(.precedencegroup), _ unexpectedBetweenPrecedencegroupKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -5358,7 +5358,7 @@ public struct PrecedenceGroupDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndPrecedencegroupKeyword?.raw, precedencegroupKeyword.raw, unexpectedBetweenPrecedencegroupKeywordAndName?.raw, @@ -5439,12 +5439,12 @@ public struct PrecedenceGroupDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// The declaration modifiers applied to the 'precedencegroup' declaration. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = PrecedenceGroupDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = PrecedenceGroupDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -5679,7 +5679,7 @@ public struct ProtocolDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndProtocolKeyword: UnexpectedNodesSyntax? = nil, protocolKeyword: TokenSyntax = .keyword(.protocol), _ unexpectedBetweenProtocolKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -5721,7 +5721,7 @@ public struct ProtocolDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndProtocolKeyword?.raw, protocolKeyword.raw, unexpectedBetweenProtocolKeywordAndName?.raw, @@ -5804,12 +5804,12 @@ public struct ProtocolDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Modifiers attached to the protocol declaration, such as `public`. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = ProtocolDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = ProtocolDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -6090,7 +6090,7 @@ public struct StructDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndStructKeyword: UnexpectedNodesSyntax? = nil, structKeyword: TokenSyntax = .keyword(.struct), _ unexpectedBetweenStructKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -6132,7 +6132,7 @@ public struct StructDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndStructKeyword?.raw, structKeyword.raw, unexpectedBetweenStructKeywordAndName?.raw, @@ -6215,12 +6215,12 @@ public struct StructDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Modifiers that are attached to the struct declaration. - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = StructDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = StructDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -6437,7 +6437,7 @@ public struct SubscriptDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndSubscriptKeyword: UnexpectedNodesSyntax? = nil, subscriptKeyword: TokenSyntax = .keyword(.subscript), _ unexpectedBetweenSubscriptKeywordAndGenericParameterClause: UnexpectedNodesSyntax? = nil, @@ -6479,7 +6479,7 @@ public struct SubscriptDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndSubscriptKeyword?.raw, subscriptKeyword.raw, unexpectedBetweenSubscriptKeywordAndGenericParameterClause?.raw, @@ -6560,12 +6560,12 @@ public struct SubscriptDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = SubscriptDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = SubscriptDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -6777,7 +6777,7 @@ public struct TypeAliasDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndTypealiasKeyword: UnexpectedNodesSyntax? = nil, typealiasKeyword: TokenSyntax = .keyword(.typealias), _ unexpectedBetweenTypealiasKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -6815,7 +6815,7 @@ public struct TypeAliasDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndTypealiasKeyword?.raw, typealiasKeyword.raw, unexpectedBetweenTypealiasKeywordAndName?.raw, @@ -6894,12 +6894,12 @@ public struct TypeAliasDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = TypeAliasDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = TypeAliasDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -7093,7 +7093,7 @@ public struct VariableDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndBindingSpecifier: UnexpectedNodesSyntax? = nil, bindingSpecifier: TokenSyntax, _ unexpectedBetweenBindingSpecifierAndBindings: UnexpectedNodesSyntax? = nil, @@ -7119,7 +7119,7 @@ public struct VariableDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndBindingSpecifier?.raw, bindingSpecifier.raw, unexpectedBetweenBindingSpecifierAndBindings?.raw, @@ -7192,12 +7192,12 @@ public struct VariableDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = VariableDeclSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = VariableDeclSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift index a1c57ab49b7..340c857ed25 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift @@ -3025,7 +3025,7 @@ public struct ClosureParameterSyntax: SyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax? = nil, firstName: TokenSyntax, _ unexpectedBetweenFirstNameAndSecondName: UnexpectedNodesSyntax? = nil, @@ -3067,7 +3067,7 @@ public struct ClosureParameterSyntax: SyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndFirstName?.raw, firstName.raw, unexpectedBetweenFirstNameAndSecondName?.raw, @@ -3148,12 +3148,12 @@ public struct ClosureParameterSyntax: SyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = ClosureParameterSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = ClosureParameterSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -7776,7 +7776,7 @@ public struct EnumCaseParameterSyntax: SyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax? = nil, firstName: TokenSyntax? = nil, _ unexpectedBetweenFirstNameAndSecondName: UnexpectedNodesSyntax? = nil, @@ -7814,7 +7814,7 @@ public struct EnumCaseParameterSyntax: SyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndFirstName?.raw, firstName?.raw, unexpectedBetweenFirstNameAndSecondName?.raw, @@ -7851,12 +7851,12 @@ public struct EnumCaseParameterSyntax: SyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = EnumCaseParameterSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = EnumCaseParameterSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -8770,7 +8770,7 @@ public struct FunctionParameterSyntax: SyntaxProtocol, SyntaxHashable { _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax? = nil, firstName: TokenSyntax, _ unexpectedBetweenFirstNameAndSecondName: UnexpectedNodesSyntax? = nil, @@ -8816,7 +8816,7 @@ public struct FunctionParameterSyntax: SyntaxProtocol, SyntaxHashable { unexpectedBeforeAttributes?.raw, attributes?.raw, unexpectedBetweenAttributesAndModifiers?.raw, - modifiers?.raw, + modifiers.raw, unexpectedBetweenModifiersAndFirstName?.raw, firstName.raw, unexpectedBetweenFirstNameAndSecondName?.raw, @@ -8899,12 +8899,12 @@ public struct FunctionParameterSyntax: SyntaxProtocol, SyntaxHashable { } } - public var modifiers: DeclModifierListSyntax? { + public var modifiers: DeclModifierListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(DeclModifierListSyntax.init) + return DeclModifierListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = FunctionParameterSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = FunctionParameterSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift index 7ddffb0a9a0..548ee3df72b 100644 --- a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift +++ b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift @@ -359,7 +359,7 @@ extension VariableDeclSyntax { public init( leadingTrivia: Trivia = [], attributes: AttributeListSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], _ bindingSpecifier: Keyword, name: PatternSyntax, type: TypeAnnotationSyntax? = nil, diff --git a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift index e583bfd4564..1216ef5ebd9 100644 --- a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift +++ b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift @@ -62,7 +62,7 @@ extension ActorDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndActorKeyword: UnexpectedNodesSyntax? = nil, actorKeyword: TokenSyntax = .keyword(.actor), unexpectedBetweenActorKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -163,7 +163,7 @@ extension ClassDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndClassKeyword: UnexpectedNodesSyntax? = nil, classKeyword: TokenSyntax = .keyword(.class), unexpectedBetweenClassKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -318,7 +318,7 @@ extension DeinitializerDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndDeinitKeyword: UnexpectedNodesSyntax? = nil, deinitKeyword: TokenSyntax = .keyword(.deinit), unexpectedBetweenDeinitKeywordAndEffectSpecifiers: UnexpectedNodesSyntax? = nil, @@ -382,7 +382,7 @@ extension EnumCaseDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndCaseKeyword: UnexpectedNodesSyntax? = nil, caseKeyword: TokenSyntax = .keyword(.case), unexpectedBetweenCaseKeywordAndElements: UnexpectedNodesSyntax? = nil, @@ -413,7 +413,7 @@ extension EnumDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndEnumKeyword: UnexpectedNodesSyntax? = nil, enumKeyword: TokenSyntax = .keyword(.enum), unexpectedBetweenEnumKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -495,7 +495,7 @@ extension ExtensionDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndExtensionKeyword: UnexpectedNodesSyntax? = nil, extensionKeyword: TokenSyntax = .keyword(.extension), unexpectedBetweenExtensionKeywordAndExtendedType: UnexpectedNodesSyntax? = nil, @@ -632,7 +632,7 @@ extension FunctionDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndFuncKeyword: UnexpectedNodesSyntax? = nil, funcKeyword: TokenSyntax = .keyword(.func), unexpectedBetweenFuncKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -878,7 +878,7 @@ extension InitializerDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndInitKeyword: UnexpectedNodesSyntax? = nil, initKeyword: TokenSyntax = .keyword(.`init`), unexpectedBetweenInitKeywordAndOptionalMark: UnexpectedNodesSyntax? = nil, @@ -954,7 +954,7 @@ extension MacroExpansionDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndPound: UnexpectedNodesSyntax? = nil, pound: TokenSyntax = .poundToken(), unexpectedBetweenPoundAndMacroName: UnexpectedNodesSyntax? = nil, @@ -1083,7 +1083,7 @@ extension ProtocolDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndProtocolKeyword: UnexpectedNodesSyntax? = nil, protocolKeyword: TokenSyntax = .keyword(.protocol), unexpectedBetweenProtocolKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -1203,7 +1203,7 @@ extension StructDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndStructKeyword: UnexpectedNodesSyntax? = nil, structKeyword: TokenSyntax = .keyword(.struct), unexpectedBetweenStructKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -1432,7 +1432,7 @@ extension VariableDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndBindingSpecifier: UnexpectedNodesSyntax? = nil, bindingSpecifier: TokenSyntax, unexpectedBetweenBindingSpecifierAndBindings: UnexpectedNodesSyntax? = nil, diff --git a/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift b/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift index 93091cd62fd..2740925d817 100644 --- a/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift +++ b/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift @@ -66,7 +66,7 @@ extension ActorDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndActorKeyword: UnexpectedNodesSyntax? = nil, actorKeyword: TokenSyntax = .keyword(.actor), unexpectedBetweenActorKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -144,7 +144,7 @@ extension ClassDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndClassKeyword: UnexpectedNodesSyntax? = nil, classKeyword: TokenSyntax = .keyword(.class), unexpectedBetweenClassKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -193,7 +193,7 @@ extension EnumDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndEnumKeyword: UnexpectedNodesSyntax? = nil, enumKeyword: TokenSyntax = .keyword(.enum), unexpectedBetweenEnumKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -377,7 +377,7 @@ extension FunctionDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndFuncKeyword: UnexpectedNodesSyntax? = nil, funcKeyword: TokenSyntax = .keyword(.func), unexpectedBetweenFuncKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -598,7 +598,7 @@ extension MacroExpansionDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndPoundToken: UnexpectedNodesSyntax? = nil, poundToken: TokenSyntax = .poundToken(), unexpectedBetweenPoundTokenAndMacro: UnexpectedNodesSyntax? = nil, @@ -704,7 +704,7 @@ extension ProtocolDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndProtocolKeyword: UnexpectedNodesSyntax? = nil, protocolKeyword: TokenSyntax = .keyword(.protocol), unexpectedBetweenProtocolKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -778,7 +778,7 @@ extension StructDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndStructKeyword: UnexpectedNodesSyntax? = nil, structKeyword: TokenSyntax = .keyword(.struct), unexpectedBetweenStructKeywordAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -963,7 +963,7 @@ extension VariableDeclSyntax { unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, attributes: AttributeListSyntax? = nil, unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, - modifiers: DeclModifierListSyntax? = nil, + modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndBindingKeyword: UnexpectedNodesSyntax? = nil, bindingKeyword: TokenSyntax, unexpectedBetweenBindingKeywordAndBindings: UnexpectedNodesSyntax? = nil, diff --git a/Sources/SwiftSyntaxMacroExpansion/MacroExpansion.swift b/Sources/SwiftSyntaxMacroExpansion/MacroExpansion.swift index 75b60e6ec8d..75c18ac09d5 100644 --- a/Sources/SwiftSyntaxMacroExpansion/MacroExpansion.swift +++ b/Sources/SwiftSyntaxMacroExpansion/MacroExpansion.swift @@ -107,7 +107,7 @@ public func expandFreestandingMacro( // Strip any indentation from the attributes and modifiers that we are // inheriting. The expanded macro should start at the leftmost column. let attributes = declMacroDef.propagateFreestandingMacroAttributes ? expansionDecl.attributes?.withIndentationRemoved : nil - let modifiers = declMacroDef.propagateFreestandingMacroModifiers ? expansionDecl.modifiers?.withIndentationRemoved : nil + let modifiers = declMacroDef.propagateFreestandingMacroModifiers ? expansionDecl.modifiers.withIndentationRemoved : nil rewritten = rewritten.map { $0.applying(attributes: attributes, modifiers: modifiers) } @@ -363,7 +363,7 @@ fileprivate extension DeclSyntax { attributes: AttributeListSyntax?, modifiers: DeclModifierListSyntax? ) -> DeclSyntax { - func _combine(_ left: C, _ right: C?) -> C? { + func _combine(_ left: C, _ right: C?) -> C { guard let right = right else { return left } var elems: [C.Element] = [] elems += left diff --git a/Tests/SwiftSyntaxTest/RawSyntaxTests.swift b/Tests/SwiftSyntaxTest/RawSyntaxTests.swift index 791579dd6d6..7ff430052f8 100644 --- a/Tests/SwiftSyntaxTest/RawSyntaxTests.swift +++ b/Tests/SwiftSyntaxTest/RawSyntaxTests.swift @@ -54,7 +54,7 @@ fileprivate func cannedStructDecl(arena: SyntaxArena) -> RawStructDeclSyntax { ) return RawStructDeclSyntax( attributes: nil, - modifiers: nil, + modifiers: RawDeclModifierListSyntax(elements: [], arena: arena), structKeyword: structKW, name: fooID, genericParameterClause: nil, From b173512e98d865496400d151ef6dc0542b496857 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 9 Aug 2023 12:27:27 -0700 Subject: [PATCH 4/5] Make all `AttributeListSyntax` children non-optional --- .../Sources/SyntaxSupport/CommonNodes.swift | 5 +- .../Sources/SyntaxSupport/DeclNodes.swift | 105 ++++----- .../Sources/SyntaxSupport/ExprNodes.swift | 10 +- .../Sources/SyntaxSupport/GenericNodes.swift | 3 +- .../Sources/SyntaxSupport/Traits.swift | 4 +- .../Sources/SyntaxSupport/TypeNodes.swift | 3 +- .../swiftparser/ParserEntryFile.swift | 10 +- Sources/SwiftParser/Attributes.swift | 4 +- .../CollectionNodes+Parsable.swift | 7 +- Sources/SwiftParser/Declarations.swift | 12 +- Sources/SwiftParser/Nominals.swift | 12 +- Sources/SwiftParser/Parser.swift | 13 ++ Sources/SwiftParser/Types.swift | 6 +- .../generated/LayoutNodes+Parsable.swift | 10 +- .../MissingNodesError.swift | 2 +- .../OpaqueParameterToGeneric.swift | 2 +- .../SwiftSyntax/MissingNodeInitializers.swift | 4 +- Sources/SwiftSyntax/Raw/RawSyntax.swift | 6 +- .../RenamedChildrenCompatibility.swift | 38 ++-- .../SwiftSyntax/generated/SyntaxTraits.swift | 4 +- .../generated/raw/RawSyntaxNodes.swift | 208 ++++++++--------- .../generated/raw/RawSyntaxValidation.swift | 52 ++--- .../syntaxNodes/SyntaxDeclNodes.swift | 210 +++++++++--------- .../generated/syntaxNodes/SyntaxNodes.swift | 40 ++-- .../syntaxNodes/SyntaxTypeNodes.swift | 10 +- .../ConvenienceInitializers.swift | 4 +- .../generated/BuildableNodes.swift | 26 +-- .../RenamedChildrenBuilderCompatibility.swift | 18 +- .../MacroExpansion.swift | 2 +- .../MacroSystem.swift | 12 +- .../MacroSystemTests.swift | 14 +- Tests/SwiftSyntaxTest/RawSyntaxTests.swift | 2 +- 32 files changed, 428 insertions(+), 430 deletions(-) diff --git a/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift b/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift index 6189dc93092..dfd68452065 100644 --- a/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift @@ -166,9 +166,8 @@ public let COMMON_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - documentation: "If there were standalone attributes without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these.", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + documentation: "If there were standalone attributes without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these." ), Child( name: "Modifiers", diff --git a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift index 281f4bb9e59..3dd860dad75 100644 --- a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift @@ -84,9 +84,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifier", @@ -186,9 +185,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", @@ -275,10 +273,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "Attributes attached to the associated type declaration.", - isOptional: true + documentation: "Attributes attached to the associated type declaration." ), Child( name: "Modifiers", @@ -366,10 +363,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "Attributes attached to the class declaration, such as an `@available` attribute.", - isOptional: true + documentation: "Attributes attached to the class declaration, such as an `@available` attribute." ), Child( name: "Modifiers", @@ -515,10 +511,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "Attributes that are attached to the deinitializer.", - isOptional: true + documentation: "Attributes that are attached to the deinitializer." ), Child( name: "Modifiers", @@ -584,9 +579,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - documentation: "If there were attributes before the editor placeholder, the ``EditorPlaceholderDeclSyntax`` will contain these.", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + documentation: "If there were attributes before the editor placeholder, the ``EditorPlaceholderDeclSyntax`` will contain these." ), Child( name: "Modifiers", @@ -702,10 +696,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "The attributes applied to the case declaration.", - isOptional: true + documentation: "The attributes applied to the case declaration." ), Child( name: "Modifiers", @@ -788,10 +781,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "The attributes applied to the enum declaration.", - isOptional: true + documentation: "The attributes applied to the enum declaration." ), Child( name: "Modifiers", @@ -859,9 +851,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", @@ -909,9 +900,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", @@ -978,9 +968,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", @@ -1145,10 +1134,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "Attributes attached to the import declaration, for example `@testable`.", - isOptional: true + documentation: "Attributes attached to the import declaration, for example `@testable`." ), Child( name: "Modifiers", @@ -1260,10 +1248,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "Attributes that are attached to the initializer.", - isOptional: true + documentation: "Attributes that are attached to the initializer." ), Child( name: "Modifiers", @@ -1328,9 +1315,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", @@ -1387,9 +1373,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", @@ -1827,10 +1812,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "The attributes applied to the 'precedencegroup' declaration.", - isOptional: true + documentation: "The attributes applied to the 'precedencegroup' declaration." ), Child( name: "Modifiers", @@ -1943,10 +1927,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "Attributes attached to the protocol declaration, such as an `@available` attribute.", - isOptional: true + documentation: "Attributes attached to the protocol declaration, such as an `@available` attribute." ), Child( name: "Modifiers", @@ -2114,10 +2097,9 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), nameForDiagnostics: "attributes", - documentation: "Attributes that are attached to the struct declaration.", - isOptional: true + documentation: "Attributes that are attached to the struct declaration." ), Child( name: "Modifiers", @@ -2178,9 +2160,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", @@ -2277,9 +2258,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", @@ -2333,9 +2313,8 @@ public let DECL_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", diff --git a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift index 4df951af4db..3b3743d30ef 100644 --- a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift @@ -373,9 +373,8 @@ public let EXPR_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Modifiers", @@ -525,9 +524,8 @@ public let EXPR_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - nameForDiagnostics: "attributes", - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), + nameForDiagnostics: "attributes" ), Child( name: "Capture", diff --git a/CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift b/CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift index 997956130d3..4934f2b798e 100644 --- a/CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift @@ -90,8 +90,7 @@ public let GENERIC_NODES: [Node] = [ children: [ Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true) ), Child( name: "EachKeyword", diff --git a/CodeGeneration/Sources/SyntaxSupport/Traits.swift b/CodeGeneration/Sources/SyntaxSupport/Traits.swift index c9933335810..ec354825034 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Traits.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Traits.swift @@ -37,7 +37,7 @@ public let TRAITS: [Trait] = [ Trait( traitName: "DeclGroup", children: [ - Child(name: "Attributes", kind: .node(kind: .attributeList), isOptional: true), + Child(name: "Attributes", kind: .node(kind: .attributeList)), Child(name: "Modifiers", kind: .node(kind: .declModifierList)), Child(name: "InheritanceClause", kind: .node(kind: .inheritanceClause), isOptional: true), Child( @@ -105,7 +105,7 @@ public let TRAITS: [Trait] = [ Trait( traitName: "WithAttributes", children: [ - Child(name: "Attributes", kind: .node(kind: .attributeList), isOptional: true) + Child(name: "Attributes", kind: .node(kind: .attributeList)) ] ), Trait( diff --git a/CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift b/CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift index 80bf53d5900..1e826848fd5 100644 --- a/CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift @@ -60,8 +60,7 @@ public let TYPE_NODES: [Node] = [ ), Child( name: "Attributes", - kind: .collection(kind: .attributeList, collectionElementName: "Attribute"), - isOptional: true + kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true) ), Child( name: "BaseType", diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserEntryFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserEntryFile.swift index d32cfa34525..d4d5b3e45f3 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserEntryFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserEntryFile.swift @@ -57,7 +57,15 @@ let parserEntryFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { // The missing item is not necessary to be a declaration, // which is just a placeholder here return RawCodeBlockItemSyntax( - item: .decl(RawDeclSyntax(RawMissingDeclSyntax(attributes: nil, modifiers: self.emptyCollection(RawDeclModifierListSyntax.self), arena: self.arena))), + item: .decl( + RawDeclSyntax( + RawMissingDeclSyntax( + attributes: self.emptyCollection(RawAttributeListSyntax.self), + modifiers: self.emptyCollection(RawDeclModifierListSyntax.self), + arena: self.arena + ) + ) + ), semicolon: nil, arena: self.arena ) diff --git a/Sources/SwiftParser/Attributes.swift b/Sources/SwiftParser/Attributes.swift index 2b74e7e58dc..1f2267b9360 100644 --- a/Sources/SwiftParser/Attributes.swift +++ b/Sources/SwiftParser/Attributes.swift @@ -13,9 +13,9 @@ @_spi(RawSyntax) import SwiftSyntax extension Parser { - mutating func parseAttributeList() -> RawAttributeListSyntax? { + mutating func parseAttributeList() -> RawAttributeListSyntax { guard self.at(.atSign, .poundIf) else { - return nil + return self.emptyCollection(RawAttributeListSyntax.self) } var elements = [RawAttributeListSyntax.Element]() diff --git a/Sources/SwiftParser/CollectionNodes+Parsable.swift b/Sources/SwiftParser/CollectionNodes+Parsable.swift index 14f76550625..900607b0e12 100644 --- a/Sources/SwiftParser/CollectionNodes+Parsable.swift +++ b/Sources/SwiftParser/CollectionNodes+Parsable.swift @@ -58,7 +58,7 @@ extension AccessorDeclListSyntax: SyntaxParseable { return parser.parseAccessorList() ?? RawAccessorDeclListSyntax(elements: [], arena: parser.arena) } makeMissing: { remainingTokens, arena in return RawAccessorDeclSyntax( - attributes: nil, + attributes: RawAttributeListSyntax(elements: [], arena: arena), modifier: nil, accessorSpecifier: RawTokenSyntax(missing: .keyword, text: "get", arena: arena), parameters: nil, @@ -73,8 +73,7 @@ extension AccessorDeclListSyntax: SyntaxParseable { extension AttributeListSyntax: SyntaxParseable { public static func parse(from parser: inout Parser) -> Self { return parse(from: &parser) { parser in - let node = parser.parseAttributeList() ?? RawAttributeListSyntax(elements: [], arena: parser.arena) - return RawSyntax(node) + return RawSyntax(parser.parseAttributeList()) } makeMissing: { remainingTokens, arena in return RawAttributeSyntax( atSign: RawTokenSyntax(missing: .atSign, arena: arena), @@ -106,7 +105,7 @@ extension MemberBlockItemListSyntax: SyntaxParseable { return RawSyntax(parser.parseMemberDeclList()) } makeMissing: { remainingTokens, arena in let missingDecl = RawMissingDeclSyntax( - attributes: nil, + attributes: RawAttributeListSyntax(elements: [], arena: arena), modifiers: RawDeclModifierListSyntax(elements: [], arena: arena), placeholder: RawTokenSyntax(missing: .identifier, text: "<#declaration#>", arena: arena), RawUnexpectedNodesSyntax(remainingTokens, arena: arena), diff --git a/Sources/SwiftParser/Declarations.swift b/Sources/SwiftParser/Declarations.swift index 1ec6cb0dbaa..8a34be055e3 100644 --- a/Sources/SwiftParser/Declarations.swift +++ b/Sources/SwiftParser/Declarations.swift @@ -157,10 +157,10 @@ extension TokenConsumer { extension Parser { struct DeclAttributes { - var attributes: RawAttributeListSyntax? + var attributes: RawAttributeListSyntax var modifiers: RawDeclModifierListSyntax - init(attributes: RawAttributeListSyntax?, modifiers: RawDeclModifierListSyntax) { + init(attributes: RawAttributeListSyntax, modifiers: RawDeclModifierListSyntax) { self.attributes = attributes self.modifiers = modifiers } @@ -393,7 +393,7 @@ extension Parser { var each = self.consume(if: .keyword(.each)) let (unexpectedBetweenEachAndName, name) = self.expectIdentifier(allowSelfOrCapitalSelfAsIdentifier: true) - if attributes == nil && each == nil && unexpectedBetweenEachAndName == nil && name.isMissing && elements.isEmpty && !self.at(prefix: ">") { + if attributes.isEmpty && each == nil && unexpectedBetweenEachAndName == nil && name.isMissing && elements.isEmpty && !self.at(prefix: ">") { break } @@ -678,7 +678,7 @@ extension Parser { remainingTokens, decl: RawDeclSyntax( RawMissingDeclSyntax( - attributes: nil, + attributes: self.emptyCollection(RawAttributeListSyntax.self), modifiers: self.emptyCollection(RawDeclModifierListSyntax.self), arena: self.arena ) @@ -1301,7 +1301,7 @@ extension Parser { } struct AccessorIntroducer { - var attributes: RawAttributeListSyntax? + var attributes: RawAttributeListSyntax var modifier: RawDeclModifierSyntax? var kind: AccessorDeclSyntax.AccessorSpecifierOptions var unexpectedBeforeToken: RawUnexpectedNodesSyntax? @@ -1533,7 +1533,7 @@ extension Parser { } } - var unexpectedBeforeFixity = RawUnexpectedNodesSyntax(attrs.attributes?.elements ?? [], arena: self.arena) + var unexpectedBeforeFixity = RawUnexpectedNodesSyntax(attrs.attributes.elements, arena: self.arena) var fixity: RawTokenSyntax? var unexpectedAfterFixity: RawUnexpectedNodesSyntax? diff --git a/Sources/SwiftParser/Nominals.swift b/Sources/SwiftParser/Nominals.swift index b680289d189..7e65bea5068 100644 --- a/Sources/SwiftParser/Nominals.swift +++ b/Sources/SwiftParser/Nominals.swift @@ -16,7 +16,7 @@ protocol NominalTypeDeclarationTrait { associatedtype PrimaryOrGenerics init( - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, @@ -34,7 +34,7 @@ protocol NominalTypeDeclarationTrait { extension RawProtocolDeclSyntax: NominalTypeDeclarationTrait { init( - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, @@ -68,7 +68,7 @@ extension RawProtocolDeclSyntax: NominalTypeDeclarationTrait { extension RawClassDeclSyntax: NominalTypeDeclarationTrait { init( - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, @@ -102,7 +102,7 @@ extension RawClassDeclSyntax: NominalTypeDeclarationTrait { extension RawActorDeclSyntax: NominalTypeDeclarationTrait { init( - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, @@ -136,7 +136,7 @@ extension RawActorDeclSyntax: NominalTypeDeclarationTrait { extension RawStructDeclSyntax: NominalTypeDeclarationTrait { init( - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, @@ -170,7 +170,7 @@ extension RawStructDeclSyntax: NominalTypeDeclarationTrait { extension RawEnumDeclSyntax: NominalTypeDeclarationTrait { init( - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, modifiers: RawDeclModifierListSyntax, _ unexpectedBeforeIntroducerKeyword: RawUnexpectedNodesSyntax?, introducerKeyword: RawTokenSyntax, diff --git a/Sources/SwiftParser/Parser.swift b/Sources/SwiftParser/Parser.swift index a445a3b9e26..fe1f681b29c 100644 --- a/Sources/SwiftParser/Parser.swift +++ b/Sources/SwiftParser/Parser.swift @@ -155,6 +155,19 @@ public struct Parser { return _emptyRawDeclModifierListSyntax! } + var _emptyRawAttributeListSyntax: RawAttributeListSyntax? + + /// Create an empty collection of the given type. + /// + /// These empty collections are only created once and the same node is returned + /// on subsequent calls, reducing memory usage. + mutating func emptyCollection(_: RawAttributeListSyntax.Type) -> RawAttributeListSyntax { + if _emptyRawAttributeListSyntax == nil { + _emptyRawAttributeListSyntax = RawAttributeListSyntax(elements: [], arena: self.arena) + } + return _emptyRawAttributeListSyntax! + } + /// The delegated initializer for the parser. /// /// - Parameters diff --git a/Sources/SwiftParser/Types.swift b/Sources/SwiftParser/Types.swift index 506b61635c0..03f459cdfc0 100644 --- a/Sources/SwiftParser/Types.swift +++ b/Sources/SwiftParser/Types.swift @@ -100,7 +100,7 @@ extension Parser { ) } - if unexpectedBeforeAttrList != nil || specifier != nil || attrList != nil { + if unexpectedBeforeAttrList != nil || specifier != nil || !attrList.isEmpty { return RawTypeSyntax( RawAttributedTypeSyntax( specifier: specifier, @@ -862,7 +862,7 @@ extension Parser.Lookahead { extension Parser { mutating func parseTypeAttributeList(misplacedSpecifiers: [RawTokenSyntax] = []) -> ( - specifier: RawTokenSyntax?, unexpectedBeforeAttributes: RawUnexpectedNodesSyntax?, attributes: RawAttributeListSyntax? + specifier: RawTokenSyntax?, unexpectedBeforeAttributes: RawUnexpectedNodesSyntax?, attributes: RawAttributeListSyntax ) { var specifier: RawTokenSyntax? = nil if canHaveParameterSpecifier { @@ -889,7 +889,7 @@ extension Parser { return (specifier, unexpectedBeforeAttributeList, self.parseTypeAttributeListPresent()) } - return (specifier, unexpectedBeforeAttributeList, nil) + return (specifier, unexpectedBeforeAttributeList, self.emptyCollection(RawAttributeListSyntax.self)) } mutating func parseTypeAttributeListPresent() -> RawAttributeListSyntax { diff --git a/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift b/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift index 8ed6613c2a1..81cc422106e 100644 --- a/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift +++ b/Sources/SwiftParser/generated/LayoutNodes+Parsable.swift @@ -330,7 +330,15 @@ fileprivate extension Parser { // The missing item is not necessary to be a declaration, // which is just a placeholder here return RawCodeBlockItemSyntax( - item: .decl(RawDeclSyntax(RawMissingDeclSyntax(attributes: nil, modifiers: self.emptyCollection(RawDeclModifierListSyntax.self), arena: self.arena))), + item: .decl( + RawDeclSyntax( + RawMissingDeclSyntax( + attributes: self.emptyCollection(RawAttributeListSyntax.self), + modifiers: self.emptyCollection(RawDeclModifierListSyntax.self), + arena: self.arena + ) + ) + ), semicolon: nil, arena: self.arena ) diff --git a/Sources/SwiftParserDiagnostics/MissingNodesError.swift b/Sources/SwiftParserDiagnostics/MissingNodesError.swift index 7b8b94cf70d..b03a8fbae2b 100644 --- a/Sources/SwiftParserDiagnostics/MissingNodesError.swift +++ b/Sources/SwiftParserDiagnostics/MissingNodesError.swift @@ -253,7 +253,7 @@ public struct MissingNodesError: ParserError { if let missingDecl = firstMissingNode.as(MissingDeclSyntax.self) { if let lastModifier = missingDecl.modifiers.last { return "after '\(lastModifier.name.text)' modifier" - } else if missingDecl.attributes != nil { + } else if !missingDecl.attributes.isEmpty { return "after attribute" } } diff --git a/Sources/SwiftRefactor/OpaqueParameterToGeneric.swift b/Sources/SwiftRefactor/OpaqueParameterToGeneric.swift index 6346a31adb0..bc042790ad0 100644 --- a/Sources/SwiftRefactor/OpaqueParameterToGeneric.swift +++ b/Sources/SwiftRefactor/OpaqueParameterToGeneric.swift @@ -55,7 +55,7 @@ fileprivate class SomeParameterRewriter: SyntaxRewriter { } let genericParam = GenericParameterSyntax( - attributes: nil, + attributes: [], eachKeyword: nil, name: paramNameSyntax, colon: colon, diff --git a/Sources/SwiftSyntax/MissingNodeInitializers.swift b/Sources/SwiftSyntax/MissingNodeInitializers.swift index 5c3614683d2..c8faf49c0ca 100644 --- a/Sources/SwiftSyntax/MissingNodeInitializers.swift +++ b/Sources/SwiftSyntax/MissingNodeInitializers.swift @@ -12,7 +12,7 @@ public extension MissingDeclSyntax { init( - attributes: AttributeListSyntax?, + attributes: AttributeListSyntax, modifiers: DeclModifierListSyntax, arena: __shared SyntaxArena ) { @@ -68,7 +68,7 @@ public extension MissingSyntax { public extension RawMissingDeclSyntax { init( - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, modifiers: RawDeclModifierListSyntax, arena: __shared SyntaxArena ) { diff --git a/Sources/SwiftSyntax/Raw/RawSyntax.swift b/Sources/SwiftSyntax/Raw/RawSyntax.swift index b5c5ea944f4..9ff39983aa0 100644 --- a/Sources/SwiftSyntax/Raw/RawSyntax.swift +++ b/Sources/SwiftSyntax/Raw/RawSyntax.swift @@ -828,12 +828,14 @@ extension RawSyntax { if leadingTrivia != nil || trailingTrivia != nil { var layout = Array(collection) if let leadingTrivia = leadingTrivia, - let idx = layout.firstIndex(where: { $0 != nil }) + // Find the index of the first non-empty node so we can attach the trivia to it. + let idx = layout.firstIndex(where: { $0 != nil && ($0!.isToken || $0!.totalNodes > 1) }) { layout[idx] = layout[idx]!.withLeadingTrivia(leadingTrivia + (layout[idx]?.formLeadingTrivia() ?? []), arena: arena) } if let trailingTrivia = trailingTrivia, - let idx = layout.lastIndex(where: { $0 != nil }) + // Find the index of the first non-empty node so we can attach the trivia to it. + let idx = layout.lastIndex(where: { $0 != nil && ($0!.isToken || $0!.totalNodes > 1) }) { layout[idx] = layout[idx]!.withTrailingTrivia((layout[idx]?.formTrailingTrivia() ?? []) + trailingTrivia, arena: arena) } diff --git a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift index edbb8b2db5c..2df170c16f0 100644 --- a/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift +++ b/Sources/SwiftSyntax/generated/RenamedChildrenCompatibility.swift @@ -68,7 +68,7 @@ extension AccessorDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifier: UnexpectedNodesSyntax? = nil, modifier: DeclModifierSyntax? = nil, _ unexpectedBetweenModifierAndAccessorKind: UnexpectedNodesSyntax? = nil, @@ -139,7 +139,7 @@ extension ActorDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndActorKeyword: UnexpectedNodesSyntax? = nil, @@ -605,7 +605,7 @@ extension AssociatedTypeDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndAssociatedtypeKeyword: UnexpectedNodesSyntax? = nil, @@ -1124,7 +1124,7 @@ extension ClassDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndClassKeyword: UnexpectedNodesSyntax? = nil, @@ -1379,7 +1379,7 @@ extension ClosureSignatureSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndCapture: UnexpectedNodesSyntax? = nil, capture: ClosureCaptureClauseSyntax? = nil, _ unexpectedBetweenCaptureAndInput: UnexpectedNodesSyntax? = nil, @@ -2383,7 +2383,7 @@ extension EditorPlaceholderDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndIdentifier: UnexpectedNodesSyntax? = nil, @@ -2730,7 +2730,7 @@ extension EnumDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndEnumKeyword: UnexpectedNodesSyntax? = nil, @@ -3085,7 +3085,7 @@ extension FunctionDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFuncKeyword: UnexpectedNodesSyntax? = nil, @@ -3223,7 +3223,7 @@ extension FunctionParameterSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax? = nil, @@ -3759,7 +3759,7 @@ extension GenericParameterSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndEach: UnexpectedNodesSyntax? = nil, each: TokenSyntax? = nil, _ unexpectedBetweenEachAndName: UnexpectedNodesSyntax? = nil, @@ -4019,7 +4019,7 @@ extension ImportDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndImportTok: UnexpectedNodesSyntax? = nil, @@ -4782,7 +4782,7 @@ extension MacroDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndMacroKeyword: UnexpectedNodesSyntax? = nil, @@ -4931,7 +4931,7 @@ extension MacroExpansionDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPoundToken: UnexpectedNodesSyntax? = nil, @@ -6269,7 +6269,7 @@ extension PrecedenceGroupDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPrecedencegroupKeyword: UnexpectedNodesSyntax? = nil, @@ -6607,7 +6607,7 @@ extension ProtocolDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndProtocolKeyword: UnexpectedNodesSyntax? = nil, @@ -7444,7 +7444,7 @@ extension StructDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndStructKeyword: UnexpectedNodesSyntax? = nil, @@ -7684,7 +7684,7 @@ extension SubscriptDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndSubscriptKeyword: UnexpectedNodesSyntax? = nil, @@ -8318,7 +8318,7 @@ extension TypeAliasDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndTypealiasKeyword: UnexpectedNodesSyntax? = nil, @@ -8653,7 +8653,7 @@ extension VariableDeclSyntax { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndBindingKeyword: UnexpectedNodesSyntax? = nil, diff --git a/Sources/SwiftSyntax/generated/SyntaxTraits.swift b/Sources/SwiftSyntax/generated/SyntaxTraits.swift index 170fe078314..56d2259f51a 100644 --- a/Sources/SwiftSyntax/generated/SyntaxTraits.swift +++ b/Sources/SwiftSyntax/generated/SyntaxTraits.swift @@ -58,7 +58,7 @@ public extension SyntaxProtocol { public protocol DeclGroupSyntax: SyntaxProtocol { - var attributes: AttributeListSyntax? { + var attributes: AttributeListSyntax { get set } @@ -364,7 +364,7 @@ public extension SyntaxProtocol { public protocol WithAttributesSyntax: SyntaxProtocol { - var attributes: AttributeListSyntax? { + var attributes: AttributeListSyntax { get set } diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift index d9ce5d944d9..ef7fea54d2f 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift @@ -220,7 +220,7 @@ public struct RawAccessorDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifier: RawUnexpectedNodesSyntax? = nil, modifier: RawDeclModifierSyntax?, _ unexpectedBetweenModifierAndAccessorSpecifier: RawUnexpectedNodesSyntax? = nil, @@ -238,7 +238,7 @@ public struct RawAccessorDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .accessorDecl, uninitializedCount: 13, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifier?.raw layout[3] = modifier?.raw layout[4] = unexpectedBetweenModifierAndAccessorSpecifier?.raw @@ -258,8 +258,8 @@ public struct RawAccessorDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifier: RawUnexpectedNodesSyntax? { @@ -490,7 +490,7 @@ public struct RawActorDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndActorKeyword: RawUnexpectedNodesSyntax? = nil, @@ -512,7 +512,7 @@ public struct RawActorDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .actorDecl, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndActorKeyword?.raw @@ -536,8 +536,8 @@ public struct RawActorDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -1138,7 +1138,7 @@ public struct RawAssociatedTypeDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndAssociatedtypeKeyword: RawUnexpectedNodesSyntax? = nil, @@ -1158,7 +1158,7 @@ public struct RawAssociatedTypeDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .associatedTypeDecl, uninitializedCount: 15, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndAssociatedtypeKeyword?.raw @@ -1180,8 +1180,8 @@ public struct RawAssociatedTypeDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -1612,7 +1612,7 @@ public struct RawAttributedTypeSyntax: RawTypeSyntaxNodeProtocol { _ unexpectedBeforeSpecifier: RawUnexpectedNodesSyntax? = nil, specifier: RawTokenSyntax?, _ unexpectedBetweenSpecifierAndAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndBaseType: RawUnexpectedNodesSyntax? = nil, baseType: RawTypeSyntax, _ unexpectedAfterBaseType: RawUnexpectedNodesSyntax? = nil, @@ -1624,7 +1624,7 @@ public struct RawAttributedTypeSyntax: RawTypeSyntaxNodeProtocol { layout[0] = unexpectedBeforeSpecifier?.raw layout[1] = specifier?.raw layout[2] = unexpectedBetweenSpecifierAndAttributes?.raw - layout[3] = attributes?.raw + layout[3] = attributes.raw layout[4] = unexpectedBetweenAttributesAndBaseType?.raw layout[5] = baseType.raw layout[6] = unexpectedAfterBaseType?.raw @@ -1644,8 +1644,8 @@ public struct RawAttributedTypeSyntax: RawTypeSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[3].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[3].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndBaseType: RawUnexpectedNodesSyntax? { @@ -2927,7 +2927,7 @@ public struct RawClassDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndClassKeyword: RawUnexpectedNodesSyntax? = nil, @@ -2949,7 +2949,7 @@ public struct RawClassDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .classDecl, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndClassKeyword?.raw @@ -2973,8 +2973,8 @@ public struct RawClassDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -3685,7 +3685,7 @@ public struct RawClosureParameterSyntax: RawSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndFirstName: RawUnexpectedNodesSyntax? = nil, @@ -3707,7 +3707,7 @@ public struct RawClosureParameterSyntax: RawSyntaxNodeProtocol { kind: .closureParameter, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndFirstName?.raw @@ -3731,8 +3731,8 @@ public struct RawClosureParameterSyntax: RawSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -3977,7 +3977,7 @@ public struct RawClosureSignatureSyntax: RawSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndCapture: RawUnexpectedNodesSyntax? = nil, capture: RawClosureCaptureClauseSyntax?, _ unexpectedBetweenCaptureAndParameterClause: RawUnexpectedNodesSyntax? = nil, @@ -3995,7 +3995,7 @@ public struct RawClosureSignatureSyntax: RawSyntaxNodeProtocol { kind: .closureSignature, uninitializedCount: 13, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndCapture?.raw layout[3] = capture?.raw layout[4] = unexpectedBetweenCaptureAndParameterClause?.raw @@ -4015,8 +4015,8 @@ public struct RawClosureSignatureSyntax: RawSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndCapture: RawUnexpectedNodesSyntax? { @@ -5739,7 +5739,7 @@ public struct RawDeinitializerDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndDeinitKeyword: RawUnexpectedNodesSyntax? = nil, @@ -5755,7 +5755,7 @@ public struct RawDeinitializerDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .deinitializerDecl, uninitializedCount: 11, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndDeinitKeyword?.raw @@ -5773,8 +5773,8 @@ public struct RawDeinitializerDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -7401,7 +7401,7 @@ public struct RawEditorPlaceholderDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndPlaceholder: RawUnexpectedNodesSyntax? = nil, @@ -7413,7 +7413,7 @@ public struct RawEditorPlaceholderDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .editorPlaceholderDecl, uninitializedCount: 7, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndPlaceholder?.raw @@ -7427,8 +7427,8 @@ public struct RawEditorPlaceholderDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -7591,7 +7591,7 @@ public struct RawEnumCaseDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndCaseKeyword: RawUnexpectedNodesSyntax? = nil, @@ -7605,7 +7605,7 @@ public struct RawEnumCaseDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .enumCaseDecl, uninitializedCount: 9, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndCaseKeyword?.raw @@ -7621,8 +7621,8 @@ public struct RawEnumCaseDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -8091,7 +8091,7 @@ public struct RawEnumDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndEnumKeyword: RawUnexpectedNodesSyntax? = nil, @@ -8113,7 +8113,7 @@ public struct RawEnumDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .enumDecl, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndEnumKeyword?.raw @@ -8137,8 +8137,8 @@ public struct RawEnumDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -8626,7 +8626,7 @@ public struct RawExtensionDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndExtensionKeyword: RawUnexpectedNodesSyntax? = nil, @@ -8646,7 +8646,7 @@ public struct RawExtensionDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .extensionDecl, uninitializedCount: 15, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndExtensionKeyword?.raw @@ -8668,8 +8668,8 @@ public struct RawExtensionDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -9226,7 +9226,7 @@ public struct RawFunctionDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndFuncKeyword: RawUnexpectedNodesSyntax? = nil, @@ -9248,7 +9248,7 @@ public struct RawFunctionDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .functionDecl, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndFuncKeyword?.raw @@ -9272,8 +9272,8 @@ public struct RawFunctionDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -9570,7 +9570,7 @@ public struct RawFunctionParameterSyntax: RawSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndFirstName: RawUnexpectedNodesSyntax? = nil, @@ -9594,7 +9594,7 @@ public struct RawFunctionParameterSyntax: RawSyntaxNodeProtocol { kind: .functionParameter, uninitializedCount: 19, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndFirstName?.raw @@ -9620,8 +9620,8 @@ public struct RawFunctionParameterSyntax: RawSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -10258,7 +10258,7 @@ public struct RawGenericParameterSyntax: RawSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndEachKeyword: RawUnexpectedNodesSyntax? = nil, eachKeyword: RawTokenSyntax?, _ unexpectedBetweenEachKeywordAndName: RawUnexpectedNodesSyntax? = nil, @@ -10276,7 +10276,7 @@ public struct RawGenericParameterSyntax: RawSyntaxNodeProtocol { kind: .genericParameter, uninitializedCount: 13, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndEachKeyword?.raw layout[3] = eachKeyword?.raw layout[4] = unexpectedBetweenEachKeywordAndName?.raw @@ -10296,8 +10296,8 @@ public struct RawGenericParameterSyntax: RawSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndEachKeyword: RawUnexpectedNodesSyntax? { @@ -11436,7 +11436,7 @@ public struct RawImportDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndImportKeyword: RawUnexpectedNodesSyntax? = nil, @@ -11452,7 +11452,7 @@ public struct RawImportDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .importDecl, uninitializedCount: 11, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndImportKeyword?.raw @@ -11470,8 +11470,8 @@ public struct RawImportDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -12074,7 +12074,7 @@ public struct RawInitializerDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndInitKeyword: RawUnexpectedNodesSyntax? = nil, @@ -12096,7 +12096,7 @@ public struct RawInitializerDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .initializerDecl, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndInitKeyword?.raw @@ -12120,8 +12120,8 @@ public struct RawInitializerDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -13337,7 +13337,7 @@ public struct RawMacroDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndMacroKeyword: RawUnexpectedNodesSyntax? = nil, @@ -13359,7 +13359,7 @@ public struct RawMacroDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .macroDecl, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndMacroKeyword?.raw @@ -13383,8 +13383,8 @@ public struct RawMacroDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -13479,7 +13479,7 @@ public struct RawMacroExpansionDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndPound: RawUnexpectedNodesSyntax? = nil, @@ -13505,7 +13505,7 @@ public struct RawMacroExpansionDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .macroExpansionDecl, uninitializedCount: 21, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndPound?.raw @@ -13533,8 +13533,8 @@ public struct RawMacroExpansionDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -14341,7 +14341,7 @@ public struct RawMissingDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndPlaceholder: RawUnexpectedNodesSyntax? = nil, @@ -14353,7 +14353,7 @@ public struct RawMissingDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .missingDecl, uninitializedCount: 7, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndPlaceholder?.raw @@ -14367,8 +14367,8 @@ public struct RawMissingDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -17029,7 +17029,7 @@ public struct RawPrecedenceGroupDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndPrecedencegroupKeyword: RawUnexpectedNodesSyntax? = nil, @@ -17049,7 +17049,7 @@ public struct RawPrecedenceGroupDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .precedenceGroupDecl, uninitializedCount: 15, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndPrecedencegroupKeyword?.raw @@ -17071,8 +17071,8 @@ public struct RawPrecedenceGroupDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -17633,7 +17633,7 @@ public struct RawProtocolDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndProtocolKeyword: RawUnexpectedNodesSyntax? = nil, @@ -17655,7 +17655,7 @@ public struct RawProtocolDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .protocolDecl, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndProtocolKeyword?.raw @@ -17679,8 +17679,8 @@ public struct RawProtocolDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -19174,7 +19174,7 @@ public struct RawStructDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndStructKeyword: RawUnexpectedNodesSyntax? = nil, @@ -19196,7 +19196,7 @@ public struct RawStructDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .structDecl, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndStructKeyword?.raw @@ -19220,8 +19220,8 @@ public struct RawStructDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -19434,7 +19434,7 @@ public struct RawSubscriptDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndSubscriptKeyword: RawUnexpectedNodesSyntax? = nil, @@ -19456,7 +19456,7 @@ public struct RawSubscriptDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .subscriptDecl, uninitializedCount: 17, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndSubscriptKeyword?.raw @@ -19480,8 +19480,8 @@ public struct RawSubscriptDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -21114,7 +21114,7 @@ public struct RawTypeAliasDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndTypealiasKeyword: RawUnexpectedNodesSyntax? = nil, @@ -21134,7 +21134,7 @@ public struct RawTypeAliasDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .typeAliasDecl, uninitializedCount: 15, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndTypealiasKeyword?.raw @@ -21156,8 +21156,8 @@ public struct RawTypeAliasDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { @@ -22045,7 +22045,7 @@ public struct RawVariableDeclSyntax: RawDeclSyntaxNodeProtocol { public init( _ unexpectedBeforeAttributes: RawUnexpectedNodesSyntax? = nil, - attributes: RawAttributeListSyntax?, + attributes: RawAttributeListSyntax, _ unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? = nil, modifiers: RawDeclModifierListSyntax, _ unexpectedBetweenModifiersAndBindingSpecifier: RawUnexpectedNodesSyntax? = nil, @@ -22059,7 +22059,7 @@ public struct RawVariableDeclSyntax: RawDeclSyntaxNodeProtocol { kind: .variableDecl, uninitializedCount: 9, arena: arena) { layout in layout.initialize(repeating: nil) layout[0] = unexpectedBeforeAttributes?.raw - layout[1] = attributes?.raw + layout[1] = attributes.raw layout[2] = unexpectedBetweenAttributesAndModifiers?.raw layout[3] = modifiers.raw layout[4] = unexpectedBetweenModifiersAndBindingSpecifier?.raw @@ -22075,8 +22075,8 @@ public struct RawVariableDeclSyntax: RawDeclSyntaxNodeProtocol { layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var attributes: RawAttributeListSyntax? { - layoutView.children[1].map(RawAttributeListSyntax.init(raw:)) + public var attributes: RawAttributeListSyntax { + layoutView.children[1].map(RawAttributeListSyntax.init(raw:))! } public var unexpectedBetweenAttributesAndModifiers: RawUnexpectedNodesSyntax? { diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift index 2dc1bad71ad..d5dce636059 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift @@ -222,7 +222,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .accessorDecl: assert(layout.count == 13) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierSyntax?.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -267,7 +267,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .actorDecl: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -338,7 +338,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .associatedTypeDecl: assert(layout.count == 15) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -385,7 +385,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { .keyword("consuming") ])) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawAttributeListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTypeSyntax.self)) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -521,7 +521,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .classDecl: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -606,7 +606,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .closureParameter: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -636,7 +636,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .closureSignature: assert(layout.count == 13) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawClosureCaptureClauseSyntax?.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -851,7 +851,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .deinitializerDecl: assert(layout.count == 11) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1024,7 +1024,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .editorPlaceholderDecl: assert(layout.count == 7) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1042,7 +1042,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .enumCaseDecl: assert(layout.count == 9) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1098,7 +1098,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .enumDecl: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1153,7 +1153,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .extensionDecl: assert(layout.count == 15) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1225,7 +1225,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .functionDecl: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1269,7 +1269,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .functionParameter: assert(layout.count == 19) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1347,7 +1347,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .genericParameter: assert(layout.count == 13) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawTokenSyntax?.self, tokenChoices: [.keyword("each")])) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1468,7 +1468,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .importDecl: assert(layout.count == 11) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1548,7 +1548,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .initializerDecl: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1700,7 +1700,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .macroDecl: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1719,7 +1719,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .macroExpansionDecl: assert(layout.count == 21) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -1821,7 +1821,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .missingDecl: assert(layout.count == 7) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -2093,7 +2093,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .precedenceGroupDecl: assert(layout.count == 15) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -2157,7 +2157,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .protocolDecl: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -2319,7 +2319,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .structDecl: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -2353,7 +2353,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .subscriptDecl: assert(layout.count == 17) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -2534,7 +2534,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .typeAliasDecl: assert(layout.count == 15) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) @@ -2627,7 +2627,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { case .variableDecl: assert(layout.count == 9) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax?.self)) + assertNoError(kind, 1, verify(layout[1], as: RawAttributeListSyntax.self)) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawDeclModifierListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift index c656e04ccf3..6813ba020f1 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift @@ -51,7 +51,7 @@ public struct AccessorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifier: UnexpectedNodesSyntax? = nil, modifier: DeclModifierSyntax? = nil, _ unexpectedBetweenModifierAndAccessorSpecifier: UnexpectedNodesSyntax? = nil, @@ -85,7 +85,7 @@ public struct AccessorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifier?.raw, modifier?.raw, unexpectedBetweenModifierAndAccessorSpecifier?.raw, @@ -120,12 +120,12 @@ public struct AccessorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = AccessorDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = AccessorDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -312,7 +312,7 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndActorKeyword: UnexpectedNodesSyntax? = nil, @@ -354,7 +354,7 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndActorKeyword?.raw, @@ -393,12 +393,12 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = ActorDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = ActorDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -683,7 +683,7 @@ public struct AssociatedTypeDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndAssociatedtypeKeyword: UnexpectedNodesSyntax? = nil, @@ -721,7 +721,7 @@ public struct AssociatedTypeDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndAssociatedtypeKeyword?.raw, @@ -759,12 +759,12 @@ public struct AssociatedTypeDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Attributes attached to the associated type declaration. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = AssociatedTypeDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = AssociatedTypeDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -1033,7 +1033,7 @@ public struct ClassDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndClassKeyword: UnexpectedNodesSyntax? = nil, @@ -1075,7 +1075,7 @@ public struct ClassDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndClassKeyword?.raw, @@ -1115,12 +1115,12 @@ public struct ClassDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Attributes attached to the class declaration, such as an `@available` attribute. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = ClassDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = ClassDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -1388,7 +1388,7 @@ public struct DeinitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndDeinitKeyword: UnexpectedNodesSyntax? = nil, @@ -1418,7 +1418,7 @@ public struct DeinitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndDeinitKeyword?.raw, @@ -1452,12 +1452,12 @@ public struct DeinitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Attributes that are attached to the deinitializer. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = DeinitializerDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = DeinitializerDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -1651,7 +1651,7 @@ public struct EditorPlaceholderDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPlaceholder: UnexpectedNodesSyntax? = nil, @@ -1673,7 +1673,7 @@ public struct EditorPlaceholderDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndPlaceholder?.raw, @@ -1703,12 +1703,12 @@ public struct EditorPlaceholderDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// If there were attributes before the editor placeholder, the ``EditorPlaceholderDeclSyntax`` will contain these. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = EditorPlaceholderDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = EditorPlaceholderDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -1863,7 +1863,7 @@ public struct EnumCaseDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndCaseKeyword: UnexpectedNodesSyntax? = nil, @@ -1889,7 +1889,7 @@ public struct EnumCaseDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndCaseKeyword?.raw, @@ -1921,12 +1921,12 @@ public struct EnumCaseDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// The attributes applied to the case declaration. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = EnumCaseDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = EnumCaseDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -2136,7 +2136,7 @@ public struct EnumDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndEnumKeyword: UnexpectedNodesSyntax? = nil, @@ -2178,7 +2178,7 @@ public struct EnumDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndEnumKeyword?.raw, @@ -2218,12 +2218,12 @@ public struct EnumDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// The attributes applied to the enum declaration. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = EnumDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = EnumDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -2481,7 +2481,7 @@ public struct ExtensionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndExtensionKeyword: UnexpectedNodesSyntax? = nil, @@ -2519,7 +2519,7 @@ public struct ExtensionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndExtensionKeyword?.raw, @@ -2556,12 +2556,12 @@ public struct ExtensionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = ExtensionDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = ExtensionDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -2795,7 +2795,7 @@ public struct FunctionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFuncKeyword: UnexpectedNodesSyntax? = nil, @@ -2837,7 +2837,7 @@ public struct FunctionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndFuncKeyword?.raw, @@ -2876,12 +2876,12 @@ public struct FunctionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = FunctionDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = FunctionDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -3299,7 +3299,7 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndImportKeyword: UnexpectedNodesSyntax? = nil, @@ -3329,7 +3329,7 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndImportKeyword?.raw, @@ -3363,12 +3363,12 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Attributes attached to the import declaration, for example `@testable`. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = ImportDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = ImportDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -3610,7 +3610,7 @@ public struct InitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndInitKeyword: UnexpectedNodesSyntax? = nil, @@ -3652,7 +3652,7 @@ public struct InitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndInitKeyword?.raw, @@ -3692,12 +3692,12 @@ public struct InitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Attributes that are attached to the initializer. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = InitializerDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = InitializerDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -3957,7 +3957,7 @@ public struct MacroDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndMacroKeyword: UnexpectedNodesSyntax? = nil, @@ -3999,7 +3999,7 @@ public struct MacroDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndMacroKeyword?.raw, @@ -4038,12 +4038,12 @@ public struct MacroDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = MacroDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = MacroDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -4299,7 +4299,7 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPound: UnexpectedNodesSyntax? = nil, @@ -4349,7 +4349,7 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndPound?.raw, @@ -4392,12 +4392,12 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = MacroExpansionDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = MacroExpansionDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -4741,7 +4741,7 @@ public struct MissingDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPlaceholder: UnexpectedNodesSyntax? = nil, @@ -4763,7 +4763,7 @@ public struct MissingDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndPlaceholder?.raw, @@ -4793,12 +4793,12 @@ public struct MissingDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// If there were standalone attributes without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = MissingDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = MissingDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -5318,7 +5318,7 @@ public struct PrecedenceGroupDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndPrecedencegroupKeyword: UnexpectedNodesSyntax? = nil, @@ -5356,7 +5356,7 @@ public struct PrecedenceGroupDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndPrecedencegroupKeyword?.raw, @@ -5394,12 +5394,12 @@ public struct PrecedenceGroupDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// The attributes applied to the 'precedencegroup' declaration. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = PrecedenceGroupDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = PrecedenceGroupDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -5677,7 +5677,7 @@ public struct ProtocolDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndProtocolKeyword: UnexpectedNodesSyntax? = nil, @@ -5719,7 +5719,7 @@ public struct ProtocolDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndProtocolKeyword?.raw, @@ -5759,12 +5759,12 @@ public struct ProtocolDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Attributes attached to the protocol declaration, such as an `@available` attribute. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = ProtocolDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = ProtocolDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -6088,7 +6088,7 @@ public struct StructDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndStructKeyword: UnexpectedNodesSyntax? = nil, @@ -6130,7 +6130,7 @@ public struct StructDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndStructKeyword?.raw, @@ -6170,12 +6170,12 @@ public struct StructDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } /// Attributes that are attached to the struct declaration. - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = StructDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = StructDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -6435,7 +6435,7 @@ public struct SubscriptDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndSubscriptKeyword: UnexpectedNodesSyntax? = nil, @@ -6477,7 +6477,7 @@ public struct SubscriptDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndSubscriptKeyword?.raw, @@ -6516,12 +6516,12 @@ public struct SubscriptDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = SubscriptDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = SubscriptDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -6775,7 +6775,7 @@ public struct TypeAliasDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndTypealiasKeyword: UnexpectedNodesSyntax? = nil, @@ -6813,7 +6813,7 @@ public struct TypeAliasDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndTypealiasKeyword?.raw, @@ -6850,12 +6850,12 @@ public struct TypeAliasDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = TypeAliasDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = TypeAliasDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -7091,7 +7091,7 @@ public struct VariableDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndBindingSpecifier: UnexpectedNodesSyntax? = nil, @@ -7117,7 +7117,7 @@ public struct VariableDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndBindingSpecifier?.raw, @@ -7148,12 +7148,12 @@ public struct VariableDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = VariableDeclSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = VariableDeclSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift index 340c857ed25..c7a05083f79 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift @@ -3023,7 +3023,7 @@ public struct ClosureParameterSyntax: SyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax? = nil, @@ -3065,7 +3065,7 @@ public struct ClosureParameterSyntax: SyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndFirstName?.raw, @@ -3104,12 +3104,12 @@ public struct ClosureParameterSyntax: SyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = ClosureParameterSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = ClosureParameterSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -3537,7 +3537,7 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndCapture: UnexpectedNodesSyntax? = nil, capture: ClosureCaptureClauseSyntax? = nil, _ unexpectedBetweenCaptureAndParameterClause: UnexpectedNodesSyntax? = nil, @@ -3571,7 +3571,7 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndCapture?.raw, capture?.raw, unexpectedBetweenCaptureAndParameterClause?.raw, @@ -3606,12 +3606,12 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = ClosureSignatureSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = ClosureSignatureSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -8768,7 +8768,7 @@ public struct FunctionParameterSyntax: SyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], _ unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax? = nil, @@ -8814,7 +8814,7 @@ public struct FunctionParameterSyntax: SyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndModifiers?.raw, modifiers.raw, unexpectedBetweenModifiersAndFirstName?.raw, @@ -8855,12 +8855,12 @@ public struct FunctionParameterSyntax: SyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = FunctionParameterSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = FunctionParameterSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } @@ -9827,7 +9827,7 @@ public struct GenericParameterSyntax: SyntaxProtocol, SyntaxHashable { public init( leadingTrivia: Trivia? = nil, _ unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndEachKeyword: UnexpectedNodesSyntax? = nil, eachKeyword: TokenSyntax? = nil, _ unexpectedBetweenEachKeywordAndName: UnexpectedNodesSyntax? = nil, @@ -9861,7 +9861,7 @@ public struct GenericParameterSyntax: SyntaxProtocol, SyntaxHashable { ))) { (arena, _) in let layout: [RawSyntax?] = [ unexpectedBeforeAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndEachKeyword?.raw, eachKeyword?.raw, unexpectedBetweenEachKeywordAndName?.raw, @@ -9896,12 +9896,12 @@ public struct GenericParameterSyntax: SyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 1, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 1, parent: Syntax(self))!) } set(value) { - self = GenericParameterSyntax(data.replacingChild(at: 1, with: value?.data, arena: SyntaxArena())) + self = GenericParameterSyntax(data.replacingChild(at: 1, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift index 3a292272791..5a1710b5a65 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift @@ -196,7 +196,7 @@ public struct AttributedTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { _ unexpectedBeforeSpecifier: UnexpectedNodesSyntax? = nil, specifier: TokenSyntax? = nil, _ unexpectedBetweenSpecifierAndAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], _ unexpectedBetweenAttributesAndBaseType: UnexpectedNodesSyntax? = nil, baseType: some TypeSyntaxProtocol, _ unexpectedAfterBaseType: UnexpectedNodesSyntax? = nil, @@ -218,7 +218,7 @@ public struct AttributedTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { unexpectedBeforeSpecifier?.raw, specifier?.raw, unexpectedBetweenSpecifierAndAttributes?.raw, - attributes?.raw, + attributes.raw, unexpectedBetweenAttributesAndBaseType?.raw, baseType.raw, unexpectedAfterBaseType?.raw @@ -263,12 +263,12 @@ public struct AttributedTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { } } - public var attributes: AttributeListSyntax? { + public var attributes: AttributeListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(AttributeListSyntax.init) + return AttributeListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = AttributedTypeSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = AttributedTypeSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift index 548ee3df72b..6c4c3a302b9 100644 --- a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift +++ b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift @@ -358,7 +358,7 @@ extension VariableDeclSyntax { /// Creates an optionally initialized property. public init( leadingTrivia: Trivia = [], - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], modifiers: DeclModifierListSyntax = [], _ bindingSpecifier: Keyword, name: PatternSyntax, @@ -367,7 +367,7 @@ extension VariableDeclSyntax { ) { self.init( leadingTrivia: leadingTrivia, - attributes: attributes?.with(\.trailingTrivia, .space), + attributes: attributes.with(\.trailingTrivia, .space), modifiers: modifiers, bindingSpecifier: .keyword(bindingSpecifier) ) { diff --git a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift index 1216ef5ebd9..2cffa152a8d 100644 --- a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift +++ b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift @@ -19,7 +19,7 @@ extension AccessorDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifier: UnexpectedNodesSyntax? = nil, modifier: DeclModifierSyntax? = nil, unexpectedBetweenModifierAndAccessorSpecifier: UnexpectedNodesSyntax? = nil, @@ -60,7 +60,7 @@ extension ActorDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndActorKeyword: UnexpectedNodesSyntax? = nil, @@ -161,7 +161,7 @@ extension ClassDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndClassKeyword: UnexpectedNodesSyntax? = nil, @@ -316,7 +316,7 @@ extension DeinitializerDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndDeinitKeyword: UnexpectedNodesSyntax? = nil, @@ -380,7 +380,7 @@ extension EnumCaseDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndCaseKeyword: UnexpectedNodesSyntax? = nil, @@ -411,7 +411,7 @@ extension EnumDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndEnumKeyword: UnexpectedNodesSyntax? = nil, @@ -493,7 +493,7 @@ extension ExtensionDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndExtensionKeyword: UnexpectedNodesSyntax? = nil, @@ -630,7 +630,7 @@ extension FunctionDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndFuncKeyword: UnexpectedNodesSyntax? = nil, @@ -876,7 +876,7 @@ extension InitializerDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndInitKeyword: UnexpectedNodesSyntax? = nil, @@ -952,7 +952,7 @@ extension MacroExpansionDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndPound: UnexpectedNodesSyntax? = nil, @@ -1081,7 +1081,7 @@ extension ProtocolDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndProtocolKeyword: UnexpectedNodesSyntax? = nil, @@ -1201,7 +1201,7 @@ extension StructDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndStructKeyword: UnexpectedNodesSyntax? = nil, @@ -1430,7 +1430,7 @@ extension VariableDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndBindingSpecifier: UnexpectedNodesSyntax? = nil, diff --git a/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift b/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift index 2740925d817..ecaee9bce5c 100644 --- a/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift +++ b/Sources/SwiftSyntaxBuilder/generated/RenamedChildrenBuilderCompatibility.swift @@ -21,7 +21,7 @@ extension AccessorDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifier: UnexpectedNodesSyntax? = nil, modifier: DeclModifierSyntax? = nil, unexpectedBetweenModifierAndAccessorKind: UnexpectedNodesSyntax? = nil, @@ -64,7 +64,7 @@ extension ActorDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndActorKeyword: UnexpectedNodesSyntax? = nil, @@ -142,7 +142,7 @@ extension ClassDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndClassKeyword: UnexpectedNodesSyntax? = nil, @@ -191,7 +191,7 @@ extension EnumDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndEnumKeyword: UnexpectedNodesSyntax? = nil, @@ -375,7 +375,7 @@ extension FunctionDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndFuncKeyword: UnexpectedNodesSyntax? = nil, @@ -596,7 +596,7 @@ extension MacroExpansionDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndPoundToken: UnexpectedNodesSyntax? = nil, @@ -702,7 +702,7 @@ extension ProtocolDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndProtocolKeyword: UnexpectedNodesSyntax? = nil, @@ -776,7 +776,7 @@ extension StructDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndStructKeyword: UnexpectedNodesSyntax? = nil, @@ -961,7 +961,7 @@ extension VariableDeclSyntax { public init( leadingTrivia: Trivia? = nil, unexpectedBeforeAttributes: UnexpectedNodesSyntax? = nil, - attributes: AttributeListSyntax? = nil, + attributes: AttributeListSyntax = [], unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax? = nil, modifiers: DeclModifierListSyntax = [], unexpectedBetweenModifiersAndBindingKeyword: UnexpectedNodesSyntax? = nil, diff --git a/Sources/SwiftSyntaxMacroExpansion/MacroExpansion.swift b/Sources/SwiftSyntaxMacroExpansion/MacroExpansion.swift index 75c18ac09d5..a810d85b476 100644 --- a/Sources/SwiftSyntaxMacroExpansion/MacroExpansion.swift +++ b/Sources/SwiftSyntaxMacroExpansion/MacroExpansion.swift @@ -106,7 +106,7 @@ public func expandFreestandingMacro( if let expansionDecl = node.as(MacroExpansionDeclSyntax.self) { // Strip any indentation from the attributes and modifiers that we are // inheriting. The expanded macro should start at the leftmost column. - let attributes = declMacroDef.propagateFreestandingMacroAttributes ? expansionDecl.attributes?.withIndentationRemoved : nil + let attributes = declMacroDef.propagateFreestandingMacroAttributes ? expansionDecl.attributes.withIndentationRemoved : nil let modifiers = declMacroDef.propagateFreestandingMacroModifiers ? expansionDecl.modifiers.withIndentationRemoved : nil rewritten = rewritten.map { $0.applying(attributes: attributes, modifiers: modifiers) diff --git a/Sources/SwiftSyntaxMacroExpansion/MacroSystem.swift b/Sources/SwiftSyntaxMacroExpansion/MacroSystem.swift index d672494c131..81d6c9cc648 100644 --- a/Sources/SwiftSyntaxMacroExpansion/MacroSystem.swift +++ b/Sources/SwiftSyntaxMacroExpansion/MacroSystem.swift @@ -491,7 +491,7 @@ private class MacroApplication: SyntaxRewriter { if let declSyntax = node.as(DeclSyntax.self), let attributedNode = node.asProtocol(WithAttributesSyntax.self), - !(attributedNode.attributes?.isEmpty ?? true) + !attributedNode.attributes.isEmpty { // Visit the node, disabling the `visitAny` handling. skipVisitAnyHandling.insert(node) @@ -579,9 +579,7 @@ private class MacroApplication: SyntaxRewriter { ) .map { visit($0) } if !newAttributes.isEmpty { - if let existingAttrs = decl.attributes { - newAttributes.insert(contentsOf: existingAttrs, at: 0) - } + newAttributes.insert(contentsOf: decl.attributes, at: 0) item.decl = decl.with(\.attributes, AttributeListSyntax(newAttributes)).cast(DeclSyntax.self) } } @@ -626,13 +624,11 @@ extension MacroApplication { private func macroAttributes( attachedTo decl: DeclSyntax ) -> [(attributeNode: AttributeSyntax, definition: Macro.Type)] { - guard let attributedNode = decl.asProtocol(WithAttributesSyntax.self), - let attributes = attributedNode.attributes - else { + guard let attributedNode = decl.asProtocol(WithAttributesSyntax.self) else { return [] } - return attributes.compactMap { + return attributedNode.attributes.compactMap { guard case let .attribute(attribute) = $0, let attributeName = attribute.attributeName.as(IdentifierTypeSyntax.self)?.name.text, let macro = macroSystem.lookup(attributeName) diff --git a/Tests/SwiftSyntaxMacroExpansionTest/MacroSystemTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/MacroSystemTests.swift index b9613966303..2ad736936b5 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/MacroSystemTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/MacroSystemTests.swift @@ -343,14 +343,12 @@ public struct AddCompletionHandler: PeerMacro { """ // Drop the @addCompletionHandler attribute from the new declaration. - let newAttributeList = AttributeListSyntax( - funcDecl.attributes?.filter { - guard case let .attribute(attribute) = $0 else { - return true - } - return attribute.attributeName.as(IdentifierTypeSyntax.self)?.name == "addCompletionHandler" - } ?? [] - ) + let newAttributeList = funcDecl.attributes.filter { + guard case let .attribute(attribute) = $0 else { + return true + } + return attribute.attributeName.as(IdentifierTypeSyntax.self)?.name == "addCompletionHandler" + } let newFunc = funcDecl diff --git a/Tests/SwiftSyntaxTest/RawSyntaxTests.swift b/Tests/SwiftSyntaxTest/RawSyntaxTests.swift index 7ff430052f8..2bc87ed3c1e 100644 --- a/Tests/SwiftSyntaxTest/RawSyntaxTests.swift +++ b/Tests/SwiftSyntaxTest/RawSyntaxTests.swift @@ -53,7 +53,7 @@ fileprivate func cannedStructDecl(arena: SyntaxArena) -> RawStructDeclSyntax { arena: arena ) return RawStructDeclSyntax( - attributes: nil, + attributes: RawAttributeListSyntax(elements: [], arena: arena), modifiers: RawDeclModifierListSyntax(elements: [], arena: arena), structKeyword: structKW, name: fooID, From b6f45959e3076d3fd270a739ae1890b2249dea97 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 9 Aug 2023 12:32:19 -0700 Subject: [PATCH 5/5] Ensure there are no optional syntax collection in the syntax tree All syntax collections should be non-optional, which makes it easier to work with them. Also, the semantics of what an empty collection vs. a `nil` collection have not been clear. --- .../SyntaxSupport/AvailabilityNodes.swift | 3 +- .../Sources/SyntaxSupport/ExprNodes.swift | 3 +- .../Sources/SyntaxSupport/StmtNodes.swift | 6 ++-- .../ValidateSyntaxNodes.swift | 19 +++++++++++ Sources/SwiftParser/Availability.swift | 2 +- Sources/SwiftParser/Expressions.swift | 2 +- Sources/SwiftParser/Statements.swift | 4 +-- .../ParseDiagnosticsGenerator.swift | 8 ++--- .../generated/raw/RawSyntaxNodes.swift | 32 +++++++++---------- .../generated/raw/RawSyntaxValidation.swift | 8 ++--- .../generated/syntaxNodes/SyntaxNodes.swift | 30 ++++++++--------- .../syntaxNodes/SyntaxStmtNodes.swift | 10 +++--- .../generated/BuildableNodes.swift | 6 ++-- Tests/SwiftParserTest/AvailabilityTests.swift | 3 +- 14 files changed, 75 insertions(+), 61 deletions(-) diff --git a/CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift b/CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift index 96df96c377a..31a139d954d 100644 --- a/CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift @@ -180,8 +180,7 @@ public let AVAILABILITY_NODES: [Node] = [ Child( name: "Components", kind: .collection(kind: .versionComponentList, collectionElementName: "VersionComponent"), - documentation: "Any version components that are not the major version . For example, for `1.2.0`, this will contain `.2.0`", - isOptional: true + documentation: "Any version components that are not the major version . For example, for `1.2.0`, this will contain `.2.0`" ), ] ), diff --git a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift index 3b3743d30ef..8d421ae77c4 100644 --- a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift @@ -354,8 +354,7 @@ public let EXPR_NODES: [Node] = [ ), Child( name: "Items", - kind: .collection(kind: .closureCaptureList, collectionElementName: "Item"), - isOptional: true + kind: .collection(kind: .closureCaptureList, collectionElementName: "Item") ), Child( name: "RightSquare", diff --git a/CodeGeneration/Sources/SyntaxSupport/StmtNodes.swift b/CodeGeneration/Sources/SyntaxSupport/StmtNodes.swift index 927b06f43ba..0b704c4f7f3 100644 --- a/CodeGeneration/Sources/SyntaxSupport/StmtNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/StmtNodes.swift @@ -86,8 +86,7 @@ public let STMT_NODES: [Node] = [ ), Child( name: "CatchItems", - kind: .collection(kind: .catchItemList, collectionElementName: "CatchItem"), - isOptional: true + kind: .collection(kind: .catchItemList, collectionElementName: "CatchItem", defaultsToEmpty: true) ), Child( name: "Body", @@ -240,8 +239,7 @@ public let STMT_NODES: [Node] = [ ), Child( name: "CatchClauses", - kind: .collection(kind: .catchClauseList, collectionElementName: "CatchClause"), - isOptional: true + kind: .collection(kind: .catchClauseList, collectionElementName: "CatchClause", defaultsToEmpty: true) ), ] ), diff --git a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift index 9852ce51fb9..bac83f2773c 100644 --- a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift +++ b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift @@ -760,4 +760,23 @@ class ValidateSyntaxNodes: XCTestCase { assertFailuresMatchXFails(failures, expectedFailures: []) } + + func testNoOptionalSyntaxCollections() { + var failures: [ValidationFailure] = [] + + for node in SYNTAX_NODES.compactMap(\.layoutNode) { + for child in node.children { + if case .collection = child.kind, child.isOptional, !child.isUnexpectedNodes { + failures.append( + ValidationFailure( + node: node.kind, + message: "child '\(child.name)' is an optional syntax collection. All syntax collections should be non-optional." + ) + ) + } + } + } + + assertFailuresMatchXFails(failures, expectedFailures: []) + } } diff --git a/Sources/SwiftParser/Availability.swift b/Sources/SwiftParser/Availability.swift index 4dc2696359c..ac144c45187 100644 --- a/Sources/SwiftParser/Availability.swift +++ b/Sources/SwiftParser/Availability.swift @@ -298,7 +298,7 @@ extension Parser { let unexpectedAfterComponents = self.parseUnexpectedVersionTokens() return RawVersionTupleSyntax( major: major, - components: nil, + components: RawVersionComponentListSyntax(elements: [], arena: self.arena), unexpectedAfterComponents, arena: self.arena ) diff --git a/Sources/SwiftParser/Expressions.swift b/Sources/SwiftParser/Expressions.swift index a7abea4af32..bc43255679c 100644 --- a/Sources/SwiftParser/Expressions.swift +++ b/Sources/SwiftParser/Expressions.swift @@ -1733,7 +1733,7 @@ extension Parser { captures = RawClosureCaptureClauseSyntax( leftSquare: lsquare, - items: elements.isEmpty ? nil : RawClosureCaptureListSyntax(elements: elements, arena: self.arena), + items: RawClosureCaptureListSyntax(elements: elements, arena: self.arena), RawUnexpectedNodesSyntax(unexpectedNodes, arena: self.arena), rightSquare: rsquare, arena: self.arena diff --git a/Sources/SwiftParser/Statements.swift b/Sources/SwiftParser/Statements.swift index 7288500d37f..879c3b72303 100644 --- a/Sources/SwiftParser/Statements.swift +++ b/Sources/SwiftParser/Statements.swift @@ -384,7 +384,7 @@ extension Parser { unexpectedBeforeDoKeyword, doKeyword: doKeyword, body: body, - catchClauses: elements.isEmpty ? nil : RawCatchClauseListSyntax(elements: elements, arena: self.arena), + catchClauses: RawCatchClauseListSyntax(elements: elements, arena: self.arena), arena: self.arena ) } @@ -416,7 +416,7 @@ extension Parser { return RawCatchClauseSyntax( unexpectedBeforeCatchKeyword, catchKeyword: catchKeyword, - catchItems: catchItems.isEmpty ? nil : RawCatchItemListSyntax(elements: catchItems, arena: self.arena), + catchItems: RawCatchItemListSyntax(elements: catchItems, arena: self.arena), body: body, arena: self.arena ) diff --git a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift index a7bd8b4ce84..a3bb0538744 100644 --- a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift +++ b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift @@ -1986,19 +1986,17 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor { } if let unexpectedAfterComponents = node.unexpectedAfterComponents { - if let components = node.components, - unexpectedAfterComponents.allSatisfy({ $0.is(VersionComponentSyntax.self) }) - { + if unexpectedAfterComponents.allSatisfy({ $0.is(VersionComponentSyntax.self) }) { addDiagnostic( unexpectedAfterComponents, - TrailingVersionAreIgnored(major: node.major, components: components), + TrailingVersionAreIgnored(major: node.major, components: node.components), handledNodes: [unexpectedAfterComponents.id] ) } else { addDiagnostic( unexpectedAfterComponents, CannotParseVersionTuple(versionTuple: unexpectedAfterComponents), - handledNodes: [node.major.id, node.components?.id, unexpectedAfterComponents.id].compactMap { $0 } + handledNodes: [node.major.id, node.components.id, unexpectedAfterComponents.id] ) } } diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift index ef7fea54d2f..7dae59c883e 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodes.swift @@ -2715,7 +2715,7 @@ public struct RawCatchClauseSyntax: RawSyntaxNodeProtocol { _ unexpectedBeforeCatchKeyword: RawUnexpectedNodesSyntax? = nil, catchKeyword: RawTokenSyntax, _ unexpectedBetweenCatchKeywordAndCatchItems: RawUnexpectedNodesSyntax? = nil, - catchItems: RawCatchItemListSyntax?, + catchItems: RawCatchItemListSyntax, _ unexpectedBetweenCatchItemsAndBody: RawUnexpectedNodesSyntax? = nil, body: RawCodeBlockSyntax, _ unexpectedAfterBody: RawUnexpectedNodesSyntax? = nil, @@ -2727,7 +2727,7 @@ public struct RawCatchClauseSyntax: RawSyntaxNodeProtocol { layout[0] = unexpectedBeforeCatchKeyword?.raw layout[1] = catchKeyword.raw layout[2] = unexpectedBetweenCatchKeywordAndCatchItems?.raw - layout[3] = catchItems?.raw + layout[3] = catchItems.raw layout[4] = unexpectedBetweenCatchItemsAndBody?.raw layout[5] = body.raw layout[6] = unexpectedAfterBody?.raw @@ -2747,8 +2747,8 @@ public struct RawCatchClauseSyntax: RawSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var catchItems: RawCatchItemListSyntax? { - layoutView.children[3].map(RawCatchItemListSyntax.init(raw:)) + public var catchItems: RawCatchItemListSyntax { + layoutView.children[3].map(RawCatchItemListSyntax.init(raw:))! } public var unexpectedBetweenCatchItemsAndBody: RawUnexpectedNodesSyntax? { @@ -3129,7 +3129,7 @@ public struct RawClosureCaptureClauseSyntax: RawSyntaxNodeProtocol { _ unexpectedBeforeLeftSquare: RawUnexpectedNodesSyntax? = nil, leftSquare: RawTokenSyntax, _ unexpectedBetweenLeftSquareAndItems: RawUnexpectedNodesSyntax? = nil, - items: RawClosureCaptureListSyntax?, + items: RawClosureCaptureListSyntax, _ unexpectedBetweenItemsAndRightSquare: RawUnexpectedNodesSyntax? = nil, rightSquare: RawTokenSyntax, _ unexpectedAfterRightSquare: RawUnexpectedNodesSyntax? = nil, @@ -3141,7 +3141,7 @@ public struct RawClosureCaptureClauseSyntax: RawSyntaxNodeProtocol { layout[0] = unexpectedBeforeLeftSquare?.raw layout[1] = leftSquare.raw layout[2] = unexpectedBetweenLeftSquareAndItems?.raw - layout[3] = items?.raw + layout[3] = items.raw layout[4] = unexpectedBetweenItemsAndRightSquare?.raw layout[5] = rightSquare.raw layout[6] = unexpectedAfterRightSquare?.raw @@ -3161,8 +3161,8 @@ public struct RawClosureCaptureClauseSyntax: RawSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var items: RawClosureCaptureListSyntax? { - layoutView.children[3].map(RawClosureCaptureListSyntax.init(raw:)) + public var items: RawClosureCaptureListSyntax { + layoutView.children[3].map(RawClosureCaptureListSyntax.init(raw:))! } public var unexpectedBetweenItemsAndRightSquare: RawUnexpectedNodesSyntax? { @@ -7067,7 +7067,7 @@ public struct RawDoStmtSyntax: RawStmtSyntaxNodeProtocol { _ unexpectedBetweenDoKeywordAndBody: RawUnexpectedNodesSyntax? = nil, body: RawCodeBlockSyntax, _ unexpectedBetweenBodyAndCatchClauses: RawUnexpectedNodesSyntax? = nil, - catchClauses: RawCatchClauseListSyntax?, + catchClauses: RawCatchClauseListSyntax, _ unexpectedAfterCatchClauses: RawUnexpectedNodesSyntax? = nil, arena: __shared SyntaxArena ) { @@ -7079,7 +7079,7 @@ public struct RawDoStmtSyntax: RawStmtSyntaxNodeProtocol { layout[2] = unexpectedBetweenDoKeywordAndBody?.raw layout[3] = body.raw layout[4] = unexpectedBetweenBodyAndCatchClauses?.raw - layout[5] = catchClauses?.raw + layout[5] = catchClauses.raw layout[6] = unexpectedAfterCatchClauses?.raw } self.init(unchecked: raw) @@ -7105,8 +7105,8 @@ public struct RawDoStmtSyntax: RawStmtSyntaxNodeProtocol { layoutView.children[4].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var catchClauses: RawCatchClauseListSyntax? { - layoutView.children[5].map(RawCatchClauseListSyntax.init(raw:)) + public var catchClauses: RawCatchClauseListSyntax { + layoutView.children[5].map(RawCatchClauseListSyntax.init(raw:))! } public var unexpectedAfterCatchClauses: RawUnexpectedNodesSyntax? { @@ -22261,7 +22261,7 @@ public struct RawVersionTupleSyntax: RawSyntaxNodeProtocol { _ unexpectedBeforeMajor: RawUnexpectedNodesSyntax? = nil, major: RawTokenSyntax, _ unexpectedBetweenMajorAndComponents: RawUnexpectedNodesSyntax? = nil, - components: RawVersionComponentListSyntax?, + components: RawVersionComponentListSyntax, _ unexpectedAfterComponents: RawUnexpectedNodesSyntax? = nil, arena: __shared SyntaxArena ) { @@ -22271,7 +22271,7 @@ public struct RawVersionTupleSyntax: RawSyntaxNodeProtocol { layout[0] = unexpectedBeforeMajor?.raw layout[1] = major.raw layout[2] = unexpectedBetweenMajorAndComponents?.raw - layout[3] = components?.raw + layout[3] = components.raw layout[4] = unexpectedAfterComponents?.raw } self.init(unchecked: raw) @@ -22289,8 +22289,8 @@ public struct RawVersionTupleSyntax: RawSyntaxNodeProtocol { layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var components: RawVersionComponentListSyntax? { - layoutView.children[3].map(RawVersionComponentListSyntax.init(raw:)) + public var components: RawVersionComponentListSyntax { + layoutView.children[3].map(RawVersionComponentListSyntax.init(raw:))! } public var unexpectedAfterComponents: RawUnexpectedNodesSyntax? { diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift index d5dce636059..8421ccb77bf 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift @@ -501,7 +501,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawTokenSyntax.self, tokenChoices: [.keyword("catch")])) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawCatchItemListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawCatchItemListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawCodeBlockSyntax.self)) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -547,7 +547,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.leftSquare)])) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawClosureCaptureListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawClosureCaptureListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.rightSquare)])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) @@ -994,7 +994,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawCodeBlockSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 5, verify(layout[5], as: RawCatchClauseListSyntax?.self)) + assertNoError(kind, 5, verify(layout[5], as: RawCatchClauseListSyntax.self)) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) case .documentationAttributeArgumentList: for (index, element) in layout.enumerated() { @@ -2651,7 +2651,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 1, verify(layout[1], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.integerLiteral)])) assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 3, verify(layout[3], as: RawVersionComponentListSyntax?.self)) + assertNoError(kind, 3, verify(layout[3], as: RawVersionComponentListSyntax.self)) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) case .whereClause: assert(layout.count == 5) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift index c7a05083f79..0a6ecd17e82 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift @@ -1925,7 +1925,7 @@ public struct CatchClauseSyntax: SyntaxProtocol, SyntaxHashable { _ unexpectedBeforeCatchKeyword: UnexpectedNodesSyntax? = nil, catchKeyword: TokenSyntax = .keyword(.catch), _ unexpectedBetweenCatchKeywordAndCatchItems: UnexpectedNodesSyntax? = nil, - catchItems: CatchItemListSyntax? = nil, + catchItems: CatchItemListSyntax = [], _ unexpectedBetweenCatchItemsAndBody: UnexpectedNodesSyntax? = nil, body: CodeBlockSyntax, _ unexpectedAfterBody: UnexpectedNodesSyntax? = nil, @@ -1947,7 +1947,7 @@ public struct CatchClauseSyntax: SyntaxProtocol, SyntaxHashable { unexpectedBeforeCatchKeyword?.raw, catchKeyword.raw, unexpectedBetweenCatchKeywordAndCatchItems?.raw, - catchItems?.raw, + catchItems.raw, unexpectedBetweenCatchItemsAndBody?.raw, body.raw, unexpectedAfterBody?.raw @@ -1992,12 +1992,12 @@ public struct CatchClauseSyntax: SyntaxProtocol, SyntaxHashable { } } - public var catchItems: CatchItemListSyntax? { + public var catchItems: CatchItemListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(CatchItemListSyntax.init) + return CatchItemListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = CatchClauseSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = CatchClauseSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -2259,7 +2259,7 @@ public struct ClosureCaptureClauseSyntax: SyntaxProtocol, SyntaxHashable { _ unexpectedBeforeLeftSquare: UnexpectedNodesSyntax? = nil, leftSquare: TokenSyntax = .leftSquareToken(), _ unexpectedBetweenLeftSquareAndItems: UnexpectedNodesSyntax? = nil, - items: ClosureCaptureListSyntax? = nil, + items: ClosureCaptureListSyntax, _ unexpectedBetweenItemsAndRightSquare: UnexpectedNodesSyntax? = nil, rightSquare: TokenSyntax = .rightSquareToken(), _ unexpectedAfterRightSquare: UnexpectedNodesSyntax? = nil, @@ -2281,7 +2281,7 @@ public struct ClosureCaptureClauseSyntax: SyntaxProtocol, SyntaxHashable { unexpectedBeforeLeftSquare?.raw, leftSquare.raw, unexpectedBetweenLeftSquareAndItems?.raw, - items?.raw, + items.raw, unexpectedBetweenItemsAndRightSquare?.raw, rightSquare.raw, unexpectedAfterRightSquare?.raw @@ -2326,12 +2326,12 @@ public struct ClosureCaptureClauseSyntax: SyntaxProtocol, SyntaxHashable { } } - public var items: ClosureCaptureListSyntax? { + public var items: ClosureCaptureListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(ClosureCaptureListSyntax.init) + return ClosureCaptureListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = ClosureCaptureClauseSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = ClosureCaptureClauseSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } @@ -19003,7 +19003,7 @@ public struct VersionTupleSyntax: SyntaxProtocol, SyntaxHashable { _ unexpectedBeforeMajor: UnexpectedNodesSyntax? = nil, major: TokenSyntax, _ unexpectedBetweenMajorAndComponents: UnexpectedNodesSyntax? = nil, - components: VersionComponentListSyntax? = nil, + components: VersionComponentListSyntax, _ unexpectedAfterComponents: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -19021,7 +19021,7 @@ public struct VersionTupleSyntax: SyntaxProtocol, SyntaxHashable { unexpectedBeforeMajor?.raw, major.raw, unexpectedBetweenMajorAndComponents?.raw, - components?.raw, + components.raw, unexpectedAfterComponents?.raw ] let raw = RawSyntax.makeLayout( @@ -19066,12 +19066,12 @@ public struct VersionTupleSyntax: SyntaxProtocol, SyntaxHashable { } /// Any version components that are not the major version . For example, for `1.2.0`, this will contain `.2.0` - public var components: VersionComponentListSyntax? { + public var components: VersionComponentListSyntax { get { - return data.child(at: 3, parent: Syntax(self)).map(VersionComponentListSyntax.init) + return VersionComponentListSyntax(data.child(at: 3, parent: Syntax(self))!) } set(value) { - self = VersionTupleSyntax(data.replacingChild(at: 3, with: value?.data, arena: SyntaxArena())) + self = VersionTupleSyntax(data.replacingChild(at: 3, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift index 48729900771..642c7bb8c79 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift @@ -540,7 +540,7 @@ public struct DoStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { _ unexpectedBetweenDoKeywordAndBody: UnexpectedNodesSyntax? = nil, body: CodeBlockSyntax, _ unexpectedBetweenBodyAndCatchClauses: UnexpectedNodesSyntax? = nil, - catchClauses: CatchClauseListSyntax? = nil, + catchClauses: CatchClauseListSyntax = [], _ unexpectedAfterCatchClauses: UnexpectedNodesSyntax? = nil, trailingTrivia: Trivia? = nil @@ -562,7 +562,7 @@ public struct DoStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { unexpectedBetweenDoKeywordAndBody?.raw, body.raw, unexpectedBetweenBodyAndCatchClauses?.raw, - catchClauses?.raw, + catchClauses.raw, unexpectedAfterCatchClauses?.raw ] let raw = RawSyntax.makeLayout( @@ -623,12 +623,12 @@ public struct DoStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { } } - public var catchClauses: CatchClauseListSyntax? { + public var catchClauses: CatchClauseListSyntax { get { - return data.child(at: 5, parent: Syntax(self)).map(CatchClauseListSyntax.init) + return CatchClauseListSyntax(data.child(at: 5, parent: Syntax(self))!) } set(value) { - self = DoStmtSyntax(data.replacingChild(at: 5, with: value?.data, arena: SyntaxArena())) + self = DoStmtSyntax(data.replacingChild(at: 5, with: value.data, arena: SyntaxArena())) } } diff --git a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift index 2cffa152a8d..2064d31c349 100644 --- a/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift +++ b/Sources/SwiftSyntaxBuilder/generated/BuildableNodes.swift @@ -136,7 +136,7 @@ extension CatchClauseSyntax { unexpectedBeforeCatchKeyword: UnexpectedNodesSyntax? = nil, catchKeyword: TokenSyntax = .keyword(.catch), unexpectedBetweenCatchKeywordAndCatchItems: UnexpectedNodesSyntax? = nil, - catchItems: CatchItemListSyntax? = nil, + catchItems: CatchItemListSyntax = [], unexpectedBetweenCatchItemsAndBody: UnexpectedNodesSyntax? = nil, unexpectedAfterBody: UnexpectedNodesSyntax? = nil, @CodeBlockItemListBuilder bodyBuilder: () throws -> CodeBlockItemListSyntax, @@ -213,7 +213,7 @@ extension ClosureCaptureClauseSyntax { unexpectedBetweenItemsAndRightSquare: UnexpectedNodesSyntax? = nil, rightSquare: TokenSyntax = .rightSquareToken(), unexpectedAfterRightSquare: UnexpectedNodesSyntax? = nil, - @ClosureCaptureListBuilder itemsBuilder: () throws -> ClosureCaptureListSyntax?, + @ClosureCaptureListBuilder itemsBuilder: () throws -> ClosureCaptureListSyntax, trailingTrivia: Trivia? = nil ) rethrows { try self.init( @@ -356,7 +356,7 @@ extension DoStmtSyntax { doKeyword: TokenSyntax = .keyword(.do), unexpectedBetweenDoKeywordAndBody: UnexpectedNodesSyntax? = nil, unexpectedBetweenBodyAndCatchClauses: UnexpectedNodesSyntax? = nil, - catchClauses: CatchClauseListSyntax? = nil, + catchClauses: CatchClauseListSyntax = [], unexpectedAfterCatchClauses: UnexpectedNodesSyntax? = nil, @CodeBlockItemListBuilder bodyBuilder: () throws -> CodeBlockItemListSyntax, trailingTrivia: Trivia? = nil diff --git a/Tests/SwiftParserTest/AvailabilityTests.swift b/Tests/SwiftParserTest/AvailabilityTests.swift index 9dc2904bd02..506699259fb 100644 --- a/Tests/SwiftParserTest/AvailabilityTests.swift +++ b/Tests/SwiftParserTest/AvailabilityTests.swift @@ -107,7 +107,8 @@ final class AvailabilityTests: ParserTestCase { func test() {} """, substructure: VersionTupleSyntax( - major: .integerLiteral("10") + major: .integerLiteral("10"), + components: [] ) )