2 * Copyright (c) 2016, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
15 let autocomplete_response_to_json x
=
16 let param_to_json x
= JSON_Object
[
17 ("name", JSON_String x
.name
);
18 ("type", JSON_String x
.type_
);
21 let callable_details_to_json x
= JSON_Object
[
22 ("return_type", JSON_String x
.return_type
);
23 ("params", JSON_Array
(List.map x
.params ~f
:param_to_json));
26 let callable_details_to_json = function
28 | Some x
-> [("callable_details", callable_details_to_json x
)] in
30 let autocomplete_response_to_json x
= JSON_Object
([
31 ("name", JSON_String x
.autocomplete_item_text
);
32 ("type", JSON_String x
.autocomplete_item_type
);
33 ] @ (callable_details_to_json x
.callable_details
)) in
35 JSON_Array
(List.map x ~f
:autocomplete_response_to_json)
37 let to_json ~id
:_ ~response
=
39 | Autocomplete_response x
-> autocomplete_response_to_json x
40 (* Delegate unhandled messages to previous version of API *)
41 | _
-> Nuclide_rpc_message_printer.to_json ~response