@@ -18,34 +18,6 @@ import SKOptions
1818import SKSupport
1919import SourceKitD
2020
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-
4921/// Caches the contents of macro expansions that were recently requested by the user.
5022actor MacroExpansionManager {
5123 private struct CacheEntry {
@@ -199,7 +171,7 @@ extension SwiftLanguageService {
199171 throw ResponseError . unknown ( " Connection to the editor closed " )
200172 }
201173
202- let primaryFileDisplayName =
174+ let parentFileDisplayName =
203175 switch try ? ReferenceDocumentURL ( from: expandMacroCommand. textDocument. uri) {
204176 case . macroExpansion( let data) :
205177 data. bufferName
@@ -234,7 +206,7 @@ extension SwiftLanguageService {
234206
235207 let editContent =
236208 """
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 )
238210 \( macroEdit. newText)
239211
240212
@@ -298,7 +270,7 @@ extension SwiftLanguageService {
298270 }
299271
300272 completeExpansionFilePath =
301- completeExpansionFilePath. appendingPathComponent ( primaryFileDisplayName )
273+ completeExpansionFilePath. appendingPathComponent ( parentFileDisplayName )
302274 do {
303275 try completeExpansionFileContent. write ( to: completeExpansionFilePath, atomically: true , encoding: . utf8)
304276 } catch {
0 commit comments