mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
Fix a race condition that could cause the build graph to not be generated when doing initial background indexing
We were making the initial `generateBuildGraph` call in `SourceKitLSPServer` from a `Task`. This means that `generateBuildGraph` could be executed after `waitForUpToDateBuildGraph` was called by `SemanticIndexManager`. Thus `waitForUpToDateBuildGraph` returned immediately and no files were background indexed. Make `generateBuildGraph` immediately schedule a package reload for SwiftPM build systems instead of doing the hop through a `Task`, fixing the race condition. rdar://135551812
This commit is contained in:
@@ -137,8 +137,10 @@ package protocol BuildSystem: AnyObject, Sendable {
|
||||
/// Return the list of targets and run destinations that the given document can be built for.
|
||||
func configuredTargets(for document: DocumentURI) async -> [ConfiguredTarget]
|
||||
|
||||
/// Re-generate the build graph.
|
||||
func generateBuildGraph() async throws
|
||||
/// Schedule a task that re-generates the build graph. The function may return before the build graph has finished
|
||||
/// being generated. If clients need to wait for an up-to-date build graph, they should call
|
||||
/// `waitForUpToDateBuildGraph` afterwards.
|
||||
func scheduleBuildGraphGeneration() async throws
|
||||
|
||||
/// Wait until the build graph has been loaded.
|
||||
func waitForUpToDateBuildGraph() async
|
||||
|
||||
Reference in New Issue
Block a user