mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
Add a BuildSystemDelegate which supports notifications for build settings changes
Introduce a `BuildSystemDelegate` to handle notifications from the build system
* `SourceKitServer` is the main delegate to process these notifications
* Currently limited to changes in `FileBuildSettings`
* Delegate informs the `BuildSystem` of files to watch via `registerChangeWatching(for: URL)` and `unregisterChangeWatching(for: URL)`
* In the future we could have more integration for handling changes in dependencies
Handling changes in `FileBuildSettings`
* `SourceKitServer` sends notifications to the internal LSPs informing them of any opened documents that have changes in their compiler flags
* For clangd, we send a notification to update the compilation database
* For SourceKit/sourcekitd we must close and reopen the file to force a new AST with the new compiler flags
This commit is contained in:
@@ -30,6 +30,9 @@ public final class BuildServerBuildSystem {
|
||||
var buildServer: Connection?
|
||||
public private(set) var indexStorePath: AbsolutePath?
|
||||
|
||||
/// Delegate to handle any build system events.
|
||||
public weak var delegate: BuildSystemDelegate? = nil
|
||||
|
||||
public init(projectRoot: AbsolutePath, buildFolder: AbsolutePath?, fileSystem: FileSystem = localFileSystem) throws {
|
||||
let configPath = projectRoot.appending(component: "buildServer.json")
|
||||
let config = try loadBuildServerConfig(path: configPath, fileSystem: fileSystem)
|
||||
@@ -116,6 +119,19 @@ final class BuildServerHandler: LanguageServerEndpoint {
|
||||
|
||||
extension BuildServerBuildSystem: BuildSystem {
|
||||
|
||||
/// Register the given file for build-system level change notifications, such as command
|
||||
/// line flag changes, dependency changes, etc.
|
||||
public func registerForChangeNotifications(for url: LanguageServerProtocol.URL) {
|
||||
// TODO: Implement via BSP extensions.
|
||||
}
|
||||
|
||||
/// Unregister the given file for build-system level change notifications, such as command
|
||||
/// line flag changes, dependency changes, etc.
|
||||
public func unregisterForChangeNotifications(for url: LanguageServerProtocol.URL) {
|
||||
// TODO: Implement via BSP extensions.
|
||||
}
|
||||
|
||||
|
||||
public var indexDatabasePath: AbsolutePath? {
|
||||
return buildFolder?.appending(components: "index", "db")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user