Skip to content

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

Merged
merged 2 commits into from
Feb 22, 2025

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Feb 20, 2025

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: 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.

In CodeGeneration, make collectionElementName optional to avoid unnecessary deprecated add{ElemebtName}(_:) methods.

@rintaro
Copy link
Member Author

rintaro commented Feb 20, 2025

swiftlang/swift#79513
@swift-ci Please test

@rintaro rintaro force-pushed the compiler-generated-files branch from 75cb90a to 66c1a1e Compare February 21, 2025 04:58
@rintaro rintaro changed the title Add 'GeneratedAttributeClauseFile' and 'GeneratedAcceesoBlockFile' Add Syntax nodes for compiler generated files Feb 21, 2025
@rintaro
Copy link
Member Author

rintaro commented Feb 21, 2025

swiftlang/swift#79513
@swift-ci Please test

@rintaro rintaro requested a review from hamishknight February 21, 2025 05:43
* `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.
@rintaro rintaro force-pushed the compiler-generated-files branch from 66c1a1e to 7549913 Compare February 21, 2025 14:45
@rintaro
Copy link
Member Author

rintaro commented Feb 21, 2025

swiftlang/swift#79513
@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Feb 21, 2025

swiftlang/swift#79513
@swift-ci Please test Windows

@rintaro
Copy link
Member Author

rintaro commented Feb 22, 2025

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Feb 22, 2025

@swift-ci Please test macOS

@rintaro
Copy link
Member Author

rintaro commented Feb 22, 2025

@swift-ci Please test Linux

@rintaro rintaro enabled auto-merge February 22, 2025 02:00
Copy link
Member

@ahoppen ahoppen left a 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?

Comment on lines +13 to +17
#if compiler(>=6)
@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) internal import SwiftSyntax
#else
@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) import SwiftSyntax
#endif
Copy link
Member

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?

Copy link
Member Author

@rintaro rintaro Feb 22, 2025

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.

Copy link
Member

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.

@rintaro rintaro merged commit 3688938 into swiftlang:main Feb 22, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants