@@ -22,22 +22,34 @@ struct GeneratedInterfaceInfo {
2222
2323extension SwiftLanguageService {
2424 public func openGeneratedInterface(
25- _ request: OpenGeneratedInterfaceRequest
25+ document: DocumentURI ,
26+ moduleName: String ,
27+ groupName: String ? ,
28+ symbolUSR symbol: String ?
2629 ) 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 =
32+ if let groupName {
33+ " \( moduleName) . \( groupName. replacing ( " / " , with: " . " ) ) "
34+ } else {
35+ moduleName
36+ }
2937 let interfaceFilePath = self . generatedInterfacesPath. appendingPathComponent ( " \( name) .swiftinterface " )
3038 let interfaceDocURI = DocumentURI ( interfaceFilePath)
3139 // has interface already been generated
3240 if let snapshot = try ? self . documentManager. latestSnapshot ( interfaceDocURI) {
3341 return await self . generatedInterfaceDetails (
34- request: request,
3542 uri: interfaceDocURI,
3643 snapshot: snapshot,
3744 symbol: symbol
3845 )
3946 } else {
40- let interfaceInfo = try await self . generatedInterfaceInfo ( request: request, interfaceURI: interfaceDocURI)
47+ let interfaceInfo = try await self . generatedInterfaceInfo (
48+ document: document,
49+ moduleName: moduleName,
50+ groupName: groupName,
51+ interfaceURI: interfaceDocURI
52+ )
4153 try interfaceInfo. contents. write ( to: interfaceFilePath, atomically: true , encoding: String . Encoding. utf8)
4254 let snapshot = DocumentSnapshot (
4355 uri: interfaceDocURI,
@@ -46,7 +58,6 @@ extension SwiftLanguageService {
4658 lineTable: LineTable ( interfaceInfo. contents)
4759 )
4860 let result = await self . generatedInterfaceDetails (
49- request: request,
5061 uri: interfaceDocURI,
5162 snapshot: snapshot,
5263 symbol: symbol
@@ -61,31 +72,34 @@ extension SwiftLanguageService {
6172 /// Open the Swift interface for a module.
6273 ///
6374 /// - Parameters:
64- /// - request: The OpenGeneratedInterfaceRequest.
75+ /// - document: The document whose compiler arguments should be used to generate the interface.
76+ /// - moduleName: The module to generate an index for.
77+ /// - groupName: The module group name.
6578 /// - interfaceURI: The file where the generated interface should be written.
6679 ///
6780 /// - Important: This opens a document with name `interfaceURI.pseudoPath` in sourcekitd. The caller is responsible
6881 /// for ensuring that the document will eventually get closed in sourcekitd again.
6982 private func generatedInterfaceInfo(
70- request: OpenGeneratedInterfaceRequest ,
83+ document: DocumentURI ,
84+ moduleName: String ,
85+ groupName: String ? ,
7186 interfaceURI: DocumentURI
7287 ) async throws -> GeneratedInterfaceInfo {
7388 let keys = self . keys
7489 let skreq = sourcekitd. dictionary ( [
7590 keys. request: requests. editorOpenInterface,
76- keys. moduleName: request . moduleName,
77- keys. groupName: request . groupName,
91+ keys. moduleName: moduleName,
92+ keys. groupName: groupName,
7893 keys. name: interfaceURI. pseudoPath,
7994 keys. synthesizedExtension: 1 ,
80- keys. compilerArgs: await self . buildSettings ( for: request . textDocument . uri ) ? . compilerArgs as [ SKDRequestValue ] ? ,
95+ keys. compilerArgs: await self . buildSettings ( for: document ) ? . compilerArgs as [ SKDRequestValue ] ? ,
8196 ] )
8297
8398 let dict = try await self . sourcekitd. send ( skreq, fileContents: nil )
8499 return GeneratedInterfaceInfo ( contents: dict [ keys. sourceText] ?? " " )
85100 }
86101
87102 private func generatedInterfaceDetails(
88- request: OpenGeneratedInterfaceRequest ,
89103 uri: DocumentURI ,
90104 snapshot: DocumentSnapshot ,
91105 symbol: String ?
0 commit comments