Skip to content

Commit a13278f

Browse files
authored
Merge pull request swiftlang#38 from abdullahselek/master
Prefer Void over ().
2 parents 85cf046 + e73dac5 commit a13278f

File tree

11 files changed

+34
-34
lines changed

11 files changed

+34
-34
lines changed

Sources/LanguageServerProtocol/Connection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public protocol Connection: AnyObject {
1919
func send<Notification>(_: Notification) where Notification: NotificationType
2020

2121
/// Send a request and (asynchronously) receive a reply.
22-
func send<Request>(_: Request, queue: DispatchQueue, reply: @escaping (LSPResult<Request.Response>) -> ()) -> RequestID where Request: RequestType
22+
func send<Request>(_: Request, queue: DispatchQueue, reply: @escaping (LSPResult<Request.Response>) -> Void) -> RequestID where Request: RequestType
2323

2424
/// Send a request synchronously. **Use wisely**.
2525
func sendSync<Request>(_: Request) throws -> Request.Response where Request: RequestType
@@ -51,7 +51,7 @@ public protocol MessageHandler: AnyObject {
5151
func handle<Notification>(_: Notification, from: ObjectIdentifier) where Notification: NotificationType
5252

5353
/// Handle a request and (asynchronously) receive a reply.
54-
func handle<Request>(_: Request, id: RequestID, from: ObjectIdentifier, reply: @escaping (LSPResult<Request.Response>) -> ()) where Request: RequestType
54+
func handle<Request>(_: Request, id: RequestID, from: ObjectIdentifier, reply: @escaping (LSPResult<Request.Response>) -> Void) where Request: RequestType
5555
}
5656

5757
/// A connection between two message handlers in the same process.
@@ -114,7 +114,7 @@ extension LocalConnection: Connection {
114114
handler!.handle(notification, from: ObjectIdentifier(self))
115115
}
116116

117-
public func send<Request>(_ request: Request, queue: DispatchQueue, reply: @escaping (LSPResult<Request.Response>) -> ()) -> RequestID where Request: RequestType {
117+
public func send<Request>(_ request: Request, queue: DispatchQueue, reply: @escaping (LSPResult<Request.Response>) -> Void) -> RequestID where Request: RequestType {
118118
precondition(state == .started)
119119
let id = nextRequestID()
120120
handler!.handle(request, id: id, from: ObjectIdentifier(self)) { result in

Sources/LanguageServerProtocol/LanguageServer.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ extension LanguageServerEndpoint {
103103
/// Register the given request handler, which must be a method on `self`.
104104
///
105105
/// Must be called on `queue`.
106-
public func _register<Server, R>(_ requestHandler: @escaping (Server) -> (Request<R>) -> ()) {
106+
public func _register<Server, R>(_ requestHandler: @escaping (Server) -> (Request<R>) -> Void) {
107107
// We can use `unowned` here because the handler is run synchronously on `queue`.
108108
precondition(self is Server)
109109
requestHandlers[ObjectIdentifier(R.self)] = { [unowned self] request in
@@ -114,7 +114,7 @@ extension LanguageServerEndpoint {
114114
/// Register the given notification handler, which must be a method on `self`.
115115
///
116116
/// Must be called on `queue`.
117-
public func _register<Server, N>(_ noteHandler: @escaping (Server) -> (Notification<N>) -> ()) {
117+
public func _register<Server, N>(_ noteHandler: @escaping (Server) -> (Notification<N>) -> Void) {
118118
// We can use `unowned` here because the handler is run synchronously on `queue`.
119119
notificationHandlers[ObjectIdentifier(N.self)] = { [unowned self] note in
120120
noteHandler(self as! Server)(note)
@@ -124,24 +124,24 @@ extension LanguageServerEndpoint {
124124
/// Register the given request handler.
125125
///
126126
/// Must be called on `queue`.
127-
public func _register<R>(_ requestHandler: @escaping (Request<R>) -> ()) {
127+
public func _register<R>(_ requestHandler: @escaping (Request<R>) -> Void) {
128128
requestHandlers[ObjectIdentifier(R.self)] = requestHandler
129129
}
130130

131131
/// Register the given notification handler.
132132
///
133133
/// Must be called on `queue`.
134-
public func _register<N>(_ noteHandler: @escaping (Notification<N>) -> ()) {
134+
public func _register<N>(_ noteHandler: @escaping (Notification<N>) -> Void) {
135135
notificationHandlers[ObjectIdentifier(N.self)] = noteHandler
136136
}
137137

138138
/// Register the given request handler. **For test messages only**.
139-
public func register<R>(_ requestHandler: @escaping (Request<R>) -> ()) {
139+
public func register<R>(_ requestHandler: @escaping (Request<R>) -> Void) {
140140
queue.sync { _register(requestHandler) }
141141
}
142142

143143
/// Register the given notification handler. **For test messages only**.
144-
public func register<N>(_ noteHandler: @escaping (Notification<N>) -> ()) {
144+
public func register<N>(_ noteHandler: @escaping (Notification<N>) -> Void) {
145145
queue.sync { _register(noteHandler) }
146146
}
147147
}
@@ -157,15 +157,15 @@ extension LanguageServerEndpoint: MessageHandler {
157157

158158
self._logNotification(notification)
159159

160-
guard let handler = self.notificationHandlers[ObjectIdentifier(N.self)] as? ((Notification<N>) -> ()) else {
160+
guard let handler = self.notificationHandlers[ObjectIdentifier(N.self)] as? ((Notification<N>) -> Void) else {
161161
self._handleUnknown(notification)
162162
return
163163
}
164164
handler(notification)
165165
}
166166
}
167167

168-
public func handle<R>(_ params: R, id: RequestID, from clientID: ObjectIdentifier, reply: @escaping (LSPResult<R.Response >) -> ()) where R: RequestType {
168+
public func handle<R>(_ params: R, id: RequestID, from clientID: ObjectIdentifier, reply: @escaping (LSPResult<R.Response >) -> Void) where R: RequestType {
169169

170170
queue.async {
171171

@@ -182,7 +182,7 @@ extension LanguageServerEndpoint: MessageHandler {
182182

183183
self._logRequest(request)
184184

185-
guard let handler = self.requestHandlers[ObjectIdentifier(R.self)] as? ((Request<R>) -> ()) else {
185+
guard let handler = self.requestHandlers[ObjectIdentifier(R.self)] as? ((Request<R>) -> Void) else {
186186
self._handleUnknown(request)
187187
return
188188
}

Sources/LanguageServerProtocol/Request.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public final class Request<R: RequestType> {
2828
/// The request parameters.
2929
public let params: Params
3030

31-
private var replyBlock: (LSPResult<Response>) -> ()
31+
private var replyBlock: (LSPResult<Response>) -> Void
3232

3333
/// Whether a reply has been made. Every request must reply exactly once.
3434
private var replied: Bool = false {
@@ -40,7 +40,7 @@ public final class Request<R: RequestType> {
4040
/// The request's cancellation state.
4141
public let cancellationToken: CancellationToken
4242

43-
public init(_ request: Params, id: RequestID, clientID: ObjectIdentifier, cancellation: CancellationToken, reply: @escaping (LSPResult<Response>) -> ()) {
43+
public init(_ request: Params, id: RequestID, clientID: ObjectIdentifier, cancellation: CancellationToken, reply: @escaping (LSPResult<Response>) -> Void) {
4444
self.id = id
4545
self.clientID = clientID
4646
self.params = request

Sources/LanguageServerProtocolJSONRPC/JSONRPCConnection.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public final class JSONRPCConection {
4242
var requestType: _RequestType.Type
4343
var responseType: ResponseType.Type
4444
var queue: DispatchQueue
45-
var replyHandler: (LSPResult<Any>) -> ()
45+
var replyHandler: (LSPResult<Any>) -> Void
4646
}
4747

4848
/// The set of currently outstanding outgoing requests along with information about how to decode and handle their responses.
@@ -296,7 +296,7 @@ extension JSONRPCConection: _IndirectConnection {
296296
}
297297
}
298298

299-
public func send<Request>(_ request: Request, queue: DispatchQueue, reply: @escaping (LSPResult<Request.Response>) -> ()) -> RequestID where Request: RequestType {
299+
public func send<Request>(_ request: Request, queue: DispatchQueue, reply: @escaping (LSPResult<Request.Response>) -> Void) -> RequestID where Request: RequestType {
300300

301301
let id: RequestID = self.queue.sync {
302302
let id = nextRequestID()

Sources/SKSupport/Logging.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public final class Logger {
100100
}
101101

102102
@discardableResult
103-
public func addLogHandler(_ handler: @escaping (String, LogLevel) -> ()) -> AnyLogHandler {
103+
public func addLogHandler(_ handler: @escaping (String, LogLevel) -> Void) -> AnyLogHandler {
104104
let obj = AnyLogHandler(handler)
105105
addLogHandler(obj)
106106
return obj
@@ -165,9 +165,9 @@ public final class Logger {
165165

166166
public class AnyLogHandler: LogHandler {
167167

168-
let handler: (String, LogLevel) -> ()
168+
let handler: (String, LogLevel) -> Void
169169

170-
public init(_ handler: @escaping (String, LogLevel) -> ()) {
170+
public init(_ handler: @escaping (String, LogLevel) -> Void) {
171171
self.handler = handler
172172
}
173173

Sources/SKTestSupport/CheckCoding.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public func checkDecoding<T>(json: String, expected value: T, file: StaticString
6767
XCTAssertEqual(value, decodedValue, file: file, line: line)
6868
}
6969

70-
public func checkCoding<T>(_ value: T, json: String, userInfo: [CodingUserInfoKey: Any] = [:], file: StaticString = #file, line: UInt = #line, body: (T) -> ()) where T: Codable {
70+
public func checkCoding<T>(_ value: T, json: String, userInfo: [CodingUserInfoKey: Any] = [:], file: StaticString = #file, line: UInt = #line, body: (T) -> Void) where T: Codable {
7171
let encoder = JSONEncoder()
7272
encoder.outputFormatting.insert(.prettyPrinted)
7373
if #available(macOS 10.13, *) {

Sources/SKTestSupport/TestJSONRPCConnection.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ public final class TestClient: LanguageServerEndpoint {
9393
}
9494

9595
public var replyQueue: DispatchQueue = DispatchQueue(label: "testclient-reply-queue")
96-
var oneShotNotificationHandlers: [((Any) -> ())] = []
96+
var oneShotNotificationHandlers: [((Any) -> Void)] = []
9797

9898
public var allowUnexpectedNotification: Bool = false
9999

100-
public func appendOneShotNotificationHandler<N>(_ handler: @escaping (Notification<N>) -> ()) {
100+
public func appendOneShotNotificationHandler<N>(_ handler: @escaping (Notification<N>) -> Void) {
101101
oneShotNotificationHandlers.append({ anyNote in
102102
guard let note = anyNote as? Notification<N> else {
103103
fatalError("received notification of the wrong type \(anyNote); expected \(N.self)")
@@ -106,7 +106,7 @@ public final class TestClient: LanguageServerEndpoint {
106106
})
107107
}
108108

109-
public func handleNextNotification<N>(_ handler: @escaping (Notification<N>) -> ()) {
109+
public func handleNextNotification<N>(_ handler: @escaping (Notification<N>) -> Void) {
110110
precondition(oneShotNotificationHandlers.isEmpty)
111111
appendOneShotNotificationHandler(handler)
112112
}
@@ -137,12 +137,12 @@ extension TestClient: Connection {
137137
}
138138

139139
/// Send a request to the language server and (asynchronously) receive a reply.
140-
public func send<Request>(_ request: Request, queue: DispatchQueue, reply: @escaping (LSPResult<Request.Response>) -> ()) -> RequestID where Request: RequestType {
140+
public func send<Request>(_ request: Request, queue: DispatchQueue, reply: @escaping (LSPResult<Request.Response>) -> Void) -> RequestID where Request: RequestType {
141141
return server.send(request, queue: queue, reply: reply)
142142
}
143143

144144
/// Convenience method to get reply on replyQueue.
145-
public func send<Request>(_ request: Request, reply: @escaping (LSPResult<Request.Response>) -> ()) -> RequestID where Request: RequestType {
145+
public func send<Request>(_ request: Request, reply: @escaping (LSPResult<Request.Response>) -> Void) -> RequestID where Request: RequestType {
146146
return send(request, queue: replyQueue, reply: reply)
147147
}
148148

@@ -152,7 +152,7 @@ extension TestClient: Connection {
152152

153153
/// Send a notification and expect a notification in reply synchronously.
154154
/// For testing notifications that behave like requests - e.g. didChange & publishDiagnostics.
155-
public func sendNoteSync<NSend, NReply>(_ notification: NSend, _ handler: @escaping (Notification<NReply>) -> ()) where NSend: NotificationType {
155+
public func sendNoteSync<NSend, NReply>(_ notification: NSend, _ handler: @escaping (Notification<NReply>) -> Void) where NSend: NotificationType {
156156

157157
let expectation = XCTestExpectation(description: "sendNoteSync - note received")
158158

@@ -173,8 +173,8 @@ extension TestClient: Connection {
173173
/// For testing notifications that behave like requests - e.g. didChange & publishDiagnostics.
174174
public func sendNoteSync<NSend, NReply1, NReply2>(
175175
_ notification: NSend,
176-
_ handler1: @escaping (Notification<NReply1>) -> (),
177-
_ handler2: @escaping (Notification<NReply2>) -> ()
176+
_ handler1: @escaping (Notification<NReply1>) -> Void,
177+
_ handler2: @escaping (Notification<NReply2>) -> Void
178178
) where NSend: NotificationType {
179179

180180
let expectation = XCTestExpectation(description: "sendNoteSync - note received")

Sources/SourceKit/DocumentManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public final class DocumentManager {
9595
/// - returns: The contents of the file after all the edits are applied.
9696
/// - throws: Error.missingDocument if the document is not open.
9797
@discardableResult
98-
public func edit(_ url: URL, newVersion: Int, edits: [TextDocumentContentChangeEvent], editCallback: ((_ before: DocumentSnapshot, TextDocumentContentChangeEvent) -> ())? = nil) throws -> DocumentSnapshot {
98+
public func edit(_ url: URL, newVersion: Int, edits: [TextDocumentContentChangeEvent], editCallback: ((_ before: DocumentSnapshot, TextDocumentContentChangeEvent) -> Void)? = nil) throws -> DocumentSnapshot {
9999
return try queue.sync {
100100
guard let document = documents[url] else {
101101
throw Error.missingDocument(url)
@@ -159,7 +159,7 @@ extension DocumentManager {
159159

160160
/// Convenience wrapper for `edit(_:newVersion:edits:editCallback:)` that logs on failure.
161161
@discardableResult
162-
func edit(_ note: Notification<DidChangeTextDocument>, editCallback: ((_ before: DocumentSnapshot, TextDocumentContentChangeEvent) -> ())? = nil) -> DocumentSnapshot? {
162+
func edit(_ note: Notification<DidChangeTextDocument>, editCallback: ((_ before: DocumentSnapshot, TextDocumentContentChangeEvent) -> Void)? = nil) -> DocumentSnapshot? {
163163
return orLog("failed to edit document", level: .error) {
164164
try edit(note.params.textDocument.url, newVersion: note.params.textDocument.version ?? -1, edits: note.params.contentChanges, editCallback: editCallback)
165165
}

Sources/SourceKit/SourceKitServer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public final class SourceKitServer: LanguageServer {
7171
}
7272

7373
func registerWorkspaceRequest<R>(
74-
_ requestHandler: @escaping (SourceKitServer) -> (Request<R>, Workspace) -> ())
74+
_ requestHandler: @escaping (SourceKitServer) -> (Request<R>, Workspace) -> Void)
7575
{
7676
_register { [unowned self] (req: Request<R>) in
7777
guard let workspace = self.workspace else {
@@ -83,7 +83,7 @@ public final class SourceKitServer: LanguageServer {
8383
}
8484

8585
func registerWorkspaceNotfication<N>(
86-
_ noteHandler: @escaping (SourceKitServer) -> (Notification<N>, Workspace) -> ())
86+
_ noteHandler: @escaping (SourceKitServer) -> (Notification<N>, Workspace) -> Void)
8787
{
8888
_register { [unowned self] (note: Notification<N>) in
8989
guard let workspace = self.workspace else {

Sources/SourceKit/sourcekitd/SwiftSourceKitFramework.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ extension SwiftSourceKitFramework {
160160
}
161161

162162
/// Send the given request and synchronously receive a reply dictionary (or error).
163-
func send(_ req: SKRequestDictionary, reply: @escaping (LSPResult<SKResponseDictionary>) -> ()) -> sourcekitd_request_handle_t? {
163+
func send(_ req: SKRequestDictionary, reply: @escaping (LSPResult<SKResponseDictionary>) -> Void) -> sourcekitd_request_handle_t? {
164164
logAsync { _ in req.description }
165165

166166
var handle: sourcekitd_request_handle_t? = nil

Tests/LanguageServerProtocolTests/CodingTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ final class CodingTests: XCTestCase {
199199
}
200200
}
201201

202-
func with<T>(_ value: T, mutate: (inout T) -> ()) -> T {
202+
func with<T>(_ value: T, mutate: (inout T) -> Void) -> T {
203203
var localCopy = value
204204
mutate(&localCopy)
205205
return localCopy

0 commit comments

Comments
 (0)