-
Notifications
You must be signed in to change notification settings - Fork 440
Add Syntax nodes for compiler generated files #2968
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
Conversation
swiftlang/swift#79513 |
75cb90a
to
66c1a1e
Compare
swiftlang/swift#79513 |
* `AccessorBlockFileSyntax`: For `accessor` macro expansions * `AttributeClauseFileSyntax`: For `memberAttribute` macro expansions * `CodeBlockFileSyntax`: For `body` macro expansiosns * `MemberBlockItemListFileSyntax`: For decl macros in type contexts Also rename 'AvailabilityMacroDefinition' to `AvailabilityMacroDefinitionFile` and add 'endOfFileToken'. These are 'Compiler' SPI and parsed as a "file". To keep the source fidelity, we should keep the EOF token which might have some trivia. In `CodeGeneration`, make `collectionElementName` optional to avoid unnecessary _deprecated_ `add{ElemebtName}(_:)` methods.
66c1a1e
to
7549913
Compare
swiftlang/swift#79513 |
swiftlang/swift#79513 |
@swift-ci Please test |
@swift-ci Please test macOS |
@swift-ci Please test Linux |
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.
Should we have tests cases that parse these nodes?
#if compiler(>=6) | ||
@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) internal import SwiftSyntax | ||
#else | ||
@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) import SwiftSyntax | ||
#endif |
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.
Why do you need internal import
here?
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.
Not sure I understand your question. Every swift files in SwiftParser
has internal import SwiftSyntax
or public import SwiftSyntax
depending on the APIs declared in the file.
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.
Ooops, I thought that we didn’t use scoped imports at all in swift-syntax. Sorry.
All 'Compiler' SPI.
These are parsed as "file". To keep the source fidelity, we should keep the EOF token which might have some trivia.
AccessorBlockFileSyntax
: Foraccessor
macro expansionsAttributeClauseFileSyntax
: FormemberAttribute
macro expansionsCodeBlockFileSyntax
: Forbody
macro expansiosnsMemberBlockItemListFileSyntax
: For decl macros in type contextsAvailabilityMacroDefinition
toAvailabilityMacroDefinitionFile
and addendOfFileToken
.In
CodeGeneration
, makecollectionElementName
optional to avoid unnecessary deprecatedadd{ElemebtName}(_:)
methods.