Skip to content

Commit 1fb087f

Browse files
authored
Merge pull request #1292 from ahoppen/sourcekitlsp-in-swift-6-mode
Make the `SourceKitLSP` module build in Swift 6 mode
2 parents 0f097e6 + 7e7df04 commit 1fb087f

31 files changed

+232
-157
lines changed

Sources/LSPLogging/Logging.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ public typealias LogLevel = os.OSLogType
2828
public typealias Logger = os.Logger
2929
public typealias Signposter = OSSignposter
3030

31+
#if compiler(<5.11)
32+
extension OSSignposter: @unchecked Sendable {}
33+
extension OSSignpostID: @unchecked Sendable {}
34+
extension OSSignpostIntervalState: @unchecked Sendable {}
35+
#else
36+
extension OSSignposter: @retroactive @unchecked Sendable {}
37+
extension OSSignpostID: @retroactive @unchecked Sendable {}
38+
extension OSSignpostIntervalState: @retroactive @unchecked Sendable {}
39+
#endif
40+
3141
extension os.Logger {
3242
public func makeSignposter() -> Signposter {
3343
return OSSignposter(logger: self)

Sources/LSPLogging/LoggingScope.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public func withLoggingScope<Result>(
8080
/// - SeeAlso: ``withLoggingScope(_:_:)-6qtga``
8181
public func withLoggingScope<Result>(
8282
_ scope: String,
83-
_ operation: () async throws -> Result
83+
@_inheritActorContext _ operation: @Sendable () async throws -> Result
8484
) async rethrows -> Result {
8585
return try await LoggingScope.$_scope.withValue(
8686
scope,

Sources/LSPLogging/NonDarwinLogging.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,14 @@ public struct NonDarwinLogger: Sendable {
361361

362362
// MARK: - Signposter
363363

364-
public struct NonDarwinSignpostID {}
364+
public struct NonDarwinSignpostID: Sendable {}
365365

366-
public struct NonDarwinSignpostIntervalState {}
366+
public struct NonDarwinSignpostIntervalState: Sendable {}
367367

368368
/// A type that is API-compatible to `OSLogMessage` for all uses within sourcekit-lsp.
369369
///
370370
/// Since non-Darwin platforms don't have signposts, the type just has no-op operations.
371-
public struct NonDarwinSignposter {
371+
public struct NonDarwinSignposter: Sendable {
372372
public func makeSignpostID() -> NonDarwinSignpostID {
373373
return NonDarwinSignpostID()
374374
}

Sources/LanguageServerProtocol/Connection.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public protocol MessageHandler: AnyObject, Sendable {
4444
func handle<Request: RequestType>(
4545
_ request: Request,
4646
id: RequestID,
47-
reply: @escaping (LSPResult<Request.Response>) -> Void
47+
reply: @Sendable @escaping (LSPResult<Request.Response>) -> Void
4848
)
4949
}
5050

@@ -110,7 +110,7 @@ public final class LocalConnection: Connection, @unchecked Sendable {
110110

111111
public func send<Request: RequestType>(
112112
_ request: Request,
113-
reply: @escaping (LSPResult<Request.Response>) -> Void
113+
reply: @Sendable @escaping (LSPResult<Request.Response>) -> Void
114114
) -> RequestID {
115115
let id = nextRequestID()
116116

Sources/LanguageServerProtocol/Message.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public protocol _RequestType: MessageType {
2424
func _handle(
2525
_ handler: MessageHandler,
2626
id: RequestID,
27-
reply: @escaping (LSPResult<ResponseType>, RequestID) -> Void
27+
reply: @Sendable @escaping (LSPResult<ResponseType>, RequestID) -> Void
2828
)
2929
}
3030

@@ -49,7 +49,7 @@ extension RequestType {
4949
public func _handle(
5050
_ handler: MessageHandler,
5151
id: RequestID,
52-
reply: @escaping (LSPResult<ResponseType>, RequestID) -> Void
52+
reply: @Sendable @escaping (LSPResult<ResponseType>, RequestID) -> Void
5353
) {
5454
handler.handle(self, id: id) { response in
5555
reply(response.map({ $0 as ResponseType }), id)

Sources/LanguageServerProtocol/Requests/CodeActionRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
public typealias CodeActionProvider = (CodeActionRequest) async throws -> [CodeAction]
13+
public typealias CodeActionProvider = @Sendable (CodeActionRequest) async throws -> [CodeAction]
1414

1515
/// Request for returning all possible code actions for a given text document and range.
1616
///

Sources/LanguageServerProtocol/SupportTypes/ServerCapabilities.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ public struct DocumentRangeFormattingOptions: WorkDoneProgressOptions, Codable,
587587
}
588588
}
589589

590-
public struct FoldingRangeOptions: Codable, Hashable {
590+
public struct FoldingRangeOptions: Codable, Hashable, Sendable {
591591
/// Currently empty in the spec.
592592
public init() {}
593593
}

Sources/SKCore/BuildSystemManager.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import LanguageServerProtocol
1717

1818
import struct TSCBasic.AbsolutePath
1919

20+
#if canImport(os)
21+
import os
22+
#endif
23+
2024
/// `BuildSystem` that integrates client-side information such as main-file lookup as well as providing
2125
/// common functionality such as caching.
2226
///
@@ -169,7 +173,7 @@ extension BuildSystemManager {
169173
logger.error("Getting build settings failed: \(error.forLogging)")
170174
}
171175

172-
guard var settings = fallbackBuildSystem?.buildSettings(for: document, language: language) else {
176+
guard var settings = await fallbackBuildSystem?.buildSettings(for: document, language: language) else {
173177
return nil
174178
}
175179
if buildSystem == nil {

Sources/SKCore/FallbackBuildSystem.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import struct TSCBasic.AbsolutePath
2121
import class TSCBasic.Process
2222

2323
/// A simple BuildSystem suitable as a fallback when accurate settings are unknown.
24-
public final class FallbackBuildSystem {
24+
public actor FallbackBuildSystem {
2525

2626
let buildSetup: BuildSetup
2727

@@ -38,6 +38,10 @@ public final class FallbackBuildSystem {
3838
)
3939
}()
4040

41+
@_spi(Testing) public func setSdkPath(_ newValue: AbsolutePath?) {
42+
self.sdkpath = newValue
43+
}
44+
4145
/// Delegate to handle any build system events.
4246
public weak var delegate: BuildSystemDelegate? = nil
4347

Sources/SKSupport/LineTable.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import LSPLogging
14+
#if canImport(os)
15+
import os
16+
#endif
1417

15-
public struct LineTable: Hashable {
18+
public struct LineTable: Hashable, Sendable {
1619
@usableFromInline
1720
var impl: [String.Index]
1821

0 commit comments

Comments
 (0)