<commit_before>//===--------------------- SourceKitdClient.swift -------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// This file provides a wrapper of SourceKitd service.
//===----------------------------------------------------------------------===//

import sourcekitd
import Foundation

public class SourceKitdService {

  public init() {
    sourcekitd_initialize()
  }
  deinit {
    sourcekitd_shutdown()
  }
  public func sendSyn(request: SourceKitdRequest) -> SourceKitdResponse {
    return SourceKitdResponse(resp: sourcekitd_send_request_sync(request.rawRequest))
  }
}<commit_msg>SwiftSourceKit: Add an API for sending request asynchronously. NFC<commit_after>//===--------------------- SourceKitdClient.swift -------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// This file provides a wrapper of SourceKitd service.
//===----------------------------------------------------------------------===//

import sourcekitd
import Foundation

public class SourceKitdService {

  public init() {
    sourcekitd_initialize()
  }
  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))
    }
  }
}
{'fraction_non_alphanumeric': 0.2305159165751921, 'fraction_numerical': 0.007317965605561654, 'mean_word_length': 2.0209944751381217, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2556750', 'n_tokens_mistral': 696, 'n_tokens_neox': 652, 'n_words': 226}