Split determining which build system to use for a workspace and the workspace creation

This allows us to create the build system from a `BuiltInBuildSystemAdapter` when it receives an `InitializeRequest`, which will be done in a follow-up commit.
This commit is contained in:
Alex Hoppen
2024-08-23 16:59:07 -07:00
parent b490a6fef1
commit 6a9dcd2349
9 changed files with 218 additions and 168 deletions

View File

@@ -13,6 +13,7 @@
import BuildServerProtocol
import LanguageServerProtocol
import SKLogging
import SKOptions
import ToolchainRegistry
import struct TSCBasic.AbsolutePath
@@ -67,6 +68,13 @@ package struct PrepareNotSupportedError: Error, CustomStringConvertible {
/// For example, a SwiftPMWorkspace provides compiler arguments for the files
/// contained in a SwiftPM package root directory.
package protocol BuiltInBuildSystem: AnyObject, Sendable {
/// When opening an LSP workspace at `workspaceFolder`, determine the directory in which a project of this build system
/// starts. For example, a user might open the `Sources` folder of a SwiftPM project, then the project root is the
/// directory containing `Package.swift`.
///
/// Returns `nil` if the build system can't handle the given workspace folder
static func projectRoot(for workspaceFolder: AbsolutePath, options: SourceKitLSPOptions) -> AbsolutePath?
/// The root of the project that this build system manages. For example, for SwiftPM packages, this is the folder
/// containing Package.swift. For compilation databases it is the root folder based on which the compilation database
/// was found.