-
Notifications
You must be signed in to change notification settings - Fork 425
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
SwiftSyntax support for experimental @abi attribute #2882
base: main
Are you sure you want to change the base?
Changes from all commits
aa0b9a7
df991ae
2c57e11
c335d65
f77bb25
cb0f4b9
54ce286
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,11 @@ public let ATTRIBUTE_NODES: [Node] = [ | |
name: "documentationArguments", | ||
kind: .node(kind: .documentationAttributeArgumentList) | ||
), | ||
Child( | ||
name: "abiArguments", | ||
kind: .node(kind: .abiAttributeArguments), | ||
experimentalFeature: .abiAttribute | ||
), | ||
]), | ||
documentation: """ | ||
The arguments of the attribute. | ||
|
@@ -267,6 +272,31 @@ public let ATTRIBUTE_NODES: [Node] = [ | |
] | ||
), | ||
|
||
Node( | ||
kind: .abiAttributeArguments, | ||
base: .syntax, | ||
experimentalFeature: .abiAttribute, | ||
nameForDiagnostics: "ABI-providing declaration", | ||
documentation: "The arguments of the '@abi' attribute", | ||
children: [ | ||
Child( | ||
name: "provider", | ||
kind: ChildKind.nodeChoices(choices: [ | ||
Child(name: "associatedType", kind: .node(kind: .associatedTypeDecl)), | ||
Child(name: "declGroup", kind: .node(kind: .declGroupHeader)), | ||
Child(name: "deinitializer", kind: .node(kind: .deinitializerDecl)), | ||
Child(name: "enumCase", kind: .node(kind: .enumCaseDecl)), | ||
Child(name: "function", kind: .node(kind: .functionDecl)), | ||
Child(name: "initializer", kind: .node(kind: .initializerDecl)), | ||
Child(name: "subscript", kind: .node(kind: .subscriptDecl)), | ||
Child(name: "typeAlias", kind: .node(kind: .typeAliasDecl)), | ||
Child(name: "variable", kind: .node(kind: .variableDecl)), | ||
Child(name: "unsupported", kind: .node(kind: .decl)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of having an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I do that, we probably still need a choice for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, adding a choice for |
||
]) | ||
) | ||
] | ||
), | ||
|
||
Node( | ||
kind: .conventionAttributeArguments, | ||
base: .syntax, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,13 +180,98 @@ public let COMMON_NODES: [Node] = [ | |
parserFunction: "parseDeclaration" | ||
), | ||
|
||
Node( | ||
kind: .declGroupHeader, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of the other base nodes ( That said, I would make the base of all header nodes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little reluctant to do this because I get a fair bit of mileage out of having (If it helps, the If you can suggest another design that would still give me a concrete node which could contain any of the headers, I'd be open to that change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me think about it some more. It might also become clearer to me once #2888 is merged and this PR is rebased so it doesn’t contain those changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @ahoppen , we now have the other PR merged. Do you have more specific suggestions in mind? |
||
base: .syntax, | ||
nameForDiagnostics: "declaration group header", | ||
parserFunction: "parseDeclarationGroupHeader", | ||
traits: [ | ||
"WithAttributes", | ||
"WithModifiers", | ||
], | ||
children: [ | ||
Child( | ||
name: "attributes", | ||
kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), | ||
nameForDiagnostics: "attributes" | ||
), | ||
Child( | ||
name: "modifiers", | ||
kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true), | ||
nameForDiagnostics: "modifiers", | ||
documentation: "Modifiers like `public` that are attached to the actor declaration." | ||
), | ||
Child( | ||
name: "introducer", | ||
kind: .token(choices: [ | ||
.keyword(.actor), .keyword(.class), .keyword(.enum), .keyword(.extension), .keyword(.protocol), | ||
.keyword(.struct), | ||
]), | ||
documentation: "The token that introduces this declaration, eg. `class` for a class declaration." | ||
), | ||
Child(name: "inheritanceClause", kind: .node(kind: .inheritanceClause), isOptional: true), | ||
Child( | ||
name: "genericWhereClause", | ||
kind: .node(kind: .genericWhereClause), | ||
documentation: | ||
"A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`.", | ||
isOptional: true | ||
), | ||
] | ||
), | ||
|
||
Node( | ||
kind: .expr, | ||
base: .syntax, | ||
nameForDiagnostics: "expression", | ||
parserFunction: "parseExpression" | ||
), | ||
|
||
Node( | ||
kind: .missingDeclHeader, | ||
base: .declGroupHeader, | ||
nameForDiagnostics: "declaration group header", | ||
documentation: | ||
"In case the source code is missing a declaration group header, this node stands in place of the missing header.", | ||
traits: [ | ||
"MissingNode", | ||
"WithAttributes", | ||
"WithModifiers", | ||
], | ||
children: [ | ||
Child( | ||
name: "attributes", | ||
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", defaultsToEmpty: true), | ||
documentation: | ||
"If there were standalone modifiers without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these." | ||
), | ||
Child( | ||
name: "placeholder", | ||
kind: .token(choices: [.token(.identifier)], requiresLeadingSpace: false, requiresTrailingSpace: false), | ||
documentation: """ | ||
A placeholder, i.e. `<#decl#>`, that can be inserted into the source code to represent the missing declaration. | ||
|
||
This token should always have `presence = .missing`. | ||
""" | ||
), | ||
Child(name: "inheritanceClause", kind: .node(kind: .inheritanceClause), isOptional: true), | ||
Child( | ||
name: "genericWhereClause", | ||
kind: .node(kind: .genericWhereClause), | ||
documentation: | ||
"A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`.", | ||
isOptional: true | ||
), | ||
|
||
] | ||
), | ||
|
||
Node( | ||
kind: .missingDecl, | ||
base: .decl, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an entry to the release notes for the new/updated nodes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, the node is hidden behind an experimental feature. Should I still document it now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably didn’t put the comment at the right place. I meant adding a release note entry for the nodes that change and that are not SPI, eg. the introduction of
ClassDeclSyntax.header
.