Skip to content

Commit 91b4481

Browse files
authored
Merge pull request #2043 from ahoppen/ahoppen/no-optional-collections
Ensure there are no optional syntax collection in the syntax tree
2 parents ffe4c36 + b6f4595 commit 91b4481

File tree

63 files changed

+1058
-1387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1058
-1387
lines changed

CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ public let AVAILABILITY_NODES: [Node] = [
180180
Child(
181181
name: "Components",
182182
kind: .collection(kind: .versionComponentList, collectionElementName: "VersionComponent"),
183-
documentation: "Any version components that are not the major version . For example, for `1.2.0`, this will contain `.2.0`",
184-
isOptional: true
183+
documentation: "Any version components that are not the major version . For example, for `1.2.0`, this will contain `.2.0`"
185184
),
186185
]
187186
),

CodeGeneration/Sources/SyntaxSupport/Child.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public enum ChildKind {
3232
/// The child always contains a node that matches one of the `choices`.
3333
case nodeChoices(choices: [Child])
3434
/// The child is a collection of `kind`.
35-
case collection(kind: SyntaxNodeKind, collectionElementName: String, deprecatedCollectionElementName: String? = nil)
35+
case collection(kind: SyntaxNodeKind, collectionElementName: String, defaultsToEmpty: Bool = false, deprecatedCollectionElementName: String? = nil)
3636
/// The child is a token that matches one of the given `choices`.
3737
/// If `requiresLeadingSpace` or `requiresTrailingSpace` is not `nil`, it
3838
/// overrides the default leading/trailing space behavior of the token.
@@ -91,7 +91,7 @@ public class Child {
9191
return kind
9292
case .nodeChoices:
9393
return .syntax
94-
case .collection(kind: let kind, _, _):
94+
case .collection(kind: let kind, _, _, _):
9595
return kind
9696
case .token:
9797
return .token
@@ -150,7 +150,7 @@ public class Child {
150150
/// Whether this child has syntax kind `UnexpectedNodes`.
151151
public var isUnexpectedNodes: Bool {
152152
switch kind {
153-
case .collection(kind: .unexpectedNodes, _, _):
153+
case .collection(kind: .unexpectedNodes, _, _, _):
154154
return true
155155
default:
156156
return false
@@ -165,7 +165,7 @@ public class Child {
165165
return choices.isEmpty
166166
case .node(let kind):
167167
return kind.isBase
168-
case .collection(let kind, _, _):
168+
case .collection(kind: let kind, _, _, _):
169169
return kind.isBase
170170
case .token:
171171
return false

CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,13 @@ public let COMMON_NODES: [Node] = [
166166
children: [
167167
Child(
168168
name: "Attributes",
169-
kind: .collection(kind: .attributeList, collectionElementName: "Attribute"),
170-
documentation: "If there were standalone attributes without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these.",
171-
isOptional: true
169+
kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true),
170+
documentation: "If there were standalone attributes without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these."
172171
),
173172
Child(
174173
name: "Modifiers",
175-
kind: .collection(kind: .declModifierList, collectionElementName: "Modifier"),
176-
documentation: "If there were standalone modifiers without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these.",
177-
isOptional: true
174+
kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true),
175+
documentation: "If there were standalone modifiers without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these."
178176
),
179177
Child(
180178
name: "Placeholder",

0 commit comments

Comments
 (0)