Skip to content

Further naming improvements for syntax node children #1896

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

Merged
merged 11 commits into from
Jul 23, 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
11 changes: 7 additions & 4 deletions CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public let ATTRIBUTE_NODES: [Node] = [
isOptional: true
),
Child(
name: "Argument",
name: "Arguments",
deprecatedName: "Argument",
kind: .nodeChoices(choices: [
Child(
name: "ArgumentList",
Expand Down Expand Up @@ -456,7 +457,7 @@ public let ATTRIBUTE_NODES: [Node] = [
kind: .token(choices: [.token(tokenKind: "LeftParenToken")])
),
Child(
name: "DiffParams",
name: "DifferentiabilityParameters",
kind: .collection(kind: .differentiabilityParamList, collectionElementName: "DifferentiabilityParam"),
documentation: "The parameters for differentiation."
),
Expand Down Expand Up @@ -583,7 +584,8 @@ public let ATTRIBUTE_NODES: [Node] = [
kind: .token(choices: [.token(tokenKind: "ColonToken")])
),
Child(
name: "Declname",
name: "DeclName",
deprecatedName: "Declname",
kind: .node(kind: .declName)
),
]
Expand Down Expand Up @@ -863,7 +865,8 @@ public let ATTRIBUTE_NODES: [Node] = [
documentation: "The colon separating the label and the value"
),
Child(
name: "Declname",
name: "DeclName",
deprecatedName: "Declname",
kind: .node(kind: .declName),
nameForDiagnostics: "declaration name",
documentation: "The value for this argument"
Expand Down
94 changes: 59 additions & 35 deletions CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.token(tokenKind: "LeftParenToken")])
),
Child(
name: "PropertyList",
name: "Properties",
deprecatedName: "PropertyList",
kind: .collection(kind: .tupleExprElementList, collectionElementName: "Property"),
nameForDiagnostics: "properties"
),
Expand All @@ -104,7 +105,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.token(tokenKind: "LeftParenToken")])
),
Child(
name: "PropertyList",
name: "Properties",
deprecatedName: "PropertyList",
kind: .collection(kind: .tupleExprElementList, collectionElementName: "Property"),
nameForDiagnostics: "properties"
),
Expand Down Expand Up @@ -240,7 +242,7 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "actor",
traits: [
"DeclGroup",
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithGenericParameters",
"WithModifiers",
Expand All @@ -263,7 +265,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.keyword(text: "actor")])
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")])
),
Child(
Expand Down Expand Up @@ -328,7 +331,7 @@ public let DECL_NODES: [Node] = [
```
""",
traits: [
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithModifiers",
],
Expand All @@ -353,7 +356,8 @@ public let DECL_NODES: [Node] = [
documentation: "The `associatedtype` keyword for this declaration."
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
documentation: "The name of this associated type."
),
Expand Down Expand Up @@ -416,7 +420,7 @@ public let DECL_NODES: [Node] = [
""",
traits: [
"DeclGroup",
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithGenericParameters",
"WithModifiers",
Expand All @@ -442,7 +446,8 @@ public let DECL_NODES: [Node] = [
documentation: "The `class` keyword for this declaration."
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
documentation: "The name of the class."
),
Expand Down Expand Up @@ -676,7 +681,8 @@ public let DECL_NODES: [Node] = [
documentation: "The '(' to open the parameter clause."
),
Child(
name: "ParameterList",
name: "Parameters",
deprecatedName: "ParameterList",
kind: .collection(kind: .enumCaseParameterList, collectionElementName: "Parameter"),
nameForDiagnostics: "parameters",
documentation: "The actual parameters."
Expand Down Expand Up @@ -803,7 +809,8 @@ public let DECL_NODES: [Node] = [
],
children: [
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
documentation: "The name of this case."
),
Expand Down Expand Up @@ -836,7 +843,7 @@ public let DECL_NODES: [Node] = [
documentation: "A Swift `enum` declaration.",
traits: [
"DeclGroup",
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithGenericParameters",
"WithModifiers",
Expand All @@ -862,7 +869,8 @@ public let DECL_NODES: [Node] = [
documentation: "The `enum` keyword for this declaration."
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
documentation: "Declares the name of this enum. If the name matches a reserved keyword use backticks to escape it."
),
Expand Down Expand Up @@ -958,7 +966,7 @@ public let DECL_NODES: [Node] = [
base: .decl,
nameForDiagnostics: "function",
traits: [
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithGenericParameters",
"WithModifiers",
Expand All @@ -981,7 +989,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.keyword(text: "func")])
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [
.token(tokenKind: "IdentifierToken"),
.token(tokenKind: "BinaryOperatorToken"),
Expand Down Expand Up @@ -1259,7 +1268,8 @@ public let DECL_NODES: [Node] = [
],
children: [
Child(
name: "TypeName",
name: "Type",
deprecatedName: "TypeName",
kind: .node(kind: .type)
),
Child(
Expand Down Expand Up @@ -1370,7 +1380,7 @@ public let DECL_NODES: [Node] = [
base: .decl,
nameForDiagnostics: "macro",
traits: [
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithGenericParameters",
"WithModifiers",
Expand All @@ -1393,7 +1403,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.keyword(text: "macro")])
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")])
),
Child(
Expand Down Expand Up @@ -1454,7 +1465,8 @@ public let DECL_NODES: [Node] = [
documentation: "The `#` sign."
),
Child(
name: "Macro",
name: "MacroName",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use Name for most other nodes, any reason to prefer MacroName here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use Name for nodes that declare something (e.g. StructDeclSyntax), while this node refers to something. And I just thought that name alone here is a little ambiguous because it’s not entirely sure what the name is. I don’t have super strong opinions here though.

deprecatedName: "Macro",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")])
),
Child(
Expand All @@ -1469,7 +1481,8 @@ public let DECL_NODES: [Node] = [
isOptional: true
),
Child(
name: "ArgumentList",
name: "Arguments",
deprecatedName: "ArgumentList",
kind: .collection(kind: .tupleExprElementList, collectionElementName: "Argument")
),
Child(
Expand Down Expand Up @@ -1577,7 +1590,7 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "operator declaration",
documentation: "A Swift `operator` declaration.",
traits: [
"IdentifiedDecl"
"NamedDecl"
],
children: [
Child(
Expand All @@ -1592,7 +1605,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.keyword(text: "operator")])
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"), .token(tokenKind: "PostfixOperatorToken")])
),
Child(
Expand Down Expand Up @@ -1642,7 +1656,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.token(tokenKind: "LeftParenToken")])
),
Child(
name: "ParameterList",
name: "Parameters",
deprecatedName: "ParameterList",
kind: .collection(kind: .functionParameterList, collectionElementName: "Parameter"),
nameForDiagnostics: "parameters"
),
Expand Down Expand Up @@ -1685,7 +1700,8 @@ public let DECL_NODES: [Node] = [
isOptional: true
),
Child(
name: "Accessor",
name: "Accessors",
deprecatedName: "Accessor",
kind: .nodeChoices(choices: [
Child(
name: "Accessors",
Expand Down Expand Up @@ -1765,7 +1781,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.token(tokenKind: "LeftParenToken")])
),
Child(
name: "Args",
name: "Arguments",
deprecatedName: "Args",
kind: .node(kind: .poundSourceLocationArgs),
nameForDiagnostics: "arguments",
isOptional: true
Expand Down Expand Up @@ -1848,7 +1865,7 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "precedencegroup",
documentation: "A Swift `precedencegroup` declaration.",
traits: [
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithModifiers",
],
Expand All @@ -1872,7 +1889,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.keyword(text: "precedencegroup")])
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
documentation: "The name of this precedence group."
),
Expand Down Expand Up @@ -1961,7 +1979,7 @@ public let DECL_NODES: [Node] = [
""",
traits: [
"DeclGroup",
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithModifiers",
],
Expand All @@ -1986,7 +2004,8 @@ public let DECL_NODES: [Node] = [
documentation: "The `protocol` keyword for this declaration."
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
documentation: "The name of the protocol."
),
Expand Down Expand Up @@ -2031,7 +2050,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.token(tokenKind: "ArrowToken")])
),
Child(
name: "ReturnType",
name: "Type",
deprecatedName: "ReturnType",
kind: .node(kind: .type),
nameForDiagnostics: "return type"
),
Expand Down Expand Up @@ -2128,7 +2148,7 @@ public let DECL_NODES: [Node] = [
""",
traits: [
"DeclGroup",
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithGenericParameters",
"WithModifiers",
Expand All @@ -2154,7 +2174,8 @@ public let DECL_NODES: [Node] = [
documentation: "The `struct` keyword for this declaration."
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
documentation: "Declares the name of this struct. If the name matches a reserved keyword use backticks to escape it."
),
Expand Down Expand Up @@ -2239,7 +2260,8 @@ public let DECL_NODES: [Node] = [
isOptional: true
),
Child(
name: "Accessor",
name: "Accessors",
deprecatedName: "Accessor",
kind: .nodeChoices(choices: [
Child(
name: "Accessors",
Expand All @@ -2266,7 +2288,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.token(tokenKind: "ColonToken")])
),
Child(
name: "InheritedTypeCollection",
name: "InheritedTypes",
deprecatedName: "InheritedTypeCollection",
kind: .collection(kind: .inheritedTypeList, collectionElementName: "InheritedType")
),
]
Expand Down Expand Up @@ -2299,7 +2322,7 @@ public let DECL_NODES: [Node] = [
base: .decl,
nameForDiagnostics: "typealias declaration",
traits: [
"IdentifiedDecl",
"NamedDecl",
"WithAttributes",
"WithGenericParameters",
"WithModifiers",
Expand All @@ -2322,7 +2345,8 @@ public let DECL_NODES: [Node] = [
kind: .token(choices: [.keyword(text: "typealias")])
),
Child(
name: "Identifier",
name: "Name",
deprecatedName: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")])
),
Child(
Expand Down
Loading