@@ -22,22 +22,33 @@ struct GeneratedInterfaceInfo {
22
22
23
23
extension SwiftLanguageService {
24
24
public func openGeneratedInterface(
25
- _ request: OpenGeneratedInterfaceRequest
25
+ textDocument: TextDocumentIdentifier ,
26
+ moduleName: String ,
27
+ groupName: String ? ,
28
+ symbolUSR symbol: String ?
26
29
) async throws -> GeneratedInterfaceDetails ? {
27
- let name = request. name
28
- let symbol = request. symbolUSR
30
+ // Name of interface module name with group names appended
31
+ let name = if let groupName {
32
+ " \( moduleName) . \( groupName. replacing ( " / " , with: " . " ) ) "
33
+ } else {
34
+ moduleName
35
+ }
29
36
let interfaceFilePath = self . generatedInterfacesPath. appendingPathComponent ( " \( name) .swiftinterface " )
30
37
let interfaceDocURI = DocumentURI ( interfaceFilePath)
31
38
// has interface already been generated
32
39
if let snapshot = try ? self . documentManager. latestSnapshot ( interfaceDocURI) {
33
40
return await self . generatedInterfaceDetails (
34
- request: request,
35
41
uri: interfaceDocURI,
36
42
snapshot: snapshot,
37
43
symbol: symbol
38
44
)
39
45
} else {
40
- let interfaceInfo = try await self . generatedInterfaceInfo ( request: request, interfaceURI: interfaceDocURI)
46
+ let interfaceInfo = try await self . generatedInterfaceInfo (
47
+ textDocument: textDocument,
48
+ moduleName: moduleName,
49
+ groupName: groupName,
50
+ interfaceURI: interfaceDocURI
51
+ )
41
52
try interfaceInfo. contents. write ( to: interfaceFilePath, atomically: true , encoding: String . Encoding. utf8)
42
53
let snapshot = DocumentSnapshot (
43
54
uri: interfaceDocURI,
@@ -46,7 +57,6 @@ extension SwiftLanguageService {
46
57
lineTable: LineTable ( interfaceInfo. contents)
47
58
)
48
59
let result = await self . generatedInterfaceDetails (
49
- request: request,
50
60
uri: interfaceDocURI,
51
61
snapshot: snapshot,
52
62
symbol: symbol
@@ -67,25 +77,26 @@ extension SwiftLanguageService {
67
77
/// - Important: This opens a document with name `interfaceURI.pseudoPath` in sourcekitd. The caller is responsible
68
78
/// for ensuring that the document will eventually get closed in sourcekitd again.
69
79
private func generatedInterfaceInfo(
70
- request: OpenGeneratedInterfaceRequest ,
80
+ textDocument: TextDocumentIdentifier ,
81
+ moduleName: String ,
82
+ groupName: String ? ,
71
83
interfaceURI: DocumentURI
72
84
) async throws -> GeneratedInterfaceInfo {
73
85
let keys = self . keys
74
86
let skreq = sourcekitd. dictionary ( [
75
87
keys. request: requests. editorOpenInterface,
76
- keys. moduleName: request . moduleName,
77
- keys. groupName: request . groupName,
88
+ keys. moduleName: moduleName,
89
+ keys. groupName: groupName,
78
90
keys. name: interfaceURI. pseudoPath,
79
91
keys. synthesizedExtension: 1 ,
80
- keys. compilerArgs: await self . buildSettings ( for: request . textDocument. uri) ? . compilerArgs as [ SKDRequestValue ] ? ,
92
+ keys. compilerArgs: await self . buildSettings ( for: textDocument. uri) ? . compilerArgs as [ SKDRequestValue ] ? ,
81
93
] )
82
94
83
95
let dict = try await self . sourcekitd. send ( skreq, fileContents: nil )
84
96
return GeneratedInterfaceInfo ( contents: dict [ keys. sourceText] ?? " " )
85
97
}
86
98
87
99
private func generatedInterfaceDetails(
88
- request: OpenGeneratedInterfaceRequest ,
89
100
uri: DocumentURI ,
90
101
snapshot: DocumentSnapshot ,
91
102
symbol: String ?
0 commit comments