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+
1316internal 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
3035internal 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