Call into the BuildSystemManager from SwiftLanguageServer to get build settings

Instead of storing build settings inside the language servers based on update notifications from the build system, always call into the `BuildSystemManager` to get the build settings.

Overall, I think this is a much clearer separation of concerns and will allow us to remove `SourceKitServer.documentToPendingQueue` in a follow-up commit as `SwiftLanguageServer` can always directly call into `BuildSystemManager` to get build settings and we don’t need to wait for the initial notification to receive the first build settings.

This requies `BuildServerBuildSystem` to keep track of the build settings it has received from the BSP server.

`ClangLanguageServer` still caches build settings locally. `ClangLanguageServer` will change to the same pull-based model in a follow-up commit.
This commit is contained in:
Alex Hoppen
2023-09-21 19:51:38 -07:00
parent 42ec5bba74
commit 9dd38798bb
21 changed files with 221 additions and 137 deletions

View File

@@ -93,6 +93,15 @@ extension CompilationDatabaseBuildSystem: BuildSystem {
public var indexPrefixMappings: [PathPrefixMapping] { return [] }
public func buildSettings(for document: DocumentURI, language: Language) async throws -> FileBuildSettings? {
// FIXME: (async) Convert this to an async function once `CompilationDatabaseBuildSystem` is an actor.
return await withCheckedContinuation { continuation in
self.queue.async {
continuation.resume(returning: self.settings(for: document))
}
}
}
public func registerForChangeNotifications(for uri: DocumentURI, language: Language) {
queue.async {
self.watchedFiles[uri] = language