10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
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
+
13
16
internal enum HostToPluginMessage : Codable {
14
17
case getCapability
15
18
16
19
case expandFreestandingMacro(
17
20
macro: PluginMessage . MacroReference ,
18
21
discriminator: String ,
19
- syntax: PluginMessage . Syntax )
22
+ syntax: PluginMessage . Syntax
23
+ )
20
24
21
25
case expandAttachedMacro(
22
26
macro: PluginMessage . MacroReference ,
23
27
macroRole: PluginMessage . MacroRole ,
24
28
discriminator: String ,
25
- customAttributeSyntax : PluginMessage . Syntax ,
29
+ attributeSyntax : PluginMessage . Syntax ,
26
30
declSyntax: PluginMessage . Syntax ,
27
- parentDeclSyntax: PluginMessage . Syntax ? )
31
+ parentDeclSyntax: PluginMessage . Syntax ?
32
+ )
28
33
}
29
34
30
35
internal enum PluginToHostMessage : Codable {
31
36
case expandFreestandingMacroResult(
32
37
expandedSource: String ? ,
33
- diagnostics: [ PluginMessage . Diagnostic ] )
38
+ diagnostics: [ PluginMessage . Diagnostic ]
39
+ )
34
40
35
41
case expandAttachedMacroResult(
36
42
expandedSources: [ String ] ? ,
37
- diagnostics: [ PluginMessage . Diagnostic ] )
43
+ diagnostics: [ PluginMessage . Diagnostic ]
44
+ )
38
45
39
46
case getCapabilityResult( capability: PluginMessage . PluginCapability )
40
47
}
41
48
42
49
/*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'.
44
51
45
52
struct PluginCapability : Codable {
46
53
var protocolVersion : Int
@@ -69,9 +76,17 @@ internal enum PluginToHostMessage: Codable {
69
76
}
70
77
71
78
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`.
72
81
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`.
73
85
var fileName : String
86
+
87
+ /// UTF-8 offset of the location in the file.
74
88
var offset : Int
89
+
75
90
var line : Int
76
91
var column : Int
77
92
}
@@ -84,12 +99,23 @@ internal enum PluginToHostMessage: Codable {
84
99
}
85
100
struct Position : Codable {
86
101
var fileName : String
102
+ /// UTF-8 offset in the file.
87
103
var offset : Int
104
+
105
+ static var invalid : Self {
106
+ . init( fileName: " " , offset: 0 )
107
+ }
88
108
}
89
109
struct PositionRange : Codable {
90
110
var fileName : String
111
+ /// UTF-8 offset of the start of the range in the file.
91
112
var startOffset : Int
113
+ /// UTF-8 offset of the end of the range in the file.
92
114
var endOffset : Int
115
+
116
+ static var invalid : Self {
117
+ . init( fileName: " " , startOffset: 0 , endOffset: 0 )
118
+ }
93
119
}
94
120
struct Note : Codable {
95
121
var position : Position
0 commit comments