Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure there are no optional syntax collection in the syntax tree #2043

Merged
merged 5 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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`"
),
]
),
Expand Down
8 changes: 4 additions & 4 deletions CodeGeneration/Sources/SyntaxSupport/Child.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 4 additions & 6 deletions CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,13 @@ 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",
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",
Expand Down
Loading