Skip to content

Commit 202d3f5

Browse files
committed
[ASTGen] Sync PluginMessages.swift with the SwiftSyntax changes for extension
macros. (cherry picked from commit c3bdae6)
1 parent 8f1f6bf commit 202d3f5

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/ASTGen/Sources/ASTGen/Macros.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,14 @@ func expandAttachedMacroIPC(
816816
parentDeclSyntax = nil
817817
}
818818

819+
let extendedTypeSyntax: PluginMessage.Syntax?
820+
if (!qualifiedType.isEmpty) {
821+
let typeSyntax: TypeSyntax = "\(raw: qualifiedType)"
822+
extendedTypeSyntax = .init(syntax: Syntax(typeSyntax), in: parentDeclSourceFilePtr!)!
823+
} else {
824+
extendedTypeSyntax = nil
825+
}
826+
819827
// Send the message.
820828
let message = HostToPluginMessage.expandAttachedMacro(
821829
macro: .init(moduleName: macro.moduleName, typeName: macro.typeName, name: macroName),
@@ -824,7 +832,8 @@ func expandAttachedMacroIPC(
824832
qualifiedType: qualifiedType,
825833
attributeSyntax: customAttributeSyntax,
826834
declSyntax: declSyntax,
827-
parentDeclSyntax: parentDeclSyntax)
835+
parentDeclSyntax: parentDeclSyntax,
836+
extendedTypeSyntax: extendedTypeSyntax)
828837
do {
829838
let expandedSource: String?
830839
let diagnostics: [PluginMessage.Diagnostic]

lib/ASTGen/Sources/ASTGen/PluginMessages.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ internal enum HostToPluginMessage: Codable {
3535
qualifiedType: String,
3636
attributeSyntax: PluginMessage.Syntax,
3737
declSyntax: PluginMessage.Syntax,
38-
parentDeclSyntax: PluginMessage.Syntax?
38+
parentDeclSyntax: PluginMessage.Syntax?,
39+
extendedTypeSyntax: PluginMessage.Syntax?
3940
)
4041

4142
/// Optionally implemented message to load a dynamic link library.
@@ -77,7 +78,7 @@ internal enum PluginToHostMessage: Codable {
7778
}
7879

7980
/*namespace*/ internal enum PluginMessage {
80-
static var PROTOCOL_VERSION_NUMBER: Int { 5 } // Added 'expandMacroResult'.
81+
static var PROTOCOL_VERSION_NUMBER: Int { 6 } // Added 'expandMacroResult'.
8182

8283
struct HostCapability: Codable {
8384
var protocolVersion: Int

0 commit comments

Comments
 (0)