-
Notifications
You must be signed in to change notification settings - Fork 439
[Macros] Attached macro expansions return single string #1845
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
[Macros] Attached macro expansions return single string #1845
Conversation
swiftlang/swift#66918 |
a8f456a
to
3729244
Compare
swiftlang/swift#66918 |
swiftlang/swift#66918 |
attributeNode: attributeNode, | ||
declarationNode: declarationNode, | ||
parentDeclNode: parentDeclNode, | ||
in: context | ||
) | ||
guard let expansions = expansions else { |
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.
IMO I'd just have this check in the if below, ie.
if let expansions, hostCapability.hasExpandMacroResult {
...
} else {
...
}
|
||
// Create an "oldest" capability. | ||
init() { | ||
self.protocolVersion = 0 |
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 the default be 4?
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.
4
doesn't mean anything in practice. If we use 4 as default, we should add doc-comment explaining that. I don't think it's worth it.
3729244
to
23972ec
Compare
* Move collapse(expansions:for:attachedTo:) to SwiftSyntaxMacroExpansion * SwiftSyntaxMacroExpansion.expandAttachedMacro() now perform collapsing * SwiftSyntaxMacroExpansion.expandAttachedMacroWithoutCollapsing() for to keep old behavior * IPC message 'getCapability' now send the host protocol version * Unified IPC response 'macroExpansionResult' that returns single string for both 'expandFreestandingMacro' and 'expandAttachedMacro' * Compiler accepts old 'expandFreestandingMacroResult' and 'expandAttachedMacroResult' to keep compatibility * Plugins check the compiler's protcol version to see if it suppports 'macroExpansionResult', and fall back to old behavior if necessary
Macro deifnition checking is only meant to be used by something that expands macros (e.g. compiler). Not for macro implementation.
23972ec
to
6fc14cb
Compare
swiftlang/swift#66918 |
swiftlang/swift#66918 |
swift-syntax change swiftlang/swift#66918
collapse(expansions:for:attachedTo:)
toSwiftSyntaxMacroExpansion
SwiftSyntaxMacroExpansion.expandAttachedMacro()
now perform collapsingSwiftSyntaxMacroExpansion.expandAttachedMacroWithoutCollapsing()
to keep old behaviorgetCapability
now sends the host protocol versionmacroExpansionResult
that returns single string for bothexpandFreestandingMacro
andexpandAttachedMacro
expandFreestandingMacroResult
andexpandAttachedMacroResult
to keep compatibilitymacroExpansionResult
, and fall back to old behavior if necessaryAlso:
checkMacroDefinition()
toSwiftSyntaxMacroExpansion
module