Skip to content

SwiftSourceKit: Add an API for sending request asynchronously. NFC #14899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tools/SourceKit/tools/swift-lang/SourceKitdClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,22 @@ public class SourceKitdService {
deinit {
sourcekitd_shutdown()
}

/// Send a request synchronously with a handler for its response.
/// - Parameter request: The request to send.
/// - Returns: The response from the sourcekitd service.
public func sendSyn(request: SourceKitdRequest) -> SourceKitdResponse {
return SourceKitdResponse(resp: sourcekitd_send_request_sync(request.rawRequest))
}

/// Send a request asynchronously with a handler for its response.
/// - Parameter request: The request to send.
/// - Parameter handler: The handler for the response in the future.
public func send(request: SourceKitdRequest,
handler: @escaping (SourceKitdResponse) -> ()) {
sourcekitd_send_request(request.rawRequest, nil) { response in
guard let response = response else { return }
handler(SourceKitdResponse(resp: response))
}
}
}