Skip to content

Commit 81c9f83

Browse files
authored
Merge pull request #14899 from nkcsgexi/sourcekit-async
2 parents 3b77aad + 2b464c8 commit 81c9f83

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tools/SourceKit/tools/swift-lang/SourceKitdClient.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,22 @@ public class SourceKitdService {
2323
deinit {
2424
sourcekitd_shutdown()
2525
}
26+
27+
/// Send a request synchronously with a handler for its response.
28+
/// - Parameter request: The request to send.
29+
/// - Returns: The response from the sourcekitd service.
2630
public func sendSyn(request: SourceKitdRequest) -> SourceKitdResponse {
2731
return SourceKitdResponse(resp: sourcekitd_send_request_sync(request.rawRequest))
2832
}
33+
34+
/// Send a request asynchronously with a handler for its response.
35+
/// - Parameter request: The request to send.
36+
/// - Parameter handler: The handler for the response in the future.
37+
public func send(request: SourceKitdRequest,
38+
handler: @escaping (SourceKitdResponse) -> ()) {
39+
sourcekitd_send_request(request.rawRequest, nil) { response in
40+
guard let response = response else { return }
41+
handler(SourceKitdResponse(resp: response))
42+
}
43+
}
2944
}

0 commit comments

Comments
 (0)