@@ -14,14 +14,19 @@ package import BuildServerProtocol
14
14
package import BuildSystemIntegration
15
15
package import Foundation
16
16
import LanguageServerProtocol
17
+ import SKLogging
17
18
18
19
package extension BuildSystemManager {
19
20
/// Retrieves the name of the Swift module for a given target.
20
21
///
21
22
/// - Parameter target: The build target identifier
22
23
/// - Returns: The name of the Swift module or nil if it could not be determined
23
24
func moduleName( for target: BuildTargetIdentifier ) async -> String ? {
24
- let sourceFiles = ( try ? await sourceFiles ( in: [ target] ) . flatMap ( \. sources) ) ?? [ ]
25
+ let sourceFiles =
26
+ await orLog (
27
+ " Failed to retreive source files from target \( target. uri) " ,
28
+ { try await self . sourceFiles ( in: [ target] ) . flatMap ( \. sources) }
29
+ ) ?? [ ]
25
30
for sourceFile in sourceFiles {
26
31
let language = await defaultLanguage ( for: sourceFile. uri, in: target)
27
32
guard language == . swift else {
@@ -39,7 +44,11 @@ package extension BuildSystemManager {
39
44
/// - Parameter target: The build target identifier
40
45
/// - Returns: The URL of the documentation catalog or nil if one could not be found
41
46
func doccCatalog( for target: BuildTargetIdentifier ) async -> URL ? {
42
- let sourceFiles = ( try ? await sourceFiles ( in: [ target] ) . flatMap ( \. sources) ) ?? [ ]
47
+ let sourceFiles =
48
+ await orLog (
49
+ " Failed to retreive source files from target \( target. uri) " ,
50
+ { try await self . sourceFiles ( in: [ target] ) . flatMap ( \. sources) }
51
+ ) ?? [ ]
43
52
let catalogURLs = sourceFiles. compactMap { sourceItem -> URL ? in
44
53
guard sourceItem. dataKind == . sourceKit,
45
54
let data = SourceKitSourceItemData ( fromLSPAny: sourceItem. data) ,
@@ -49,6 +58,9 @@ package extension BuildSystemManager {
49
58
}
50
59
return sourceItem. uri. fileURL
51
60
} . sorted ( by: { $0. absoluteString >= $1. absoluteString } )
61
+ if catalogURLs. count > 1 {
62
+ logger. error ( " Multiple SwiftDocC catalogs found in build target \( target. uri) " )
63
+ }
52
64
return catalogURLs. first
53
65
}
54
66
}
0 commit comments