@@ -18,34 +18,6 @@ import SKOptions
18
18
import SKSupport
19
19
import SourceKitD
20
20
21
- /// Detailed information about the result of a macro expansion operation.
22
- ///
23
- /// Wraps the information returned by sourcekitd's `semantic_refactoring`
24
- /// request, such as the necessary macro expansion edits.
25
- struct MacroExpansion : RefactoringResponse {
26
- /// The title of the refactoring action.
27
- var title : String
28
-
29
- /// The URI of the file where the macro is used
30
- var uri : DocumentURI
31
-
32
- /// The resulting array of `RefactoringEdit` of a semantic refactoring request
33
- var edits : [ RefactoringEdit ]
34
-
35
- init ( title: String , uri: DocumentURI , refactoringEdits: [ RefactoringEdit ] ) {
36
- self . title = title
37
- self . uri = uri
38
- self . edits = refactoringEdits. compactMap { refactoringEdit in
39
- if refactoringEdit. bufferName == nil && !refactoringEdit. newText. isEmpty {
40
- logger. fault ( " Unable to retrieve some parts of the expansion " )
41
- return nil
42
- }
43
-
44
- return refactoringEdit
45
- }
46
- }
47
- }
48
-
49
21
/// Caches the contents of macro expansions that were recently requested by the user.
50
22
actor MacroExpansionManager {
51
23
private struct CacheEntry {
@@ -199,7 +171,7 @@ extension SwiftLanguageService {
199
171
throw ResponseError . unknown ( " Connection to the editor closed " )
200
172
}
201
173
202
- let primaryFileDisplayName =
174
+ let parentFileDisplayName =
203
175
switch try ? ReferenceDocumentURL ( from: expandMacroCommand. textDocument. uri) {
204
176
case . macroExpansion( let data) :
205
177
data. bufferName
@@ -234,7 +206,7 @@ extension SwiftLanguageService {
234
206
235
207
let editContent =
236
208
"""
237
- // \( primaryFileDisplayName ) @ \( macroEdit. range. lowerBound. line + 1 ) : \( macroEdit. range. lowerBound. utf16index + 1 ) - \( macroEdit. range. upperBound. line + 1 ) : \( macroEdit. range. upperBound. utf16index + 1 )
209
+ // \( parentFileDisplayName ) @ \( macroEdit. range. lowerBound. line + 1 ) : \( macroEdit. range. lowerBound. utf16index + 1 ) - \( macroEdit. range. upperBound. line + 1 ) : \( macroEdit. range. upperBound. utf16index + 1 )
238
210
\( macroEdit. newText)
239
211
240
212
@@ -298,7 +270,7 @@ extension SwiftLanguageService {
298
270
}
299
271
300
272
completeExpansionFilePath =
301
- completeExpansionFilePath. appendingPathComponent ( primaryFileDisplayName )
273
+ completeExpansionFilePath. appendingPathComponent ( parentFileDisplayName )
302
274
do {
303
275
try completeExpansionFileContent. write ( to: completeExpansionFilePath, atomically: true , encoding: . utf8)
304
276
} catch {
0 commit comments