Query build system of workspaces to determine best workspace to open a file in

This sets the stage for multi-workspace support. Everything should be handled internally, we are just missing the API to actually open multiple workspaces at this point.
This commit is contained in:
Alex Hoppen
2022-04-29 14:33:59 +02:00
parent 437275e44a
commit f91564a75f
9 changed files with 101 additions and 6 deletions

View File

@@ -221,6 +221,26 @@ extension BuildServerBuildSystem: BuildSystem {
}
public func filesDidChange(_ events: [FileEvent]) {}
public func fileHandlingCapability(for uri: DocumentURI) -> FileHandlingCapability {
guard let fileUrl = uri.fileURL else {
return .unhandled
}
// FIXME: We should not make any assumptions about which files the build server can handle.
// Instead we should query the build server which files it can handle (#492).
let path = AbsolutePath(fileUrl.path)
if projectRoot.isAncestorOfOrEqual(to: path) {
return .handled
}
let realpath = resolveSymlinks(path)
if realpath != path, projectRoot.isAncestorOfOrEqual(to: realpath) {
return .handled
}
return .unhandled
}
}
private func loadBuildServerConfig(path: AbsolutePath, fileSystem: FileSystem) throws -> BuildServerConfig {