Skip to content

Commit c3bdae6

Browse files
committed
[ASTGen] Sync PluginMessages.swift with the SwiftSyntax changes for extension
macros.
1 parent c867c7c commit c3bdae6

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
@@ -846,6 +846,14 @@ func expandAttachedMacroIPC(
846846
parentDeclSyntax = nil
847847
}
848848

849+
let extendedTypeSyntax: PluginMessage.Syntax?
850+
if (!qualifiedType.isEmpty) {
851+
let typeSyntax: TypeSyntax = "\(raw: qualifiedType)"
852+
extendedTypeSyntax = .init(syntax: Syntax(typeSyntax), in: parentDeclSourceFilePtr!)!
853+
} else {
854+
extendedTypeSyntax = nil
855+
}
856+
849857
// Send the message.
850858
let message = HostToPluginMessage.expandAttachedMacro(
851859
macro: .init(moduleName: macro.moduleName, typeName: macro.typeName, name: macroName),
@@ -854,7 +862,8 @@ func expandAttachedMacroIPC(
854862
qualifiedType: qualifiedType,
855863
attributeSyntax: customAttributeSyntax,
856864
declSyntax: declSyntax,
857-
parentDeclSyntax: parentDeclSyntax)
865+
parentDeclSyntax: parentDeclSyntax,
866+
extendedTypeSyntax: extendedTypeSyntax)
858867
do {
859868
let expandedSource: String?
860869
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)