Skip to content

Commit fa54ef1

Browse files
committed
Add Sendable annotations to LanguageServerProtocol
1 parent cbb5693 commit fa54ef1

File tree

92 files changed

+283
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+283
-278
lines changed

Package.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.7
1+
// swift-tools-version:5.8
22

33
import Foundation
44
import PackageDescription
@@ -97,7 +97,8 @@ let package = Package(
9797
.target(
9898
name: "LanguageServerProtocol",
9999
dependencies: [],
100-
exclude: ["CMakeLists.txt"]
100+
exclude: ["CMakeLists.txt"],
101+
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]
101102
),
102103

103104
.testTarget(

Sources/LSPTestSupport/TestJSONRPCConnection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ extension String: @retroactive ResponseType {}
185185
#endif
186186

187187
public struct EchoRequest: RequestType {
188-
public static var method: String = "test_server/echo"
188+
public static let method: String = "test_server/echo"
189189
public typealias Response = String
190190

191191
public var string: String
@@ -196,7 +196,7 @@ public struct EchoRequest: RequestType {
196196
}
197197

198198
public struct EchoError: RequestType {
199-
public static var method: String = "test_server/echo_error"
199+
public static let method: String = "test_server/echo_error"
200200
public typealias Response = VoidResponse
201201

202202
public var code: ErrorCode?
@@ -209,7 +209,7 @@ public struct EchoError: RequestType {
209209
}
210210

211211
public struct EchoNotification: NotificationType {
212-
public static var method: String = "test_server/echo_note"
212+
public static let method: String = "test_server/echo_note"
213213

214214
public var string: String
215215

Sources/LanguageServerProtocol/CustomCodable.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public struct CustomCodable<CustomCoder: CustomCodableWrapper> {
5151
}
5252
}
5353

54+
extension CustomCodable: Sendable where CustomCoder.WrappedValue: Sendable {}
55+
5456
extension CustomCodable: Codable {
5557
public init(from decoder: Decoder) throws {
5658
self.wrappedValue = try CustomCoder(from: decoder).wrappedValue

Sources/LanguageServerProtocol/Error.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
public typealias LSPResult<T> = Swift.Result<T, ResponseError>
1515

1616
/// Error code suitable for use between language server and client.
17-
public struct ErrorCode: RawRepresentable, Codable, Hashable {
17+
public struct ErrorCode: RawRepresentable, Codable, Hashable, Sendable {
1818

1919
public var rawValue: Int
2020

@@ -100,9 +100,9 @@ public struct ResponseError: Error, Codable, Hashable {
100100
extension ResponseError {
101101
// MARK: Convenience properties for common errors.
102102

103-
public static var cancelled: ResponseError = ResponseError(code: .cancelled, message: "request cancelled by client")
103+
public static let cancelled: ResponseError = ResponseError(code: .cancelled, message: "request cancelled by client")
104104

105-
public static var serverCancelled: ResponseError = ResponseError(
105+
public static let serverCancelled: ResponseError = ResponseError(
106106
code: .serverCancelled,
107107
message: "request cancelled by server"
108108
)
@@ -136,7 +136,7 @@ public struct MessageDecodingError: Error, Hashable {
136136
/// If it was possible to recover the request id, it is stored here. This can be used e.g. to reply with a `ResponseError` to invalid requests.
137137
public var id: RequestID?
138138

139-
public enum MessageKind {
139+
public enum MessageKind: Sendable {
140140
case request
141141
case response
142142
case notification

Sources/LanguageServerProtocol/Message.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import Dispatch
1414

15-
public protocol MessageType: Codable {}
15+
public protocol MessageType: Codable, Sendable {}
1616

1717
/// `RequestType` with no associated type or same-type requirements. Most users should prefer
1818
/// `RequestType`.

Sources/LanguageServerProtocol/MessageRegistry.swift

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

13-
public final class MessageRegistry {
13+
public final class MessageRegistry: Sendable {
1414

1515
public static let lspProtocol: MessageRegistry =
1616
MessageRegistry(requests: builtinRequests, notifications: builtinNotifications)

Sources/LanguageServerProtocol/Notifications/CancelWorkDoneProgressNotification.swift

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

1313
public struct CancelWorkDoneProgressNotification: NotificationType {
14-
public static var method: String = "window/workDoneProgress/cancel"
14+
public static let method: String = "window/workDoneProgress/cancel"
1515

1616
public var token: ProgressToken
1717

Sources/LanguageServerProtocol/Notifications/DidChangeFileNotifications.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
public struct DidCreateFilesNotification: NotificationType {
14-
public static var method: String = "workspace/didCreateFiles"
14+
public static let method: String = "workspace/didCreateFiles"
1515

1616
/// An array of all files/folders created in this operation.
1717
public var files: [FileCreate]
@@ -22,7 +22,7 @@ public struct DidCreateFilesNotification: NotificationType {
2222
}
2323

2424
public struct DidRenameFilesNotification: NotificationType {
25-
public static var method: String = "workspace/didRenameFiles"
25+
public static let method: String = "workspace/didRenameFiles"
2626

2727
/// An array of all files/folders renamed in this operation. When a folder
2828
/// is renamed, only the folder will be included, and not its children.
@@ -34,7 +34,7 @@ public struct DidRenameFilesNotification: NotificationType {
3434
}
3535

3636
public struct DidDeleteFilesNotification: NotificationType {
37-
public static var method: String = "workspace/didDeleteFiles"
37+
public static let method: String = "workspace/didDeleteFiles"
3838

3939
/// An array of all files/folders created in this operation.
4040
public var files: [FileDelete]

Sources/LanguageServerProtocol/Notifications/DidChangeWorkspaceFoldersNotification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public struct DidChangeWorkspaceFoldersNotification: NotificationType {
2727
}
2828

2929
/// The workspace folder change event.
30-
public struct WorkspaceFoldersChangeEvent: Codable, Hashable {
30+
public struct WorkspaceFoldersChangeEvent: Codable, Hashable, Sendable {
3131

3232
/// The array of added workspace folders
3333
public var added: [WorkspaceFolder]?

Sources/LanguageServerProtocol/Notifications/TextSynchronizationNotifications.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public struct DidOpenNotebookDocumentNotification: NotificationType, Hashable {
169169

170170
/// The change notification is sent from the client to the server when a notebook document changes. It is only sent by a client if the server requested the synchronization mode `notebook` in its `notebookDocumentSync` capability.
171171
public struct DidChangeNotebookDocumentNotification: NotificationType, Hashable {
172-
public static var method: String = "notebookDocument/didChange"
172+
public static let method: String = "notebookDocument/didChange"
173173

174174
/// The notebook document that did change. The version number points
175175
/// to the version after all provided changes have been applied.
@@ -196,7 +196,7 @@ public struct DidChangeNotebookDocumentNotification: NotificationType, Hashable
196196

197197
/// The save notification is sent from the client to the server when a notebook document is saved. It is only sent by a client if the server requested the synchronization mode `notebook` in its `notebookDocumentSync` capability.
198198
public struct DidSaveNotebookDocumentNotification: NotificationType {
199-
public static var method: String = "notebookDocument/didSave"
199+
public static let method: String = "notebookDocument/didSave"
200200

201201
/// The notebook document that got saved.
202202
public var notebookDocument: NotebookDocumentIdentifier
@@ -208,7 +208,7 @@ public struct DidSaveNotebookDocumentNotification: NotificationType {
208208

209209
/// The close notification is sent from the client to the server when a notebook document is closed. It is only sent by a client if the server requested the synchronization mode `notebook` in its `notebookDocumentSync` capability.
210210
public struct DidCloseNotebookDocumentNotification: NotificationType {
211-
public static var method: String = "notebookDocument/didClose"
211+
public static let method: String = "notebookDocument/didClose"
212212

213213
/// The notebook document that got closed.
214214
public var notebookDocument: NotebookDocumentIdentifier

0 commit comments

Comments
 (0)