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:
Alex Hoppen
2024-09-09 11:49:54 -07:00
parent 33e955ab6c
commit 4d1fa7a7ee
9 changed files with 36 additions and 35 deletions

View File

@@ -133,7 +133,7 @@ extension CompilationDatabaseBuildSystem: BuildSystem {
throw PrepareNotSupportedError()
}
package func generateBuildGraph() {}
package func scheduleBuildGraphGeneration() {}
package func waitForUpToDateBuildGraph() async {}