Skip to content

Commit 1f6bfce

Browse files
authored
Merge pull request #1633 from ahoppen/remove-workarounds
Remove workarounds that are no longer needed
2 parents 5833322 + 189f32a commit 1f6bfce

File tree

4 files changed

+7
-32
lines changed

4 files changed

+7
-32
lines changed

Sources/BuildSystemIntegration/SwiftPMBuildSystem.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ package typealias SwiftBuildTarget = SourceKitLSPAPI.BuildTarget
5959
/// A build target in `BuildServerProtocol`
6060
package typealias BuildServerTarget = BuildServerProtocol.BuildTarget
6161

62-
/// Same as `toolchainRegistry.default`.
63-
///
64-
/// Needed to work around a compiler crash that prevents us from accessing `toolchainRegistry.preferredToolchain` in
65-
/// `SwiftPMWorkspace.init`.
66-
private func preferredToolchain(_ toolchainRegistry: ToolchainRegistry) async -> Toolchain? {
67-
return await toolchainRegistry.preferredToolchain(containing: [
68-
\.clang, \.clangd, \.sourcekitd, \.swift, \.swiftc,
69-
])
70-
}
71-
7262
fileprivate extension BuildDestination {
7363
/// A string that can be used to identify the build triple in `ConfiguredTarget.runDestinationID`.
7464
///
@@ -213,7 +203,10 @@ package actor SwiftPMBuildSystem {
213203
self.workspacePath = workspacePath
214204
self.options = options
215205
self.fileSystem = fileSystem
216-
guard let toolchain = await preferredToolchain(toolchainRegistry) else {
206+
let toolchain = await toolchainRegistry.preferredToolchain(containing: [
207+
\.clang, \.clangd, \.sourcekitd, \.swift, \.swiftc,
208+
])
209+
guard let toolchain else {
217210
throw Error.cannotDetermineHostToolchain
218211
}
219212

Sources/SourceKitLSP/Swift/SwiftLanguageService.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ package actor SwiftLanguageService: LanguageService, Sendable {
145145

146146
private var stateChangeHandlers: [(_ oldState: LanguageServerState, _ newState: LanguageServerState) -> Void] = []
147147

148-
private var diagnosticReportManager: DiagnosticReportManager!
148+
private let diagnosticReportManager: DiagnosticReportManager
149149

150150
/// - Note: Implicitly unwrapped optional so we can pass a reference of `self` to `MacroExpansionManager`.
151151
private(set) var macroExpansionManager: MacroExpansionManager!
@@ -168,14 +168,6 @@ package actor SwiftLanguageService: LanguageService, Sendable {
168168
/// request.
169169
private let refreshDiagnosticsDebouncer: Debouncer<Void>
170170

171-
/// Only exists to work around rdar://116221716.
172-
/// Once that is fixed, remove the property and make `diagnosticReportManager` non-optional.
173-
private var clientHasDiagnosticsCodeDescriptionSupport: Bool {
174-
get async {
175-
return await capabilityRegistry.clientHasDiagnosticsCodeDescriptionSupport
176-
}
177-
}
178-
179171
/// Creates a language server for the given client using the sourcekitd dylib specified in `toolchain`.
180172
/// `reopenDocuments` is a closure that will be called if sourcekitd crashes and the `SwiftLanguageService` asks its
181173
/// parent server to reopen all of its documents.
@@ -195,7 +187,6 @@ package actor SwiftLanguageService: LanguageService, Sendable {
195187
self.semanticIndexManager = workspace.semanticIndexManager
196188
self.testHooks = testHooks
197189
self.state = .connected
198-
self.diagnosticReportManager = nil // Needed to work around rdar://116221716
199190
self.options = options
200191

201192
// The debounce duration of 500ms was chosen arbitrarily without scientific research.

Sources/SourceKitLSP/WorkDoneProgressManager.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ actor WorkDoneProgressManager {
6060
/// The last status that was sent to the client. Used so we don't send no-op updates to the client.
6161
private var lastStatus: Status? = nil
6262

63-
/// Needed to work around rdar://116221716
64-
private static func getServerCapabilityRegistry(_ server: SourceKitLSPServer) async -> CapabilityRegistry? {
65-
return await server.capabilityRegistry
66-
}
67-
6863
init?(
6964
server: SourceKitLSPServer,
7065
tokenPrefix: String,
@@ -73,7 +68,7 @@ actor WorkDoneProgressManager {
7368
message: String? = nil,
7469
percentage: Int? = nil
7570
) async {
76-
guard let capabilityRegistry = await Self.getServerCapabilityRegistry(server) else {
71+
guard let capabilityRegistry = await server.capabilityRegistry else {
7772
return nil
7873
}
7974
self.init(

Tests/BuildSystemIntegrationTests/BuildSystemManagerTests.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,7 @@ private actor BSMDelegate: BuildSystemDelegate {
546546

547547
init(_ bsm: BuildSystemManager) async {
548548
self.bsm = bsm
549-
// Actor initializers can't directly leave their executor. Moving the call
550-
// of `bsm.setDelegate` into a closure works around that limitation. rdar://116221716
551-
await {
552-
await bsm.setDelegate(self)
553-
}()
549+
await bsm.setDelegate(self)
554550
}
555551

556552
func fileBuildSettingsChanged(_ changedFiles: Set<DocumentURI>) async {

0 commit comments

Comments
 (0)