mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
Implement reloadPackageStatusCallback using BSP messages
This commit is contained in:
@@ -38,10 +38,7 @@ package actor CompilationDatabaseBuildSystem {
|
||||
}
|
||||
}
|
||||
|
||||
/// Callbacks that should be called if the list of possible test files has changed.
|
||||
package var testFilesDidChangeCallbacks: [() async -> Void] = []
|
||||
|
||||
package weak var messageHandler: BuiltInBuildSystemMessageHandler?
|
||||
package let connectionToSourceKitLSP: any Connection
|
||||
|
||||
package let projectRoot: AbsolutePath
|
||||
|
||||
@@ -72,13 +69,13 @@ package actor CompilationDatabaseBuildSystem {
|
||||
package init?(
|
||||
projectRoot: AbsolutePath,
|
||||
searchPaths: [RelativePath],
|
||||
messageHandler: (any BuiltInBuildSystemMessageHandler)?,
|
||||
connectionToSourceKitLSP: any Connection,
|
||||
fileSystem: FileSystem = localFileSystem
|
||||
) {
|
||||
self.fileSystem = fileSystem
|
||||
self.projectRoot = projectRoot
|
||||
self.searchPaths = searchPaths
|
||||
self.messageHandler = messageHandler
|
||||
self.connectionToSourceKitLSP = connectionToSourceKitLSP
|
||||
if let compdb = tryLoadCompilationDatabase(directory: projectRoot, additionalSearchPaths: searchPaths, fileSystem) {
|
||||
self.compdb = compdb
|
||||
} else {
|
||||
@@ -129,9 +126,9 @@ extension CompilationDatabaseBuildSystem: BuiltInBuildSystem {
|
||||
return BuildTargetSourcesResponse(items: [SourcesItem(target: .dummy, sources: sources)])
|
||||
}
|
||||
|
||||
package func didChangeWatchedFiles(notification: BuildServerProtocol.DidChangeWatchedFilesNotification) async {
|
||||
package func didChangeWatchedFiles(notification: BuildServerProtocol.DidChangeWatchedFilesNotification) {
|
||||
if notification.changes.contains(where: { self.fileEventShouldTriggerCompilationDatabaseReload(event: $0) }) {
|
||||
await self.reloadCompilationDatabase()
|
||||
self.reloadCompilationDatabase()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,16 +191,13 @@ extension CompilationDatabaseBuildSystem: BuiltInBuildSystem {
|
||||
|
||||
/// The compilation database has been changed on disk.
|
||||
/// Reload it and notify the delegate about build setting changes.
|
||||
private func reloadCompilationDatabase() async {
|
||||
private func reloadCompilationDatabase() {
|
||||
self.compdb = tryLoadCompilationDatabase(
|
||||
directory: projectRoot,
|
||||
additionalSearchPaths: searchPaths,
|
||||
self.fileSystem
|
||||
)
|
||||
|
||||
await messageHandler?.sendNotificationToSourceKitLSP(DidChangeBuildTargetNotification(changes: nil))
|
||||
for testFilesDidChangeCallback in testFilesDidChangeCallbacks {
|
||||
await testFilesDidChangeCallback()
|
||||
}
|
||||
connectionToSourceKitLSP.send(DidChangeBuildTargetNotification(changes: nil))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user