Skip to content

Commit b41a44d

Browse files
committed
[Macros] Update PluginMessages for 'customAttrbuteSyntax' rename.
Rename 'customAttributeSyntax' -> 'attributeSyntax'
1 parent e490466 commit b41a44d

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

lib/ASTGen/Sources/ASTGen/Macros.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ func expandAttachedMacroIPC(
584584
macro: .init(moduleName: macro.moduleName, typeName: macro.typeName, name: macroName),
585585
macroRole: macroRole,
586586
discriminator: discriminator,
587-
customAttributeSyntax: customAttributeSyntax,
587+
attributeSyntax: customAttributeSyntax,
588588
declSyntax: declSyntax,
589589
parentDeclSyntax: parentDeclSyntax)
590590
do {

lib/ASTGen/Sources/ASTGen/PluginMessages.swift

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,44 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
// NOTE: This file should be synced between swift and swift-syntax repository.
14+
// NOTE: Types in this file should be self-contained and should not depend on any non-stdlib types.
15+
1316
internal enum HostToPluginMessage: Codable {
1417
case getCapability
1518

1619
case expandFreestandingMacro(
1720
macro: PluginMessage.MacroReference,
1821
discriminator: String,
19-
syntax: PluginMessage.Syntax)
22+
syntax: PluginMessage.Syntax
23+
)
2024

2125
case expandAttachedMacro(
2226
macro: PluginMessage.MacroReference,
2327
macroRole: PluginMessage.MacroRole,
2428
discriminator: String,
25-
customAttributeSyntax: PluginMessage.Syntax,
29+
attributeSyntax: PluginMessage.Syntax,
2630
declSyntax: PluginMessage.Syntax,
27-
parentDeclSyntax: PluginMessage.Syntax?)
31+
parentDeclSyntax: PluginMessage.Syntax?
32+
)
2833
}
2934

3035
internal enum PluginToHostMessage: Codable {
3136
case expandFreestandingMacroResult(
3237
expandedSource: String?,
33-
diagnostics: [PluginMessage.Diagnostic])
38+
diagnostics: [PluginMessage.Diagnostic]
39+
)
3440

3541
case expandAttachedMacroResult(
3642
expandedSources: [String]?,
37-
diagnostics: [PluginMessage.Diagnostic])
43+
diagnostics: [PluginMessage.Diagnostic]
44+
)
3845

3946
case getCapabilityResult(capability: PluginMessage.PluginCapability)
4047
}
4148

4249
/*namespace*/ internal enum PluginMessage {
43-
static var PROTOCOL_VERSION_NUMBER: Int { 2 } // Added 'MacroRole.conformance'
50+
static var PROTOCOL_VERSION_NUMBER: Int { 3 } // Renamed 'customAttributeSyntax' to 'attributeSyntax'.
4451

4552
struct PluginCapability: Codable {
4653
var protocolVersion: Int
@@ -69,9 +76,17 @@ internal enum PluginToHostMessage: Codable {
6976
}
7077

7178
struct SourceLocation: Codable {
79+
/// A file ID consisting of the module name and file name (without full path),
80+
/// as would be generated by the macro expansion `#fileID`.
7281
var fileID: String
82+
83+
/// A full path name as would be generated by the macro expansion `#filePath`,
84+
/// e.g., `/home/taylor/alison.swift`.
7385
var fileName: String
86+
87+
/// UTF-8 offset of the location in the file.
7488
var offset: Int
89+
7590
var line: Int
7691
var column: Int
7792
}
@@ -84,12 +99,23 @@ internal enum PluginToHostMessage: Codable {
8499
}
85100
struct Position: Codable {
86101
var fileName: String
102+
/// UTF-8 offset in the file.
87103
var offset: Int
104+
105+
static var invalid: Self {
106+
.init(fileName: "", offset: 0)
107+
}
88108
}
89109
struct PositionRange: Codable {
90110
var fileName: String
111+
/// UTF-8 offset of the start of the range in the file.
91112
var startOffset: Int
113+
/// UTF-8 offset of the end of the range in the file.
92114
var endOffset: Int
115+
116+
static var invalid: Self {
117+
.init(fileName: "", startOffset: 0, endOffset: 0)
118+
}
93119
}
94120
struct Note: Codable {
95121
var position: Position

0 commit comments

Comments
 (0)