@@ -392,6 +392,20 @@ package actor BuildSystemManager: QueueBasedMessageHandler {
392392 /// `pathComponents` is the result of `key.fileURL?.pathComponents`. We frequently need these path components to
393393 /// determine if a file is descendent of the directory and computing them from the `DocumentURI` is expensive.
394394 let directories : [ DocumentURI : ( pathComponents: [ String ] ? , info: SourceFileInfo ) ]
395+
396+ /// Same as `Set(files.filter(\.value.isBuildable).keys)`. Pre-computed because we need this pretty frequently in
397+ /// `SemanticIndexManager.filesToIndex`.
398+ let buildableSourceFiles : Set < DocumentURI >
399+
400+ internal init (
401+ files: [ DocumentURI : SourceFileInfo ] ,
402+ directories: [ DocumentURI : ( pathComponents: [ String ] ? , info: SourceFileInfo ) ]
403+ ) {
404+ self . files = files
405+ self . directories = directories
406+ self . buildableSourceFiles = Set ( files. filter ( \. value. isBuildable) . keys)
407+ }
408+
395409 }
396410
397411 private let cachedSourceFilesAndDirectories = Cache < SourceFilesAndDirectoriesKey , SourceFilesAndDirectories > ( )
@@ -1153,6 +1167,13 @@ package actor BuildSystemManager: QueueBasedMessageHandler {
11531167 }
11541168 }
11551169
1170+ /// Returns all source files in the project that are considered buildable.
1171+ ///
1172+ /// - SeeAlso: Comment in `sourceFilesAndDirectories` for a definition of what `buildable` means.
1173+ package func buildableSourceFiles( ) async throws -> Set < DocumentURI > {
1174+ return try await sourceFilesAndDirectories ( ) . buildableSourceFiles
1175+ }
1176+
11561177 /// Get all files and directories that are known to the build system, ie. that are returned by a `buildTarget/sources`
11571178 /// request for any target in the project.
11581179 ///
0 commit comments