diff --git a/Sources/SKCore/BuildSystem.swift b/Sources/SKCore/BuildSystem.swift index 05434701..0e693c5c 100644 --- a/Sources/SKCore/BuildSystem.swift +++ b/Sources/SKCore/BuildSystem.swift @@ -11,35 +11,26 @@ //===----------------------------------------------------------------------===// import LanguageServerProtocol +import Basic -/// Provider of build settings. -public protocol BuildSettingsProvider { +/// Provider of FileBuildSettings and other build-related information. +/// +/// The primary role of the build system is to answer queries for FileBuildSettings and (TODO) to +/// notify clients when they change. The BuildSystem is also the source of related informatino, +/// such as where the index datastore is located. +/// +/// For example, a SwiftPMWorkspace provides compiler arguments for the files contained in a +/// SwiftPM package root directory. +public protocol BuildSystem { + + /// The path to the raw index store data, if any. + var indexStorePath: AbsolutePath? { get } + + /// The path to put the index database, if any. + var indexDatabasePath: AbsolutePath? { get } /// Returns the settings for the given url and language mode, if known. - func settings(for: URL, language: Language) -> FileBuildSettings? + func settings(for: URL, _ language: Language) -> FileBuildSettings? // TODO: notifications when settings change. } - -/// Build settings for a single file. -public struct FileBuildSettings { - - /// The identifier of the toolchain that is preferred for compiling this file, if any. - public var preferredToolchain: String? = nil - - /// The compiler arguments to use for this file. - public var compilerArguments: [String] - - /// The working directory to resolve any relative paths in `compilerArguments`. - public var workingDirectory: String? = nil - - public init( - preferredToolchain: String? = nil, - compilerArguments: [String], - workingDirectory: String? = nil - ) { - self.preferredToolchain = preferredToolchain - self.compilerArguments = compilerArguments - self.workingDirectory = workingDirectory - } -} diff --git a/Sources/SKCore/BuildSettingsProviderList.swift b/Sources/SKCore/BuildSystemList.swift similarity index 52% rename from Sources/SKCore/BuildSettingsProviderList.swift rename to Sources/SKCore/BuildSystemList.swift index 6503d9f6..6c8c9ec0 100644 --- a/Sources/SKCore/BuildSettingsProviderList.swift +++ b/Sources/SKCore/BuildSystemList.swift @@ -10,21 +10,29 @@ // //===----------------------------------------------------------------------===// +import Basic import LanguageServerProtocol -/// Provides build settings from a list of providers in priority order. -public final class BuildSettingsProviderList: BuildSettingsProvider { +/// Provides build settings from a list of build systems in priority order. +public final class BuildSystemList { - /// The build settings providers to try (in order). - public var providers: [BuildSettingsProvider] = [ - FallbackBuildSettingsProvider() + /// The build systems to try (in order). + public var providers: [BuildSystem] = [ + FallbackBuildSystem() ] public init() {} +} - public func settings(for url: URL, language: Language) -> FileBuildSettings? { +extension BuildSystemList: BuildSystem { + + public var indexStorePath: AbsolutePath? { return providers.first?.indexStorePath } + + public var indexDatabasePath: AbsolutePath? { return providers.first?.indexDatabasePath } + + public func settings(for url: URL, _ language: Language) -> FileBuildSettings? { for provider in providers { - if let settings = provider.settings(for: url, language: language) { + if let settings = provider.settings(for: url, language) { return settings } } diff --git a/Sources/SKCore/CompilationDatabaseBuildSystem.swift b/Sources/SKCore/CompilationDatabaseBuildSystem.swift index 4960bcb7..03073788 100644 --- a/Sources/SKCore/CompilationDatabaseBuildSystem.swift +++ b/Sources/SKCore/CompilationDatabaseBuildSystem.swift @@ -18,7 +18,7 @@ import LanguageServerProtocol /// /// Provides build settings from a `CompilationDatabase` found by searching a project. For now, only /// one compilation database, located at the project root. -public final class CompilationDatabaseBuildSystem: BuildSettingsProvider { +public final class CompilationDatabaseBuildSystem { /// The compilation database. var compdb: CompilationDatabase? = nil @@ -31,8 +31,15 @@ public final class CompilationDatabaseBuildSystem: BuildSettingsProvider { self.compdb = tryLoadCompilationDatabase(directory: path, fileSystem) } } +} - public func settings(for url: URL, language: Language) -> FileBuildSettings? { +extension CompilationDatabaseBuildSystem: BuildSystem { + + // FIXME: derive from the compiler arguments. + public var indexStorePath: AbsolutePath? { return nil } + public var indexDatabasePath: AbsolutePath? { return nil } + + public func settings(for url: URL, _ language: Language) -> FileBuildSettings? { guard let db = database(for: url), let cmd = db[url].first else { return nil } return FileBuildSettings( diff --git a/Sources/SKCore/ExternalWorkspace.swift b/Sources/SKCore/ExternalWorkspace.swift deleted file mode 100644 index 86561b03..00000000 --- a/Sources/SKCore/ExternalWorkspace.swift +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import Basic - -/// Connection to an external workspace/project, providing access to settings, etc. -/// -/// For example, a swiftpm package loaded from disk can provide command-line arguments for the files -/// contained in its package root directory. -public protocol ExternalWorkspace { - - /// The build system, providing access to compiler arguments. - var buildSystem: BuildSettingsProvider { get } - - /// The path to the raw index store data, if any. - var indexStorePath: AbsolutePath? { get } - - /// The path to put the index database, if any. - var indexDatabasePath: AbsolutePath? { get } -} diff --git a/Sources/SKCore/FallbackBuildSettingsProvider.swift b/Sources/SKCore/FallbackBuildSystem.swift similarity index 61% rename from Sources/SKCore/FallbackBuildSettingsProvider.swift rename to Sources/SKCore/FallbackBuildSystem.swift index 412afde4..1e838e8e 100644 --- a/Sources/SKCore/FallbackBuildSettingsProvider.swift +++ b/Sources/SKCore/FallbackBuildSystem.swift @@ -14,34 +14,41 @@ import LanguageServerProtocol import Basic import enum Utility.Platform -/// A simple build settings provider suitable as a fallback when accurate settings are unknown. -public final class FallbackBuildSettingsProvider: BuildSettingsProvider { +/// A simple BuildSystem suitable as a fallback when accurate settings are unknown. +public final class FallbackBuildSystem: BuildSystem { + /// The path to the SDK. lazy var sdkpath: AbsolutePath? = { - if case .darwin? = Platform.currentPlatform { - if let str = try? Process.checkNonZeroExit(args: "/usr/bin/xcrun", "--show-sdk-path", "--sdk", "macosx"), let path = try? AbsolutePath(validating: str.spm_chomp()) { - return path - } + if case .darwin? = Platform.currentPlatform, + let str = try? Process.checkNonZeroExit( + args: "/usr/bin/xcrun", "--show-sdk-path", "--sdk", "macosx"), + let path = try? AbsolutePath(validating: str.spm_chomp()) + { + return path } return nil }() - public func settings(for url: URL, language: Language) -> FileBuildSettings? { + public var indexStorePath: AbsolutePath? { return nil } + + public var indexDatabasePath: AbsolutePath? { return nil } + + public func settings(for url: URL, _ language: Language) -> FileBuildSettings? { guard let path = try? AbsolutePath(validating: url.path) else { return nil } switch language { case .swift: - return settingsSwift(path: path) + return settingsSwift(path) case .c, .cpp, .objective_c, .objective_cpp: - return settingsClang(path: path, language: language) + return settingsClang(path, language) default: return nil } } - func settingsSwift(path: AbsolutePath) -> FileBuildSettings { + func settingsSwift(_ path: AbsolutePath) -> FileBuildSettings { var args: [String] = [] if let sdkpath = sdkpath { args += [ @@ -53,7 +60,7 @@ public final class FallbackBuildSettingsProvider: BuildSettingsProvider { return FileBuildSettings(preferredToolchain: nil, compilerArguments: args) } - func settingsClang(path: AbsolutePath, language: Language) -> FileBuildSettings { + func settingsClang(_ path: AbsolutePath, _ language: Language) -> FileBuildSettings { var args: [String] = [] if let sdkpath = sdkpath { args += [ diff --git a/Sources/SKCore/FileBuildSettings.swift b/Sources/SKCore/FileBuildSettings.swift new file mode 100644 index 00000000..b04482e7 --- /dev/null +++ b/Sources/SKCore/FileBuildSettings.swift @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +/// Build settings for a single file. +/// +/// Encapsulates all the settings needed to compile a single file, including the compiler arguments, +/// working directory, and preferred toolchain if any. FileBuildSettings are typically the result +/// of a BuildSystem query. +public struct FileBuildSettings { + + /// The identifier of the toolchain that is preferred for compiling this file, if any. + public var preferredToolchain: String? = nil + + /// The compiler arguments to use for this file. + public var compilerArguments: [String] + + /// The working directory to resolve any relative paths in `compilerArguments`. + public var workingDirectory: String? = nil + + public init( + preferredToolchain: String? = nil, + compilerArguments: [String], + workingDirectory: String? = nil) + { + self.preferredToolchain = preferredToolchain + self.compilerArguments = compilerArguments + self.workingDirectory = workingDirectory + } +} diff --git a/Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift b/Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift index 48d8ccfa..1a27502c 100644 --- a/Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift +++ b/Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift @@ -40,7 +40,7 @@ public final class SwiftPMWorkspace { var fileToTarget: [AbsolutePath: TargetBuildDescription] = [:] var sourceDirToTarget: [AbsolutePath: TargetBuildDescription] = [:] - /// Creates a `BuildSettingsProvider` using the Swift Package Manager, if this workspace is part of a package. + /// Creates a `BuildSystem` using the Swift Package Manager, if this workspace is part of a package. /// /// - returns: nil if `workspacePath` is not part of a package or there is an error. public convenience init?(url: LanguageServerProtocol.URL, toolchainRegistry: ToolchainRegistry) { @@ -52,7 +52,7 @@ public final class SwiftPMWorkspace { } } - /// Creates a `BuildSettingsProvider` using the Swift Package Manager, if this workspace is part of a package. + /// Creates a `BuildSystem` using the Swift Package Manager, if this workspace is part of a package. /// /// - returns: nil if `workspacePath` is not part of a package. /// - throws: If there is an error loading the package. @@ -163,9 +163,7 @@ public final class SwiftPMWorkspace { } } -extension SwiftPMWorkspace: ExternalWorkspace, BuildSettingsProvider { - - public var buildSystem: BuildSettingsProvider { return self } +extension SwiftPMWorkspace: BuildSystem { public var buildPath: AbsolutePath { return buildParameters.buildPath @@ -179,13 +177,16 @@ extension SwiftPMWorkspace: ExternalWorkspace, BuildSettingsProvider { return buildPath.appending(components: "index", "db") } - public func settings(for url: LanguageServerProtocol.URL, language: Language) -> FileBuildSettings? { + public func settings( + for url: LanguageServerProtocol.URL, + _ language: Language) -> FileBuildSettings? + { guard let path = try? AbsolutePath(validating: url.path) else { return nil } if let td = self.fileToTarget[path] { - return settings(for: path, language: language, targetDescription: td) + return settings(for: path, language, td) } if path.basename == "Package.swift" { @@ -193,7 +194,7 @@ extension SwiftPMWorkspace: ExternalWorkspace, BuildSettingsProvider { } if path.extension == "h" { - return settings(forHeader: path, language: language) + return settings(forHeader: path, language) } return nil @@ -206,8 +207,8 @@ extension SwiftPMWorkspace { public func settings( for path: AbsolutePath, - language: Language, - targetDescription td: TargetBuildDescription + _ language: Language, + _ td: TargetBuildDescription ) -> FileBuildSettings? { let buildPath = self.buildPath @@ -315,11 +316,11 @@ extension SwiftPMWorkspace { return nil } - public func settings(forHeader path: AbsolutePath, language: Language) -> FileBuildSettings? { + public func settings(forHeader path: AbsolutePath, _ language: Language) -> FileBuildSettings? { var dir = path.parentDirectory while !dir.isRoot { if let td = sourceDirToTarget[dir] { - return settings(for: path, language: language, targetDescription: td) + return settings(for: path, language, td) } dir = dir.parentDirectory } diff --git a/Sources/SourceKit/SourceKitServer.swift b/Sources/SourceKit/SourceKitServer.swift index af8edea7..31773e49 100644 --- a/Sources/SourceKit/SourceKitServer.swift +++ b/Sources/SourceKit/SourceKitServer.swift @@ -118,8 +118,8 @@ public final class SourceKitServer: LanguageServer { client.send(note.params) } - func toolchain(for url: URL, language: Language) -> Toolchain? { - if let id = workspace?.buildSettings.settings(for: url, language: language)?.preferredToolchain, + func toolchain(for url: URL, _ language: Language) -> Toolchain? { + if let id = workspace?.buildSettings.settings(for: url, language)?.preferredToolchain, let toolchain = toolchainRegistry.toolchain(identifier:id) { return toolchain @@ -150,7 +150,7 @@ public final class SourceKitServer: LanguageServer { return nil } - func languageService(for toolchain: Toolchain, language: Language) -> Connection? { + func languageService(for toolchain: Toolchain, _ language: Language) -> Connection? { let key = LanguageServiceKey(toolchain: toolchain.identifier, language: language) if let service = languageService[key] { return service @@ -158,7 +158,7 @@ public final class SourceKitServer: LanguageServer { // Start a new service. return orLog("failed to start language service", level: .error) { - guard let service = try SourceKit.languageService(for: toolchain, language: language, client: self) else { + guard let service = try SourceKit.languageService(for: toolchain, language, client: self) else { return nil } @@ -183,12 +183,14 @@ public final class SourceKitServer: LanguageServer { } } - func languageService(for url: URL, language: Language, workspace: Workspace) -> Connection? { + func languageService(for url: URL, _ language: Language, in workspace: Workspace) -> Connection? { if let service = workspace.documentService[url] { return service } - guard let toolchain = toolchain(for: url, language: language), let service = languageService(for: toolchain, language: language) else { + guard let toolchain = toolchain(for: url, language), + let service = languageService(for: toolchain, language) + else { return nil } @@ -226,8 +228,7 @@ extension SourceKitServer { self.workspace = Workspace( rootPath: nil, clientCapabilities: req.params.capabilities, - external: nil, - buildSettings: BuildSettingsProviderList(), + buildSettings: BuildSystemList(), index: nil ) } @@ -274,7 +275,7 @@ extension SourceKitServer { func openDocument(_ note: Notification, workspace: Workspace) { workspace.documentManager.open(note) - if let service = languageService(for: note.params.textDocument.url, language: note.params.textDocument.language, workspace: workspace) { + if let service = languageService(for: note.params.textDocument.url, note.params.textDocument.language, in: workspace) { service.send(note.params) } } @@ -448,11 +449,16 @@ extension SourceKitServer { } } -/// Creates a new connection from `client` to a service for `language` if available, and launches the service. Does *not* send the initialization request. +/// Creates a new connection from `client` to a service for `language` if available, and launches +/// the service. Does *not* send the initialization request. /// /// - returns: The connection, if a suitable language service is available; otherwise nil. /// - throws: If there is a suitable service but it fails to launch, throws an error. -public func languageService(for toolchain: Toolchain, language: Language, client: MessageHandler) throws -> Connection? { +public func languageService( + for toolchain: Toolchain, + _ language: Language, + client: MessageHandler) throws -> Connection? +{ switch language { case .c, .cpp, .objective_c, .objective_cpp: diff --git a/Sources/SourceKit/Workspace.swift b/Sources/SourceKit/Workspace.swift index c0409c16..237c245f 100644 --- a/Sources/SourceKit/Workspace.swift +++ b/Sources/SourceKit/Workspace.swift @@ -23,9 +23,7 @@ import SKSwiftPMWorkspace /// In LSP, this represents the per-workspace state that is typically only available after the /// "initialize" request has been made. /// -/// Typically a workspace is contained in a root directory, and may be represented by an -/// `ExternalWorkspace` if this workspace is part of a workspace in another tool such as a swiftpm -/// package. +/// Typically a workspace is contained in a root directory. public final class Workspace { /// The root directory of the workspace. @@ -33,14 +31,8 @@ public final class Workspace { public let clientCapabilities: ClientCapabilities - /// The external workspace connection, if any. - public let external: ExternalWorkspace? - /// The build settings provider to use for documents in this workspace. - /// - /// If `external` is not `nil`, this will typically include `external.buildSystem`. It may also - /// provide settings for files outside the workspace using additional providers. - public let buildSettings: BuildSettingsProvider + public let buildSettings: BuildSystem /// The source code index, if available. public var index: IndexStoreDB? = nil @@ -54,13 +46,11 @@ public final class Workspace { public init( rootPath: AbsolutePath?, clientCapabilities: ClientCapabilities, - external: ExternalWorkspace?, - buildSettings: BuildSettingsProvider, + buildSettings: BuildSystem, index: IndexStoreDB?) { self.rootPath = rootPath self.clientCapabilities = clientCapabilities - self.external = external self.buildSettings = buildSettings self.index = index } @@ -79,21 +69,17 @@ public final class Workspace { self.rootPath = try AbsolutePath(validating: url.path) self.clientCapabilities = clientCapabilities - self.external = SwiftPMWorkspace(url: url, toolchainRegistry: toolchainRegistry) - - let settings = BuildSettingsProviderList() + let settings = BuildSystemList() self.buildSettings = settings settings.providers.insert(CompilationDatabaseBuildSystem(projectRoot: rootPath), at: 0) - guard let external = self.external else { - return + if let swiftpm = SwiftPMWorkspace(url: url, toolchainRegistry: toolchainRegistry) { + settings.providers.insert(swiftpm, at: 0) } - settings.providers.insert(external.buildSystem, at: 0) - - if let storePath = external.indexStorePath, - let dbPath = external.indexDatabasePath, + if let storePath = buildSettings.indexStorePath, + let dbPath = buildSettings.indexDatabasePath, let libPath = toolchainRegistry.default?.libIndexStore { do { diff --git a/Sources/SourceKit/clangd/ClangLanguageServer.swift b/Sources/SourceKit/clangd/ClangLanguageServer.swift index b16f05de..5efae901 100644 --- a/Sources/SourceKit/clangd/ClangLanguageServer.swift +++ b/Sources/SourceKit/clangd/ClangLanguageServer.swift @@ -22,13 +22,13 @@ final class ClangLanguageServerShim: LanguageServer { let clangd: Connection - let buildSettingsProvider: BuildSettingsProvider + let buildSystem: BuildSystem /// Creates a language server for the given client using the sourcekitd dylib at the specified path. - public init(client: Connection, clangd: Connection, buildSettingsProvider: BuildSettingsProvider) throws { + public init(client: Connection, clangd: Connection, buildSystem: BuildSystem) throws { self.clangd = clangd - self.buildSettingsProvider = buildSettingsProvider + self.buildSystem = buildSystem super.init(client: client) } @@ -65,7 +65,7 @@ final class ClangLanguageServerShim: LanguageServer { func openDocument(_ note: Notification) { let url = note.params.textDocument.url - let settings = buildSettingsProvider.settings(for: url, language: note.params.textDocument.language) + let settings = buildSystem.settings(for: url, note.params.textDocument.language) logAsync(level: settings == nil ? .warning : .debug) { _ in let settingsStr = settings == nil ? "nil" : settings!.compilerArguments.description @@ -82,7 +82,7 @@ final class ClangLanguageServerShim: LanguageServer { } } -func makeJSONRPCClangServer(client: MessageHandler, clangd: AbsolutePath, buildSettings: BuildSettingsProvider?) throws -> Connection { +func makeJSONRPCClangServer(client: MessageHandler, clangd: AbsolutePath, buildSettings: BuildSystem?) throws -> Connection { let clientToServer: Pipe = Pipe() let serverToClient: Pipe = Pipe() @@ -98,7 +98,7 @@ func makeJSONRPCClangServer(client: MessageHandler, clangd: AbsolutePath, buildS let shim = try ClangLanguageServerShim( client: connectionToClient, clangd: connection, - buildSettingsProvider: buildSettings ?? BuildSettingsProviderList() + buildSystem: buildSettings ?? BuildSystemList() ) connectionToShim.start(handler: shim) diff --git a/Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift b/Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift index 24355dfe..c568f01e 100644 --- a/Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift +++ b/Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift @@ -21,7 +21,7 @@ public final class SwiftLanguageServer: LanguageServer { let sourcekitd: SwiftSourceKitFramework - let buildSettingsProvider: BuildSettingsProvider + let buildSystem: BuildSystem // FIXME: ideally we wouldn't need separate management from a parent server in the same process. var documentManager: DocumentManager @@ -34,10 +34,10 @@ public final class SwiftLanguageServer: LanguageServer { var values: sourcekitd_values { return sourcekitd.values } /// Creates a language server for the given client using the sourcekitd dylib at the specified path. - public init(client: Connection, sourcekitd: AbsolutePath, buildSettingsProvider: BuildSettingsProvider, onExit: @escaping () -> () = {}) throws { + public init(client: Connection, sourcekitd: AbsolutePath, buildSystem: BuildSystem, onExit: @escaping () -> () = {}) throws { self.sourcekitd = try SwiftSourceKitFramework(dylib: sourcekitd) - self.buildSettingsProvider = buildSettingsProvider + self.buildSystem = buildSystem self.documentManager = DocumentManager() self.onExit = onExit super.init(client: client) @@ -220,7 +220,7 @@ extension SwiftLanguageServer { req[keys.name] = note.params.textDocument.url.path req[keys.sourcetext] = snapshot.text - if let settings = buildSettingsProvider.settings(for: snapshot.document.url, language: snapshot.document.language) { + if let settings = buildSystem.settings(for: snapshot.document.url, snapshot.document.language) { req[keys.compilerargs] = settings.compilerArguments } @@ -308,7 +308,7 @@ extension SwiftLanguageServer { skreq[keys.sourcefile] = snapshot.document.url.path skreq[keys.sourcetext] = snapshot.text - if let settings = buildSettingsProvider.settings(for: snapshot.document.url, language: snapshot.document.language) { + if let settings = buildSystem.settings(for: snapshot.document.url, snapshot.document.language) { skreq[keys.compilerargs] = settings.compilerArguments } @@ -432,7 +432,7 @@ extension SwiftLanguageServer { skreq[keys.sourcefile] = snapshot.document.url.path // FIXME: should come from the internal document - if let settings = buildSettingsProvider.settings(for: snapshot.document.url, language: snapshot.document.language) { + if let settings = buildSystem.settings(for: snapshot.document.url, snapshot.document.language) { skreq[keys.compilerargs] = settings.compilerArguments } @@ -510,7 +510,7 @@ extension SwiftLanguageServer { skreq[keys.sourcefile] = snapshot.document.url.path // FIXME: should come from the internal document - if let settings = buildSettingsProvider.settings(for: snapshot.document.url, language: snapshot.document.language) { + if let settings = buildSystem.settings(for: snapshot.document.url, snapshot.document.language) { skreq[keys.compilerargs] = settings.compilerArguments } @@ -568,7 +568,7 @@ extension DocumentSnapshot { } } -func makeLocalSwiftServer(client: MessageHandler, sourcekitd: AbsolutePath, buildSettings: BuildSettingsProvider?) throws -> Connection { +func makeLocalSwiftServer(client: MessageHandler, sourcekitd: AbsolutePath, buildSettings: BuildSystem?) throws -> Connection { let connectionToSK = LocalConnection() let connectionToClient = LocalConnection() @@ -576,7 +576,7 @@ func makeLocalSwiftServer(client: MessageHandler, sourcekitd: AbsolutePath, buil let server = try SwiftLanguageServer( client: connectionToClient, sourcekitd: sourcekitd, - buildSettingsProvider: buildSettings ?? BuildSettingsProviderList() + buildSystem: buildSettings ?? BuildSystemList() ) connectionToSK.start(handler: server) diff --git a/Tests/SKCoreTests/CompilationDatabaseTests.swift b/Tests/SKCoreTests/CompilationDatabaseTests.swift index 44e015ec..5aafcac3 100644 --- a/Tests/SKCoreTests/CompilationDatabaseTests.swift +++ b/Tests/SKCoreTests/CompilationDatabaseTests.swift @@ -197,10 +197,10 @@ final class CompilationDatabaseTests: XCTestCase { ] """) - let buildSystem: BuildSettingsProvider = CompilationDatabaseBuildSystem( + let buildSystem: BuildSystem = CompilationDatabaseBuildSystem( projectRoot: AbsolutePath("/a"), fileSystem: fs) - let settings = buildSystem.settings(for: URL(fileURLWithPath: "/a/a.swift"), language: .swift) + let settings = buildSystem.settings(for: URL(fileURLWithPath: "/a/a.swift"), .swift) XCTAssertNotNil(settings) XCTAssertEqual(settings?.workingDirectory, "/a") XCTAssertEqual(settings?.compilerArguments, ["-swift-version", "4", "/a/a.swift"]) diff --git a/Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift b/Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift index 1e8691e8..a0e001a9 100644 --- a/Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift +++ b/Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift @@ -42,7 +42,7 @@ final class SwiftPMWorkspaceTests: XCTestCase { XCTAssertEqual(ws.buildPath, packageRoot.appending(components: ".build", "debug")) XCTAssertNotNil(ws.indexStorePath) - let arguments = ws.settings(for: aswift.asURL, language: .swift)!.compilerArguments + let arguments = ws.settings(for: aswift.asURL, .swift)!.compilerArguments check( "-module-name", "lib", "-incremental", "-emit-dependencies", @@ -87,10 +87,10 @@ final class SwiftPMWorkspaceTests: XCTestCase { let aswift = packageRoot.appending(components: "Sources", "lib", "a.swift") let bswift = packageRoot.appending(components: "Sources", "lib", "b.swift") - let argumentsA = ws.settings(for: aswift.asURL, language: .swift)!.compilerArguments + let argumentsA = ws.settings(for: aswift.asURL, .swift)!.compilerArguments check(aswift.asString, arguments: argumentsA) check(bswift.asString, arguments: argumentsA) - let argumentsB = ws.settings(for: aswift.asURL, language: .swift)!.compilerArguments + let argumentsB = ws.settings(for: aswift.asURL, .swift)!.compilerArguments check(aswift.asString, arguments: argumentsB) check(bswift.asString, arguments: argumentsB) } @@ -124,12 +124,12 @@ final class SwiftPMWorkspaceTests: XCTestCase { let aswift = packageRoot.appending(components: "Sources", "libA", "a.swift") let bswift = packageRoot.appending(components: "Sources", "libB", "b.swift") - let arguments = ws.settings(for: aswift.asURL, language: .swift)!.compilerArguments + let arguments = ws.settings(for: aswift.asURL, .swift)!.compilerArguments check(aswift.asString, arguments: arguments) checkNot(bswift.asString, arguments: arguments) check("-I", packageRoot.appending(components: "Sources", "libC", "include").asString, arguments: arguments) - let argumentsB = ws.settings(for: bswift.asURL, language: .swift)!.compilerArguments + let argumentsB = ws.settings(for: bswift.asURL, .swift)!.compilerArguments check(bswift.asString, arguments: argumentsB) checkNot(aswift.asString, arguments: argumentsB) checkNot("-I", packageRoot.appending(components: "Sources", "libC", "include").asString, arguments: argumentsB) @@ -164,7 +164,7 @@ final class SwiftPMWorkspaceTests: XCTestCase { XCTAssertEqual(ws.buildPath, build) XCTAssertNotNil(ws.indexStorePath) - let arguments = ws.settings(for: acxx.asURL, language: .cpp)!.compilerArguments + let arguments = ws.settings(for: acxx.asURL, .cpp)!.compilerArguments check("-MD", "-MT", "dependencies", "-MF", build.appending(components: "lib.build", "a.cpp.d").asString, @@ -210,7 +210,7 @@ final class SwiftPMWorkspaceTests: XCTestCase { fileSystem: fs)! let aswift = packageRoot.appending(components: "Sources", "lib", "a.swift") - let arguments = ws.settings(for: aswift.asURL, language: .swift)!.compilerArguments + let arguments = ws.settings(for: aswift.asURL, .swift)!.compilerArguments check("-target", arguments: arguments) // Only one! #if os(macOS) check("-target", "x86_64-apple-macosx10.13", arguments: arguments)