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

[CodeGeneration] Stop generating add{ElementName}(_:) methods #2973

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 4 additions & 12 deletions CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,7 @@ public let ATTRIBUTE_NODES: [Node] = [
),
Child(
name: "availabilityArguments",
kind: .collection(
kind: .availabilityArgumentList,
collectionElementName: "AvailabilityArgument",
deprecatedCollectionElementName: "Availability"
)
kind: .collection(kind: .availabilityArgumentList)
),
Child(
name: "semicolon",
Expand Down Expand Up @@ -257,11 +253,7 @@ public let ATTRIBUTE_NODES: [Node] = [
),
Child(
name: "platforms",
kind: .collection(
kind: .platformVersionItemList,
collectionElementName: "Platform",
deprecatedCollectionElementName: "Availability"
),
kind: .collection(kind: .platformVersionItemList),
documentation: "The list of OS versions in which the declaration became ABI stable."
),
],
Expand Down Expand Up @@ -500,7 +492,7 @@ public let ATTRIBUTE_NODES: [Node] = [
),
Child(
name: "arguments",
kind: .collection(kind: .differentiabilityArgumentList, collectionElementName: "Argument"),
kind: .collection(kind: .differentiabilityArgumentList),
documentation: "The parameters for differentiation."
),
Child(
Expand Down Expand Up @@ -827,7 +819,7 @@ public let ATTRIBUTE_NODES: [Node] = [
),
Child(
name: "platforms",
kind: .collection(kind: .platformVersionItemList, collectionElementName: "Platform")
kind: .collection(kind: .platformVersionItemList)
),
]
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public let AVAILABILITY_NODES: [Node] = [
),
Child(
name: "components",
kind: .collection(kind: .versionComponentList, collectionElementName: "VersionComponent"),
kind: .collection(kind: .versionComponentList),
documentation:
"Any version components that are not the major version . For example, for `1.2.0`, this will contain `.2.0`."
),
Expand Down
15 changes: 5 additions & 10 deletions CodeGeneration/Sources/SyntaxSupport/Child.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ public enum ChildKind {
case nodeChoices(choices: [Child], childHistory: Child.History = [])
// FIXME: We don't appear to have ever generated compatibility layers for children of node choices!
/// The child is a collection of `kind`.
case collection(
kind: SyntaxNodeKind,
collectionElementName: String? = nil,
defaultsToEmpty: Bool = false,
deprecatedCollectionElementName: String? = nil
)
case collection(kind: SyntaxNodeKind, defaultsToEmpty: Bool = false)
/// 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 @@ -132,7 +127,7 @@ public class Child: NodeChoiceConvertible {
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 @@ -268,7 +263,7 @@ public class Child: NodeChoiceConvertible {
/// 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 @@ -283,7 +278,7 @@ public class Child: NodeChoiceConvertible {
return choices.isEmpty
case .node(let kind):
return kind.isBase
case .collection(kind: let kind, _, _, _):
case .collection(kind: let kind, _):
return kind.isBase
case .token:
return false
Expand Down Expand Up @@ -354,7 +349,7 @@ public class Child: NodeChoiceConvertible {

self.init(
name: name,
kind: .collection(kind: .unexpectedNodes, collectionElementName: name.withFirstCharacterUppercased),
kind: .collection(kind: .unexpectedNodes),
experimentalFeature: earlier?.experimentalFeature ?? later?.experimentalFeature,
nameForDiagnostics: nil,
documentation: nil,
Expand Down
6 changes: 3 additions & 3 deletions CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public let COMMON_NODES: [Node] = [
),
Child(
name: "statements",
kind: .collection(kind: .codeBlockItemList, collectionElementName: "Statement"),
kind: .collection(kind: .codeBlockItemList),
nameForDiagnostics: "statements"
),
Child(
Expand Down Expand Up @@ -201,13 +201,13 @@ public let COMMON_NODES: [Node] = [
children: [
Child(
name: "attributes",
kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true),
kind: .collection(kind: .attributeList, 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", defaultsToEmpty: true),
kind: .collection(kind: .declModifierList, defaultsToEmpty: true),
documentation:
"If there were standalone modifiers without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these."
),
Expand Down
5 changes: 1 addition & 4 deletions CodeGeneration/Sources/SyntaxSupport/CompilerNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ public let COMPILER_NODES: [Node] = [
children: [
Child(
name: "attributes",
kind: .collection(
kind: .attributeList,
collectionElementName: "Attribute"
)
kind: .collection(kind: .attributeList)
),
Child(
name: "modifiers",
Expand Down
Loading