Skip to content

Generalize macro expansion for macros written as attributes #1208

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 5 commits into from
Jan 10, 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 @@ -45,6 +45,9 @@ public let COMMON_NODES: [Node] = [
Node(name: "MissingDecl",
nameForDiagnostics: "declaration",
kind: "Decl",
traits: [
"Attributed"
],
children: [
Child(name: "Attributes",
kind: "AttributeList",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "typealias declaration",
kind: "Decl",
traits: [
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -65,7 +66,8 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "associatedtype declaration",
kind: "Decl",
traits: [
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -454,7 +456,8 @@ public let DECL_NODES: [Node] = [
kind: "Decl",
traits: [
"DeclGroup",
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -493,7 +496,8 @@ public let DECL_NODES: [Node] = [
kind: "Decl",
traits: [
"DeclGroup",
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -535,7 +539,8 @@ public let DECL_NODES: [Node] = [
kind: "Decl",
traits: [
"DeclGroup",
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -574,7 +579,8 @@ public let DECL_NODES: [Node] = [
kind: "Decl",
traits: [
"DeclGroup",
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -612,7 +618,8 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "extension",
kind: "Decl",
traits: [
"DeclGroup"
"DeclGroup",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -721,7 +728,8 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "parameter",
kind: "Syntax",
traits: [
"WithTrailingComma"
"WithTrailingComma",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -783,7 +791,8 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "function",
kind: "Decl",
traits: [
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -824,6 +833,9 @@ public let DECL_NODES: [Node] = [
Node(name: "InitializerDecl",
nameForDiagnostics: "initializer",
kind: "Decl",
traits: [
"Attributed"
],
children: [
Child(name: "Attributes",
kind: "AttributeList",
Expand Down Expand Up @@ -862,6 +874,9 @@ public let DECL_NODES: [Node] = [
Node(name: "DeinitializerDecl",
nameForDiagnostics: "deinitializer",
kind: "Decl",
traits: [
"Attributed"
],
children: [
Child(name: "Attributes",
kind: "AttributeList",
Expand All @@ -884,6 +899,9 @@ public let DECL_NODES: [Node] = [
Node(name: "SubscriptDecl",
nameForDiagnostics: "subscript",
kind: "Decl",
traits: [
"Attributed"
],
children: [
Child(name: "Attributes",
kind: "AttributeList",
Expand Down Expand Up @@ -958,6 +976,9 @@ public let DECL_NODES: [Node] = [
Node(name: "ImportDecl",
nameForDiagnostics: "import",
kind: "Decl",
traits: [
"Attributed"
],
children: [
Child(name: "Attributes",
kind: "AttributeList",
Expand Down Expand Up @@ -1017,6 +1038,9 @@ public let DECL_NODES: [Node] = [
Node(name: "AccessorDecl",
nameForDiagnostics: "accessor",
kind: "Decl",
traits: [
"Attributed"
],
children: [
Child(name: "Attributes",
kind: "AttributeList",
Expand Down Expand Up @@ -1132,6 +1156,9 @@ public let DECL_NODES: [Node] = [
Node(name: "VariableDecl",
nameForDiagnostics: "variable",
kind: "Decl",
traits: [
"Attributed"
],
children: [
Child(name: "Attributes",
kind: "AttributeList",
Expand Down Expand Up @@ -1193,6 +1220,9 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "enum case",
description: "A `case` declaration of a Swift `enum`. It can have 1 or more`EnumCaseElement`s inside, each declaring a different case of theenum.",
kind: "Decl",
traits: [
"Attributed"
],
children: [
Child(name: "Attributes",
kind: "AttributeList",
Expand Down Expand Up @@ -1221,7 +1251,8 @@ public let DECL_NODES: [Node] = [
description: "A Swift `enum` declaration.",
kind: "Decl",
traits: [
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -1268,7 +1299,8 @@ public let DECL_NODES: [Node] = [
description: "A Swift `operator` declaration.",
kind: "Decl",
traits: [
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -1350,7 +1382,8 @@ public let DECL_NODES: [Node] = [
description: "A Swift `precedencegroup` declaration.",
kind: "Decl",
traits: [
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down Expand Up @@ -1509,7 +1542,8 @@ public let DECL_NODES: [Node] = [
nameForDiagnostics: "macro",
kind: "Decl",
traits: [
"IdentifiedDecl"
"IdentifiedDecl",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,9 @@ public let EXPR_NODES: [Node] = [
Node(name: "ClosureSignature",
nameForDiagnostics: "closure signature",
kind: "Syntax",
traits: [
"Attributed"
],
children: [
Child(name: "Attributes",
kind: "AttributeList",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public let GENERIC_NODES: [Node] = [
nameForDiagnostics: "generic parameter",
kind: "Syntax",
traits: [
"WithTrailingComma"
"WithTrailingComma",
"Attributed"
],
children: [
Child(name: "Attributes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public class Trait {
}

public let TRAITS: [Trait] = [
Trait(traitName: "Attributed",
children: [
Child(name: "Attributes", kind: "AttributeList", isOptional: true),
]
),
Trait(traitName: "DeclGroup",
children: [
Child(name: "Attributes", kind: "AttributeList", isOptional: true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ public let TYPE_NODES: [Node] = [
Node(name: "AttributedType",
nameForDiagnostics: "type",
kind: "Type",
traits: [
"Attributed"
],
children: [
Child(name: "Specifier",
kind: "Token",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ allows Swift tools to parse, inspect, generate, and transform Swift source code.

### Traits

- <doc:SwiftSyntax/AttributedSyntax>
- <doc:SwiftSyntax/DeclGroupSyntax>
- <doc:SwiftSyntax/BracedSyntax>
- <doc:SwiftSyntax/IdentifiedDeclSyntax>
Expand Down
Loading