···131131132132module U = Impl.Make (S)
133133134134+(* let test () =
135135+ let _x = Compmisc.initial_env in
136136+ let oc = open_out "/tmp/unix_worker.ml" in
137137+ Printf.fprintf oc "let x=1;;\n";
138138+ close_out oc;
139139+ let unit_info = Unit_info.make ~source_file:"/tmp/unix_worker.ml" "/tmp/unix_worker" in
140140+ try
141141+ let _ast = Pparse.parse_implementation ~tool_name:"worker" "/tmp/unix_worker.ml" in
142142+ let _ = Typemod.type_implementation unit_info (Compmisc.initial_env ()) _ast in
143143+ ()
144144+ with exn ->
145145+ Printf.eprintf "error: %s\n%!" (Printexc.to_string exn);
146146+ let ppf = Format.err_formatter in
147147+ let _ = Location.report_exception ppf exn in
148148+ () *)
149149+134150let start_server () =
135151 let open U in
136152 Logs.set_reporter (Logs_fmt.reporter ());
+9
idl/js_top_worker_client.ml
···8989 string ->
9090 (Toplevel_api_gen.exec_result, Toplevel_api_gen.err) result Lwt.t
91919292+ val query_errors :
9393+ rpc ->
9494+ string option ->
9595+ string list ->
9696+ bool ->
9797+ string ->
9898+ (Toplevel_api_gen.error list, Toplevel_api_gen.err) result Lwt.t
9299 val compile_js :
93100 rpc ->
94101 string option ->
···103110 let setup rpc a = Wraw.setup rpc a |> Rpc_lwt.T.get
104111 let typecheck rpc a = Wraw.typecheck rpc a |> Rpc_lwt.T.get
105112 let exec rpc a = Wraw.exec rpc a |> Rpc_lwt.T.get
113113+ let query_errors rpc id deps is_toplevel doc =
114114+ Wraw.query_errors rpc id deps is_toplevel doc |> Rpc_lwt.T.get
106115 let compile_js rpc id s = Wraw.compile_js rpc id s |> Rpc_lwt.T.get
107116end
+5
idl/js_top_worker_client.mli
···5050 (** Execute a phrase using the toplevel. The toplevel must have been
5151 initialised first. *)
52525353+ val query_errors : rpc -> string option -> string list -> bool -> string -> (Toplevel_api_gen.error list, err) result Lwt.t
5454+ (** Query the toplevel for errors. The first argument is the phrase to check
5555+ for errors. If it is [None], the toplevel will return all errors. If it
5656+ is [Some s], the toplevel will return only errors related to [s]. *)
5757+5358 val compile_js : rpc -> string option -> string -> (string, err) result Lwt.t
5459end
+5-5
idl/js_top_worker_client_fut.ml
···7979 let typecheck rpc a = Wraw.typecheck rpc a |> Rpc_fut.T.get
8080 let exec rpc a = Wraw.exec rpc a |> Rpc_fut.T.get
8181 let compile_js rpc id s = Wraw.compile_js rpc id s |> Rpc_fut.T.get
8282- let query_errors rpc doc = Wraw.query_errors rpc doc |> Rpc_fut.T.get
8282+ let query_errors rpc id deps is_toplevel doc = Wraw.query_errors rpc id deps is_toplevel doc |> Rpc_fut.T.get
8383 let exec_toplevel rpc doc = Wraw.exec_toplevel rpc doc |> Rpc_fut.T.get
84848585- let complete_prefix rpc doc pos =
8686- Wraw.complete_prefix rpc doc pos |> Rpc_fut.T.get
8585+ let complete_prefix rpc id deps doc pos =
8686+ Wraw.complete_prefix rpc id deps doc pos |> Rpc_fut.T.get
87878888- let type_enclosing rpc doc pos =
8989- Wraw.type_enclosing rpc doc pos |> Rpc_fut.T.get
8888+ let type_enclosing rpc id deps doc pos =
8989+ Wraw.type_enclosing rpc id deps doc pos |> Rpc_fut.T.get
9090end
+12-3
idl/toplevel_api.ml
···166166[@@deriving rpcty]
167167(** Represents the result of executing a toplevel phrase *)
168168169169+type script_parts = (int * int) list (* Input length and output length *)
170170+[@@deriving rpcty]
171171+169172type exec_toplevel_result = {
170173 script : string;
174174+ parts : script_parts;
171175 mime_vals : mime_val list;
172176}
173177[@@deriving rpcty]
···183187type err = InternalError of string [@@deriving rpcty]
184188185189type opt_id = string option [@@deriving rpcty]
190190+191191+type dependencies = string list [@@deriving rpcty]
192192+(** The ids of the cells that are dependencies *)
186193187194module E = Idl.Error.Make (struct
188195 type t = err
···210217 let unit_p = Param.mk Types.unit
211218 let phrase_p = Param.mk Types.string
212219 let id_p = Param.mk opt_id
220220+ let dependencies_p = Param.mk dependencies
213221 let typecheck_result_p = Param.mk exec_result
214222 let exec_result_p = Param.mk exec_result
215223···219227 let completions_p = Param.mk completions
220228 let error_list_p = Param.mk error_list
221229 let typed_enclosings_p = Param.mk typed_enclosings_list
230230+ let is_toplevel_p = Param.mk ~name:"is_toplevel" Types.bool
222231223232 let toplevel_script_p = Param.mk ~description:[
224233 "A toplevel script is a sequence of toplevel phrases interspersed with";
···286295 [
287296 "Complete a prefix"
288297 ]
289289- (source_p @-> position_p @-> returning completions_p err)
298298+ (id_p @-> dependencies_p @-> source_p @-> position_p @-> returning completions_p err)
290299291300 let query_errors =
292301 declare "query_errors"
293302 [
294303 "Query the errors in the given source"
295304 ]
296296- (source_p @-> returning error_list_p err)
305305+ (id_p @-> dependencies_p @-> is_toplevel_p @-> source_p @-> returning error_list_p err)
297306298307 let type_enclosing =
299308 declare "type_enclosing"
300309 [
301310 "Get the type of the enclosing expression"
302311 ]
303303- (source_p @-> position_p @-> returning typed_enclosings_p err)
312312+ (id_p @-> dependencies_p @-> source_p @-> position_p @-> returning typed_enclosings_p err)
304313end
+280-236
idl/toplevel_api_gen.ml
···22 {
33 tool_name = "ppx_driver";
44 include_dirs = [];
55- load_path = [];
55+ hidden_include_dirs = [];
66+ load_path = ([], []);
67 open_modules = [];
78 for_package = None;
89 debug = false;
···3940 Rpc.Types.fdescription = [];
4041 Rpc.Types.fversion = None;
4142 Rpc.Types.fget = (fun _r -> _r.pos_fname);
4242- Rpc.Types.fset = (fun v -> fun _s -> { _s with pos_fname = v })
4343+ Rpc.Types.fset = (fun v _s -> { _s with pos_fname = v })
4344 }
4445 and lexing_position_pos_lnum : (_, lexing_position) Rpc.Types.field =
4546 {
···4950 Rpc.Types.fdescription = [];
5051 Rpc.Types.fversion = None;
5152 Rpc.Types.fget = (fun _r -> _r.pos_lnum);
5252- Rpc.Types.fset = (fun v -> fun _s -> { _s with pos_lnum = v })
5353+ Rpc.Types.fset = (fun v _s -> { _s with pos_lnum = v })
5354 }
5455 and lexing_position_pos_bol : (_, lexing_position) Rpc.Types.field =
5556 {
···5960 Rpc.Types.fdescription = [];
6061 Rpc.Types.fversion = None;
6162 Rpc.Types.fget = (fun _r -> _r.pos_bol);
6262- Rpc.Types.fset = (fun v -> fun _s -> { _s with pos_bol = v })
6363+ Rpc.Types.fset = (fun v _s -> { _s with pos_bol = v })
6364 }
6465 and lexing_position_pos_cnum : (_, lexing_position) Rpc.Types.field =
6566 {
···6970 Rpc.Types.fdescription = [];
7071 Rpc.Types.fversion = None;
7172 Rpc.Types.fget = (fun _r -> _r.pos_cnum);
7272- Rpc.Types.fset = (fun v -> fun _s -> { _s with pos_cnum = v })
7373+ Rpc.Types.fset = (fun v _s -> { _s with pos_cnum = v })
7374 }
7475 and typ_of_lexing_position =
7576 Rpc.Types.Struct
···138139 Rpc.Types.fdescription = [];
139140 Rpc.Types.fversion = None;
140141 Rpc.Types.fget = (fun _r -> _r.loc_start);
141141- Rpc.Types.fset = (fun v -> fun _s -> { _s with loc_start = v })
142142+ Rpc.Types.fset = (fun v _s -> { _s with loc_start = v })
142143 }
143144 and location_loc_end : (_, location) Rpc.Types.field =
144145 {
···148149 Rpc.Types.fdescription = [];
149150 Rpc.Types.fversion = None;
150151 Rpc.Types.fget = (fun _r -> _r.loc_end);
151151- Rpc.Types.fset = (fun v -> fun _s -> { _s with loc_end = v })
152152+ Rpc.Types.fset = (fun v _s -> { _s with loc_end = v })
152153 }
153154 and location_loc_ghost : (_, location) Rpc.Types.field =
154155 {
···158159 Rpc.Types.fdescription = [];
159160 Rpc.Types.fversion = None;
160161 Rpc.Types.fget = (fun _r -> _r.loc_ghost);
161161- Rpc.Types.fset = (fun v -> fun _s -> { _s with loc_ghost = v })
162162+ Rpc.Types.fset = (fun v _s -> { _s with loc_ghost = v })
162163 }
163164 and typ_of_location =
164165 Rpc.Types.Struct
···292293 Rpc.Types.vdefault = None;
293294 Rpc.Types.vversion = None;
294295 Rpc.Types.vconstructor =
295295- (fun s' ->
296296- fun t ->
297297- let s = String.lowercase_ascii s' in
298298- match s with
299299- | "lexer" ->
300300- Rresult.R.bind (t.tget Unit)
301301- (function | () -> Rresult.R.ok Lexer)
302302- | "parser" ->
303303- Rresult.R.bind (t.tget Unit)
304304- (function | () -> Rresult.R.ok Parser)
305305- | "typer" ->
306306- Rresult.R.bind (t.tget Unit)
307307- (function | () -> Rresult.R.ok Typer)
308308- | "warning" ->
309309- Rresult.R.bind (t.tget Unit)
310310- (function | () -> Rresult.R.ok Warning)
311311- | "unknown" ->
312312- Rresult.R.bind (t.tget Unit)
313313- (function | () -> Rresult.R.ok Unknown)
314314- | "env" ->
315315- Rresult.R.bind (t.tget Unit)
316316- (function | () -> Rresult.R.ok Env)
317317- | "config" ->
318318- Rresult.R.bind (t.tget Unit)
319319- (function | () -> Rresult.R.ok Config)
320320- | _ ->
321321- Rresult.R.error_msg
322322- (Printf.sprintf "Unknown tag '%s'" s))
296296+ (fun s' t ->
297297+ let s = String.lowercase_ascii s' in
298298+ match s with
299299+ | "lexer" ->
300300+ Rresult.R.bind (t.tget Unit)
301301+ (function | () -> Rresult.R.ok Lexer)
302302+ | "parser" ->
303303+ Rresult.R.bind (t.tget Unit)
304304+ (function | () -> Rresult.R.ok Parser)
305305+ | "typer" ->
306306+ Rresult.R.bind (t.tget Unit)
307307+ (function | () -> Rresult.R.ok Typer)
308308+ | "warning" ->
309309+ Rresult.R.bind (t.tget Unit)
310310+ (function | () -> Rresult.R.ok Warning)
311311+ | "unknown" ->
312312+ Rresult.R.bind (t.tget Unit)
313313+ (function | () -> Rresult.R.ok Unknown)
314314+ | "env" ->
315315+ Rresult.R.bind (t.tget Unit)
316316+ (function | () -> Rresult.R.ok Env)
317317+ | "config" ->
318318+ Rresult.R.bind (t.tget Unit)
319319+ (function | () -> Rresult.R.ok Config)
320320+ | _ ->
321321+ Rresult.R.error_msg (Printf.sprintf "Unknown tag '%s'" s))
323322 } : location_error_source Rpc.Types.variant)
324323 and location_error_source =
325324 {
···403402 Rpc.Types.vdefault = None;
404403 Rpc.Types.vversion = None;
405404 Rpc.Types.vconstructor =
406406- (fun s' ->
407407- fun t ->
408408- let s = String.lowercase_ascii s' in
409409- match s with
410410- | "report_error" ->
411411- Rresult.R.bind (t.tget Unit)
412412- (function | () -> Rresult.R.ok Report_error)
413413- | "report_warning" ->
414414- Rresult.R.bind
415415- (t.tget (let open Rpc.Types in Basic String))
416416- (function | a0 -> Rresult.R.ok (Report_warning a0))
417417- | "report_warning_as_error" ->
418418- Rresult.R.bind
419419- (t.tget (let open Rpc.Types in Basic String))
420420- (function
421421- | a0 -> Rresult.R.ok (Report_warning_as_error a0))
422422- | "report_alert" ->
423423- Rresult.R.bind
424424- (t.tget (let open Rpc.Types in Basic String))
425425- (function | a0 -> Rresult.R.ok (Report_alert a0))
426426- | "report_alert_as_error" ->
427427- Rresult.R.bind
428428- (t.tget (let open Rpc.Types in Basic String))
429429- (function
430430- | a0 -> Rresult.R.ok (Report_alert_as_error a0))
431431- | _ ->
432432- Rresult.R.error_msg
433433- (Printf.sprintf "Unknown tag '%s'" s))
405405+ (fun s' t ->
406406+ let s = String.lowercase_ascii s' in
407407+ match s with
408408+ | "report_error" ->
409409+ Rresult.R.bind (t.tget Unit)
410410+ (function | () -> Rresult.R.ok Report_error)
411411+ | "report_warning" ->
412412+ Rresult.R.bind
413413+ (t.tget (let open Rpc.Types in Basic String))
414414+ (function | a0 -> Rresult.R.ok (Report_warning a0))
415415+ | "report_warning_as_error" ->
416416+ Rresult.R.bind
417417+ (t.tget (let open Rpc.Types in Basic String))
418418+ (function
419419+ | a0 -> Rresult.R.ok (Report_warning_as_error a0))
420420+ | "report_alert" ->
421421+ Rresult.R.bind
422422+ (t.tget (let open Rpc.Types in Basic String))
423423+ (function | a0 -> Rresult.R.ok (Report_alert a0))
424424+ | "report_alert_as_error" ->
425425+ Rresult.R.bind
426426+ (t.tget (let open Rpc.Types in Basic String))
427427+ (function
428428+ | a0 -> Rresult.R.ok (Report_alert_as_error a0))
429429+ | _ ->
430430+ Rresult.R.error_msg (Printf.sprintf "Unknown tag '%s'" s))
434431 } : location_report_kind Rpc.Types.variant)
435432 and location_report_kind =
436433 {
···483480 Rpc.Types.fdescription = [];
484481 Rpc.Types.fversion = None;
485482 Rpc.Types.fget = (fun _r -> _r.dcs_url);
486486- Rpc.Types.fset = (fun v -> fun _s -> { _s with dcs_url = v })
483483+ Rpc.Types.fset = (fun v _s -> { _s with dcs_url = v })
487484 }
488485 and dynamic_cmis_dcs_toplevel_modules : (_, dynamic_cmis) Rpc.Types.field
489486 =
···495492 Rpc.Types.fdescription = [];
496493 Rpc.Types.fversion = None;
497494 Rpc.Types.fget = (fun _r -> _r.dcs_toplevel_modules);
498498- Rpc.Types.fset =
499499- (fun v -> fun _s -> { _s with dcs_toplevel_modules = v })
495495+ Rpc.Types.fset = (fun v _s -> { _s with dcs_toplevel_modules = v })
500496 }
501497 and dynamic_cmis_dcs_file_prefixes : (_, dynamic_cmis) Rpc.Types.field =
502498 {
···507503 Rpc.Types.fdescription = [];
508504 Rpc.Types.fversion = None;
509505 Rpc.Types.fget = (fun _r -> _r.dcs_file_prefixes);
510510- Rpc.Types.fset =
511511- (fun v -> fun _s -> { _s with dcs_file_prefixes = v })
506506+ Rpc.Types.fset = (fun v _s -> { _s with dcs_file_prefixes = v })
512507 }
513508 and typ_of_dynamic_cmis =
514509 Rpc.Types.Struct
···558553 Rpc.Types.fdescription = [];
559554 Rpc.Types.fversion = None;
560555 Rpc.Types.fget = (fun _r -> _r.sc_name);
561561- Rpc.Types.fset = (fun v -> fun _s -> { _s with sc_name = v })
556556+ Rpc.Types.fset = (fun v _s -> { _s with sc_name = v })
562557 }
563558 and static_cmi_sc_content : (_, static_cmi) Rpc.Types.field =
564559 {
···568563 Rpc.Types.fdescription = [];
569564 Rpc.Types.fversion = None;
570565 Rpc.Types.fget = (fun _r -> _r.sc_content);
571571- Rpc.Types.fset = (fun v -> fun _s -> { _s with sc_content = v })
566566+ Rpc.Types.fset = (fun v _s -> { _s with sc_content = v })
572567 }
573568 and typ_of_static_cmi =
574569 Rpc.Types.Struct
···609604 Rpc.Types.fdescription = [];
610605 Rpc.Types.fversion = None;
611606 Rpc.Types.fget = (fun _r -> _r.static_cmis);
612612- Rpc.Types.fset = (fun v -> fun _s -> { _s with static_cmis = v })
607607+ Rpc.Types.fset = (fun v _s -> { _s with static_cmis = v })
613608 }
614609 and cmis_dynamic_cmis : (_, cmis) Rpc.Types.field =
615610 {
···619614 Rpc.Types.fdescription = [];
620615 Rpc.Types.fversion = None;
621616 Rpc.Types.fget = (fun _r -> _r.dynamic_cmis);
622622- Rpc.Types.fset = (fun v -> fun _s -> { _s with dynamic_cmis = v })
617617+ Rpc.Types.fset = (fun v _s -> { _s with dynamic_cmis = v })
623618 }
624619 and typ_of_cmis =
625620 Rpc.Types.Struct
···689684 Rpc.Types.fdescription = [];
690685 Rpc.Types.fversion = None;
691686 Rpc.Types.fget = (fun _r -> _r.kind);
692692- Rpc.Types.fset = (fun v -> fun _s -> { _s with kind = v })
687687+ Rpc.Types.fset = (fun v _s -> { _s with kind = v })
693688 }
694689 and error_loc : (_, error) Rpc.Types.field =
695690 {
···699694 Rpc.Types.fdescription = [];
700695 Rpc.Types.fversion = None;
701696 Rpc.Types.fget = (fun _r -> _r.loc);
702702- Rpc.Types.fset = (fun v -> fun _s -> { _s with loc = v })
697697+ Rpc.Types.fset = (fun v _s -> { _s with loc = v })
703698 }
704699 and error_main : (_, error) Rpc.Types.field =
705700 {
···709704 Rpc.Types.fdescription = [];
710705 Rpc.Types.fversion = None;
711706 Rpc.Types.fget = (fun _r -> _r.main);
712712- Rpc.Types.fset = (fun v -> fun _s -> { _s with main = v })
707707+ Rpc.Types.fset = (fun v _s -> { _s with main = v })
713708 }
714709 and error_sub : (_, error) Rpc.Types.field =
715710 {
···720715 Rpc.Types.fdescription = [];
721716 Rpc.Types.fversion = None;
722717 Rpc.Types.fget = (fun _r -> _r.sub);
723723- Rpc.Types.fset = (fun v -> fun _s -> { _s with sub = v })
718718+ Rpc.Types.fset = (fun v _s -> { _s with sub = v })
724719 }
725720 and error_source : (_, error) Rpc.Types.field =
726721 {
···730725 Rpc.Types.fdescription = [];
731726 Rpc.Types.fversion = None;
732727 Rpc.Types.fget = (fun _r -> _r.source);
733733- Rpc.Types.fset = (fun v -> fun _s -> { _s with source = v })
728728+ Rpc.Types.fset = (fun v _s -> { _s with source = v })
734729 }
735730 and typ_of_error =
736731 Rpc.Types.Struct
···915910 Rpc.Types.vdefault = None;
916911 Rpc.Types.vversion = None;
917912 Rpc.Types.vconstructor =
918918- (fun s' ->
919919- fun t ->
920920- let s = String.lowercase_ascii s' in
921921- match s with
922922- | "constructor" ->
923923- Rresult.R.bind (t.tget Unit)
924924- (function | () -> Rresult.R.ok Constructor)
925925- | "keyword" ->
926926- Rresult.R.bind (t.tget Unit)
927927- (function | () -> Rresult.R.ok Keyword)
928928- | "label" ->
929929- Rresult.R.bind (t.tget Unit)
930930- (function | () -> Rresult.R.ok Label)
931931- | "methodcall" ->
932932- Rresult.R.bind (t.tget Unit)
933933- (function | () -> Rresult.R.ok MethodCall)
934934- | "modtype" ->
935935- Rresult.R.bind (t.tget Unit)
936936- (function | () -> Rresult.R.ok Modtype)
937937- | "module" ->
938938- Rresult.R.bind (t.tget Unit)
939939- (function | () -> Rresult.R.ok Module)
940940- | "type" ->
941941- Rresult.R.bind (t.tget Unit)
942942- (function | () -> Rresult.R.ok Type)
943943- | "value" ->
944944- Rresult.R.bind (t.tget Unit)
945945- (function | () -> Rresult.R.ok Value)
946946- | "variant" ->
947947- Rresult.R.bind (t.tget Unit)
948948- (function | () -> Rresult.R.ok Variant)
949949- | _ ->
950950- Rresult.R.error_msg
951951- (Printf.sprintf "Unknown tag '%s'" s))
913913+ (fun s' t ->
914914+ let s = String.lowercase_ascii s' in
915915+ match s with
916916+ | "constructor" ->
917917+ Rresult.R.bind (t.tget Unit)
918918+ (function | () -> Rresult.R.ok Constructor)
919919+ | "keyword" ->
920920+ Rresult.R.bind (t.tget Unit)
921921+ (function | () -> Rresult.R.ok Keyword)
922922+ | "label" ->
923923+ Rresult.R.bind (t.tget Unit)
924924+ (function | () -> Rresult.R.ok Label)
925925+ | "methodcall" ->
926926+ Rresult.R.bind (t.tget Unit)
927927+ (function | () -> Rresult.R.ok MethodCall)
928928+ | "modtype" ->
929929+ Rresult.R.bind (t.tget Unit)
930930+ (function | () -> Rresult.R.ok Modtype)
931931+ | "module" ->
932932+ Rresult.R.bind (t.tget Unit)
933933+ (function | () -> Rresult.R.ok Module)
934934+ | "type" ->
935935+ Rresult.R.bind (t.tget Unit)
936936+ (function | () -> Rresult.R.ok Type)
937937+ | "value" ->
938938+ Rresult.R.bind (t.tget Unit)
939939+ (function | () -> Rresult.R.ok Value)
940940+ | "variant" ->
941941+ Rresult.R.bind (t.tget Unit)
942942+ (function | () -> Rresult.R.ok Variant)
943943+ | _ ->
944944+ Rresult.R.error_msg (Printf.sprintf "Unknown tag '%s'" s))
952945 } : kind_ty Rpc.Types.variant)
953946 and kind_ty =
954947 {
···978971 Rpc.Types.fdescription = [];
979972 Rpc.Types.fversion = None;
980973 Rpc.Types.fget = (fun _r -> _r.name);
981981- Rpc.Types.fset = (fun v -> fun _s -> { _s with name = v })
974974+ Rpc.Types.fset = (fun v _s -> { _s with name = v })
982975 }
983976 and query_protocol_compl_entry_kind :
984977 (_, query_protocol_compl_entry) Rpc.Types.field =
···989982 Rpc.Types.fdescription = [];
990983 Rpc.Types.fversion = None;
991984 Rpc.Types.fget = (fun _r -> _r.kind);
992992- Rpc.Types.fset = (fun v -> fun _s -> { _s with kind = v })
985985+ Rpc.Types.fset = (fun v _s -> { _s with kind = v })
993986 }
994987 and query_protocol_compl_entry_desc :
995988 (_, query_protocol_compl_entry) Rpc.Types.field =
···1000993 Rpc.Types.fdescription = [];
1001994 Rpc.Types.fversion = None;
1002995 Rpc.Types.fget = (fun _r -> _r.desc);
10031003- Rpc.Types.fset = (fun v -> fun _s -> { _s with desc = v })
996996+ Rpc.Types.fset = (fun v _s -> { _s with desc = v })
1004997 }
1005998 and query_protocol_compl_entry_info :
1006999 (_, query_protocol_compl_entry) Rpc.Types.field =
···10111004 Rpc.Types.fdescription = [];
10121005 Rpc.Types.fversion = None;
10131006 Rpc.Types.fget = (fun _r -> _r.info);
10141014- Rpc.Types.fset = (fun v -> fun _s -> { _s with info = v })
10071007+ Rpc.Types.fset = (fun v _s -> { _s with info = v })
10151008 }
10161009 and query_protocol_compl_entry_deprecated :
10171010 (_, query_protocol_compl_entry) Rpc.Types.field =
···10221015 Rpc.Types.fdescription = [];
10231016 Rpc.Types.fversion = None;
10241017 Rpc.Types.fget = (fun _r -> _r.deprecated);
10251025- Rpc.Types.fset = (fun v -> fun _s -> { _s with deprecated = v })
10181018+ Rpc.Types.fset = (fun v _s -> { _s with deprecated = v })
10261019 }
10271020 and typ_of_query_protocol_compl_entry =
10281021 Rpc.Types.Struct
···11031096 Rpc.Types.fdescription = [];
11041097 Rpc.Types.fversion = None;
11051098 Rpc.Types.fget = (fun _r -> _r.from);
11061106- Rpc.Types.fset = (fun v -> fun _s -> { _s with from = v })
10991099+ Rpc.Types.fset = (fun v _s -> { _s with from = v })
11071100 }
11081101 and completions_to_ : (_, completions) Rpc.Types.field =
11091102 {
···11131106 Rpc.Types.fdescription = [];
11141107 Rpc.Types.fversion = None;
11151108 Rpc.Types.fget = (fun _r -> _r.to_);
11161116- Rpc.Types.fset = (fun v -> fun _s -> { _s with to_ = v })
11091109+ Rpc.Types.fset = (fun v _s -> { _s with to_ = v })
11171110 }
11181111 and completions_entries : (_, completions) Rpc.Types.field =
11191112 {
···11231116 Rpc.Types.fdescription = [];
11241117 Rpc.Types.fversion = None;
11251118 Rpc.Types.fget = (fun _r -> _r.entries);
11261126- Rpc.Types.fset = (fun v -> fun _s -> { _s with entries = v })
11191119+ Rpc.Types.fset = (fun v _s -> { _s with entries = v })
11271120 }
11281121 and typ_of_completions =
11291122 Rpc.Types.Struct
···12281221 Rpc.Types.vdefault = None;
12291222 Rpc.Types.vversion = None;
12301223 Rpc.Types.vconstructor =
12311231- (fun s' ->
12321232- fun t ->
12331233- let s = String.lowercase_ascii s' in
12341234- match s with
12351235- | "start" ->
12361236- Rresult.R.bind (t.tget Unit)
12371237- (function | () -> Rresult.R.ok Start)
12381238- | "offset" ->
12391239- Rresult.R.bind
12401240- (t.tget (let open Rpc.Types in Basic Int))
12411241- (function | a0 -> Rresult.R.ok (Offset a0))
12421242- | "logical" ->
12431243- Rresult.R.bind
12441244- (t.tget
12451245- (Tuple
12461246- ((let open Rpc.Types in Basic Int),
12471247- (let open Rpc.Types in Basic Int))))
12481248- (function
12491249- | (a0, a1) -> Rresult.R.ok (Logical (a0, a1)))
12501250- | "end" ->
12511251- Rresult.R.bind (t.tget Unit)
12521252- (function | () -> Rresult.R.ok End)
12531253- | _ ->
12541254- Rresult.R.error_msg
12551255- (Printf.sprintf "Unknown tag '%s'" s))
12241224+ (fun s' t ->
12251225+ let s = String.lowercase_ascii s' in
12261226+ match s with
12271227+ | "start" ->
12281228+ Rresult.R.bind (t.tget Unit)
12291229+ (function | () -> Rresult.R.ok Start)
12301230+ | "offset" ->
12311231+ Rresult.R.bind (t.tget (let open Rpc.Types in Basic Int))
12321232+ (function | a0 -> Rresult.R.ok (Offset a0))
12331233+ | "logical" ->
12341234+ Rresult.R.bind
12351235+ (t.tget
12361236+ (Tuple
12371237+ ((let open Rpc.Types in Basic Int),
12381238+ (let open Rpc.Types in Basic Int))))
12391239+ (function | (a0, a1) -> Rresult.R.ok (Logical (a0, a1)))
12401240+ | "end" ->
12411241+ Rresult.R.bind (t.tget Unit)
12421242+ (function | () -> Rresult.R.ok End)
12431243+ | _ ->
12441244+ Rresult.R.error_msg (Printf.sprintf "Unknown tag '%s'" s))
12561245 } : msource_position Rpc.Types.variant)
12571246 and msource_position =
12581247 {
···13081297 Rpc.Types.vdefault = None;
13091298 Rpc.Types.vversion = None;
13101299 Rpc.Types.vconstructor =
13111311- (fun s' ->
13121312- fun t ->
13131313- let s = String.lowercase_ascii s' in
13141314- match s with
13151315- | "no" ->
13161316- Rresult.R.bind (t.tget Unit)
13171317- (function | () -> Rresult.R.ok No)
13181318- | "tail_position" ->
13191319- Rresult.R.bind (t.tget Unit)
13201320- (function | () -> Rresult.R.ok Tail_position)
13211321- | "tail_call" ->
13221322- Rresult.R.bind (t.tget Unit)
13231323- (function | () -> Rresult.R.ok Tail_call)
13241324- | _ ->
13251325- Rresult.R.error_msg
13261326- (Printf.sprintf "Unknown tag '%s'" s))
13001300+ (fun s' t ->
13011301+ let s = String.lowercase_ascii s' in
13021302+ match s with
13031303+ | "no" ->
13041304+ Rresult.R.bind (t.tget Unit)
13051305+ (function | () -> Rresult.R.ok No)
13061306+ | "tail_position" ->
13071307+ Rresult.R.bind (t.tget Unit)
13081308+ (function | () -> Rresult.R.ok Tail_position)
13091309+ | "tail_call" ->
13101310+ Rresult.R.bind (t.tget Unit)
13111311+ (function | () -> Rresult.R.ok Tail_call)
13121312+ | _ ->
13131313+ Rresult.R.error_msg (Printf.sprintf "Unknown tag '%s'" s))
13271314 } : is_tail_position Rpc.Types.variant)
13281315 and is_tail_position =
13291316 {
···13681355 Rpc.Types.vdefault = None;
13691356 Rpc.Types.vversion = None;
13701357 Rpc.Types.vconstructor =
13711371- (fun s' ->
13721372- fun t ->
13731373- let s = String.lowercase_ascii s' in
13741374- match s with
13751375- | "index" ->
13761376- Rresult.R.bind
13771377- (t.tget (let open Rpc.Types in Basic Int))
13781378- (function | a0 -> Rresult.R.ok (Index a0))
13791379- | "string" ->
13801380- Rresult.R.bind
13811381- (t.tget (let open Rpc.Types in Basic String))
13821382- (function | a0 -> Rresult.R.ok (String a0))
13831383- | _ ->
13841384- Rresult.R.error_msg
13851385- (Printf.sprintf "Unknown tag '%s'" s))
13581358+ (fun s' t ->
13591359+ let s = String.lowercase_ascii s' in
13601360+ match s with
13611361+ | "index" ->
13621362+ Rresult.R.bind (t.tget (let open Rpc.Types in Basic Int))
13631363+ (function | a0 -> Rresult.R.ok (Index a0))
13641364+ | "string" ->
13651365+ Rresult.R.bind
13661366+ (t.tget (let open Rpc.Types in Basic String))
13671367+ (function | a0 -> Rresult.R.ok (String a0))
13681368+ | _ ->
13691369+ Rresult.R.error_msg (Printf.sprintf "Unknown tag '%s'" s))
13861370 } : index_or_string Rpc.Types.variant)
13871371 and index_or_string =
13881372 {
···14501434 Rpc.Types.fdescription = [];
14511435 Rpc.Types.fversion = None;
14521436 Rpc.Types.fget = (fun _r -> _r.line1);
14531453- Rpc.Types.fset = (fun v -> fun _s -> { _s with line1 = v })
14371437+ Rpc.Types.fset = (fun v _s -> { _s with line1 = v })
14541438 }
14551439 and highlight_line2 : (_, highlight) Rpc.Types.field =
14561440 {
···14601444 Rpc.Types.fdescription = [];
14611445 Rpc.Types.fversion = None;
14621446 Rpc.Types.fget = (fun _r -> _r.line2);
14631463- Rpc.Types.fset = (fun v -> fun _s -> { _s with line2 = v })
14471447+ Rpc.Types.fset = (fun v _s -> { _s with line2 = v })
14641448 }
14651449 and highlight_col1 : (_, highlight) Rpc.Types.field =
14661450 {
···14701454 Rpc.Types.fdescription = [];
14711455 Rpc.Types.fversion = None;
14721456 Rpc.Types.fget = (fun _r -> _r.col1);
14731473- Rpc.Types.fset = (fun v -> fun _s -> { _s with col1 = v })
14571457+ Rpc.Types.fset = (fun v _s -> { _s with col1 = v })
14741458 }
14751459 and highlight_col2 : (_, highlight) Rpc.Types.field =
14761460 {
···14801464 Rpc.Types.fdescription = [];
14811465 Rpc.Types.fversion = None;
14821466 Rpc.Types.fget = (fun _r -> _r.col2);
14831483- Rpc.Types.fset = (fun v -> fun _s -> { _s with col2 = v })
14671467+ Rpc.Types.fset = (fun v _s -> { _s with col2 = v })
14841468 }
14851469 and typ_of_highlight =
14861470 Rpc.Types.Struct
···15661550 Rpc.Types.vdefault = None;
15671551 Rpc.Types.vversion = None;
15681552 Rpc.Types.vconstructor =
15691569- (fun s' ->
15701570- fun t ->
15711571- let s = String.lowercase_ascii s' in
15721572- match s with
15731573- | "noencoding" ->
15741574- Rresult.R.bind (t.tget Unit)
15751575- (function | () -> Rresult.R.ok Noencoding)
15761576- | "base64" ->
15771577- Rresult.R.bind (t.tget Unit)
15781578- (function | () -> Rresult.R.ok Base64)
15791579- | _ ->
15801580- Rresult.R.error_msg
15811581- (Printf.sprintf "Unknown tag '%s'" s))
15531553+ (fun s' t ->
15541554+ let s = String.lowercase_ascii s' in
15551555+ match s with
15561556+ | "noencoding" ->
15571557+ Rresult.R.bind (t.tget Unit)
15581558+ (function | () -> Rresult.R.ok Noencoding)
15591559+ | "base64" ->
15601560+ Rresult.R.bind (t.tget Unit)
15611561+ (function | () -> Rresult.R.ok Base64)
15621562+ | _ ->
15631563+ Rresult.R.error_msg (Printf.sprintf "Unknown tag '%s'" s))
15821564 } : encoding Rpc.Types.variant)
15831565 and encoding =
15841566 {
···16051587 Rpc.Types.fdescription = [];
16061588 Rpc.Types.fversion = None;
16071589 Rpc.Types.fget = (fun _r -> _r.mime_type);
16081608- Rpc.Types.fset = (fun v -> fun _s -> { _s with mime_type = v })
15901590+ Rpc.Types.fset = (fun v _s -> { _s with mime_type = v })
16091591 }
16101592 and mime_val_encoding : (_, mime_val) Rpc.Types.field =
16111593 {
···16151597 Rpc.Types.fdescription = [];
16161598 Rpc.Types.fversion = None;
16171599 Rpc.Types.fget = (fun _r -> _r.encoding);
16181618- Rpc.Types.fset = (fun v -> fun _s -> { _s with encoding = v })
16001600+ Rpc.Types.fset = (fun v _s -> { _s with encoding = v })
16191601 }
16201602 and mime_val_data : (_, mime_val) Rpc.Types.field =
16211603 {
···16251607 Rpc.Types.fdescription = [];
16261608 Rpc.Types.fversion = None;
16271609 Rpc.Types.fget = (fun _r -> _r.data);
16281628- Rpc.Types.fset = (fun v -> fun _s -> { _s with data = v })
16101610+ Rpc.Types.fset = (fun v _s -> { _s with data = v })
16291611 }
16301612 and typ_of_mime_val =
16311613 Rpc.Types.Struct
···16901672 Rpc.Types.fdescription = [];
16911673 Rpc.Types.fversion = None;
16921674 Rpc.Types.fget = (fun _r -> _r.stdout);
16931693- Rpc.Types.fset = (fun v -> fun _s -> { _s with stdout = v })
16751675+ Rpc.Types.fset = (fun v _s -> { _s with stdout = v })
16941676 }
16951677 and exec_result_stderr : (_, exec_result) Rpc.Types.field =
16961678 {
···17011683 Rpc.Types.fdescription = [];
17021684 Rpc.Types.fversion = None;
17031685 Rpc.Types.fget = (fun _r -> _r.stderr);
17041704- Rpc.Types.fset = (fun v -> fun _s -> { _s with stderr = v })
16861686+ Rpc.Types.fset = (fun v _s -> { _s with stderr = v })
17051687 }
17061688 and exec_result_sharp_ppf : (_, exec_result) Rpc.Types.field =
17071689 {
···17121694 Rpc.Types.fdescription = [];
17131695 Rpc.Types.fversion = None;
17141696 Rpc.Types.fget = (fun _r -> _r.sharp_ppf);
17151715- Rpc.Types.fset = (fun v -> fun _s -> { _s with sharp_ppf = v })
16971697+ Rpc.Types.fset = (fun v _s -> { _s with sharp_ppf = v })
17161698 }
17171699 and exec_result_caml_ppf : (_, exec_result) Rpc.Types.field =
17181700 {
···17231705 Rpc.Types.fdescription = [];
17241706 Rpc.Types.fversion = None;
17251707 Rpc.Types.fget = (fun _r -> _r.caml_ppf);
17261726- Rpc.Types.fset = (fun v -> fun _s -> { _s with caml_ppf = v })
17081708+ Rpc.Types.fset = (fun v _s -> { _s with caml_ppf = v })
17271709 }
17281710 and exec_result_highlight : (_, exec_result) Rpc.Types.field =
17291711 {
···17331715 Rpc.Types.fdescription = [];
17341716 Rpc.Types.fversion = None;
17351717 Rpc.Types.fget = (fun _r -> _r.highlight);
17361736- Rpc.Types.fset = (fun v -> fun _s -> { _s with highlight = v })
17181718+ Rpc.Types.fset = (fun v _s -> { _s with highlight = v })
17371719 }
17381720 and exec_result_mime_vals : (_, exec_result) Rpc.Types.field =
17391721 {
···17431725 Rpc.Types.fdescription = [];
17441726 Rpc.Types.fversion = None;
17451727 Rpc.Types.fget = (fun _r -> _r.mime_vals);
17461746- Rpc.Types.fset = (fun v -> fun _s -> { _s with mime_vals = v })
17281728+ Rpc.Types.fset = (fun v _s -> { _s with mime_vals = v })
17471729 }
17481730 and typ_of_exec_result =
17491731 Rpc.Types.Struct
···18231805 and _ = typ_of_exec_result
18241806 and _ = exec_result
18251807 end[@@ocaml.doc "@inline"][@@merlin.hide ]
18261826-type exec_toplevel_result = {
18081808+type script_parts = (int * int) list[@@deriving rpcty]
18091809+include
18101810+ struct
18111811+ let _ = fun (_ : script_parts) -> ()
18121812+ let rec typ_of_script_parts =
18131813+ Rpc.Types.List
18141814+ (Rpc.Types.Tuple
18151815+ ((let open Rpc.Types in Basic Int),
18161816+ (let open Rpc.Types in Basic Int)))
18171817+ and script_parts =
18181818+ {
18191819+ Rpc.Types.name = "script_parts";
18201820+ Rpc.Types.description = [];
18211821+ Rpc.Types.ty = typ_of_script_parts
18221822+ }
18231823+ let _ = typ_of_script_parts
18241824+ and _ = script_parts
18251825+ end[@@ocaml.doc "@inline"][@@merlin.hide ]
18261826+type exec_toplevel_result =
18271827+ {
18271828 script: string ;
18291829+ parts: script_parts ;
18281830 mime_vals: mime_val list }[@@deriving rpcty][@@ocaml.doc
18291831 " Represents the result of executing a toplevel script "]
18301832include
···18391841 Rpc.Types.fdescription = [];
18401842 Rpc.Types.fversion = None;
18411843 Rpc.Types.fget = (fun _r -> _r.script);
18421842- Rpc.Types.fset = (fun v -> fun _s -> { _s with script = v })
18441844+ Rpc.Types.fset = (fun v _s -> { _s with script = v })
18451845+ }
18461846+ and exec_toplevel_result_parts :
18471847+ (_, exec_toplevel_result) Rpc.Types.field =
18481848+ {
18491849+ Rpc.Types.fname = "parts";
18501850+ Rpc.Types.field = typ_of_script_parts;
18511851+ Rpc.Types.fdefault = None;
18521852+ Rpc.Types.fdescription = [];
18531853+ Rpc.Types.fversion = None;
18541854+ Rpc.Types.fget = (fun _r -> _r.parts);
18551855+ Rpc.Types.fset = (fun v _s -> { _s with parts = v })
18431856 }
18441857 and exec_toplevel_result_mime_vals :
18451858 (_, exec_toplevel_result) Rpc.Types.field =
···18501863 Rpc.Types.fdescription = [];
18511864 Rpc.Types.fversion = None;
18521865 Rpc.Types.fget = (fun _r -> _r.mime_vals);
18531853- Rpc.Types.fset = (fun v -> fun _s -> { _s with mime_vals = v })
18661866+ Rpc.Types.fset = (fun v _s -> { _s with mime_vals = v })
18541867 }
18551868 and typ_of_exec_toplevel_result =
18561869 Rpc.Types.Struct
18571870 ({
18581871 Rpc.Types.fields =
18591872 [Rpc.Types.BoxedField exec_toplevel_result_script;
18731873+ Rpc.Types.BoxedField exec_toplevel_result_parts;
18601874 Rpc.Types.BoxedField exec_toplevel_result_mime_vals];
18611875 Rpc.Types.sname = "exec_toplevel_result";
18621876 Rpc.Types.version = None;
···18671881 (Rpc.Types.List typ_of_mime_val))
18681882 >>=
18691883 (fun exec_toplevel_result_mime_vals ->
18701870- (getter.Rpc.Types.field_get "script"
18711871- (let open Rpc.Types in Basic String))
18841884+ (getter.Rpc.Types.field_get "parts"
18851885+ typ_of_script_parts)
18721886 >>=
18731873- (fun exec_toplevel_result_script ->
18741874- return
18751875- {
18761876- script = exec_toplevel_result_script;
18771877- mime_vals = exec_toplevel_result_mime_vals
18781878- })))
18871887+ (fun exec_toplevel_result_parts ->
18881888+ (getter.Rpc.Types.field_get "script"
18891889+ (let open Rpc.Types in Basic String))
18901890+ >>=
18911891+ (fun exec_toplevel_result_script ->
18921892+ return
18931893+ {
18941894+ script = exec_toplevel_result_script;
18951895+ parts = exec_toplevel_result_parts;
18961896+ mime_vals =
18971897+ exec_toplevel_result_mime_vals
18981898+ }))))
18791899 } : exec_toplevel_result Rpc.Types.structure)
18801900 and exec_toplevel_result =
18811901 {
···18851905 Rpc.Types.ty = typ_of_exec_toplevel_result
18861906 }
18871907 let _ = exec_toplevel_result_script
19081908+ and _ = exec_toplevel_result_parts
18881909 and _ = exec_toplevel_result_mime_vals
18891910 and _ = typ_of_exec_toplevel_result
18901911 and _ = exec_toplevel_result
···19051926 Rpc.Types.fdescription = ["URL where the cma is available"];
19061927 Rpc.Types.fversion = None;
19071928 Rpc.Types.fget = (fun _r -> _r.url);
19081908- Rpc.Types.fset = (fun v -> fun _s -> { _s with url = v })
19291929+ Rpc.Types.fset = (fun v _s -> { _s with url = v })
19091930 }
19101931 and cma_fn : (_, cma) Rpc.Types.field =
19111932 {
···19151936 Rpc.Types.fdescription = ["Name of the 'wrapping' function"];
19161937 Rpc.Types.fversion = None;
19171938 Rpc.Types.fget = (fun _r -> _r.fn);
19181918- Rpc.Types.fset = (fun v -> fun _s -> { _s with fn = v })
19391939+ Rpc.Types.fset = (fun v _s -> { _s with fn = v })
19191940 }
19201941 and typ_of_cma =
19211942 Rpc.Types.Struct
···19671988 Rpc.Types.fdescription = [];
19681989 Rpc.Types.fversion = None;
19691990 Rpc.Types.fget = (fun _r -> _r.path);
19701970- Rpc.Types.fset = (fun v -> fun _s -> { _s with path = v })
19911991+ Rpc.Types.fset = (fun v _s -> { _s with path = v })
19711992 }
19721993 and init_libs_cmis : (_, init_libs) Rpc.Types.field =
19731994 {
···19771998 Rpc.Types.fdescription = [];
19781999 Rpc.Types.fversion = None;
19792000 Rpc.Types.fget = (fun _r -> _r.cmis);
19801980- Rpc.Types.fset = (fun v -> fun _s -> { _s with cmis = v })
20012001+ Rpc.Types.fset = (fun v _s -> { _s with cmis = v })
19812002 }
19822003 and init_libs_cmas : (_, init_libs) Rpc.Types.field =
19832004 {
···19872008 Rpc.Types.fdescription = [];
19882009 Rpc.Types.fversion = None;
19892010 Rpc.Types.fget = (fun _r -> _r.cmas);
19901990- Rpc.Types.fset = (fun v -> fun _s -> { _s with cmas = v })
20112011+ Rpc.Types.fset = (fun v _s -> { _s with cmas = v })
19912012 }
19922013 and init_libs_findlib_index : (_, init_libs) Rpc.Types.field =
19932014 {
···19972018 Rpc.Types.fdescription = [];
19982019 Rpc.Types.fversion = None;
19992020 Rpc.Types.fget = (fun _r -> _r.findlib_index);
20002000- Rpc.Types.fset = (fun v -> fun _s -> { _s with findlib_index = v })
20212021+ Rpc.Types.fset = (fun v _s -> { _s with findlib_index = v })
20012022 }
20022023 and init_libs_findlib_requires : (_, init_libs) Rpc.Types.field =
20032024 {
···20082029 Rpc.Types.fdescription = [];
20092030 Rpc.Types.fversion = None;
20102031 Rpc.Types.fget = (fun _r -> _r.findlib_requires);
20112011- Rpc.Types.fset =
20122012- (fun v -> fun _s -> { _s with findlib_requires = v })
20322032+ Rpc.Types.fset = (fun v _s -> { _s with findlib_requires = v })
20132033 }
20142034 and init_libs_stdlib_dcs : (_, init_libs) Rpc.Types.field =
20152035 {
···20192039 Rpc.Types.fdescription = [];
20202040 Rpc.Types.fversion = None;
20212041 Rpc.Types.fget = (fun _r -> _r.stdlib_dcs);
20222022- Rpc.Types.fset = (fun v -> fun _s -> { _s with stdlib_dcs = v })
20422042+ Rpc.Types.fset = (fun v _s -> { _s with stdlib_dcs = v })
20232043 }
20242044 and typ_of_init_libs =
20252045 Rpc.Types.Struct
···21142134 Rpc.Types.vdefault = None;
21152135 Rpc.Types.vversion = None;
21162136 Rpc.Types.vconstructor =
21172117- (fun s' ->
21182118- fun t ->
21192119- let s = String.lowercase_ascii s' in
21202120- match s with
21212121- | "internalerror" ->
21222122- Rresult.R.bind
21232123- (t.tget (let open Rpc.Types in Basic String))
21242124- (function | a0 -> Rresult.R.ok (InternalError a0))
21252125- | _ ->
21262126- Rresult.R.error_msg
21272127- (Printf.sprintf "Unknown tag '%s'" s))
21372137+ (fun s' t ->
21382138+ let s = String.lowercase_ascii s' in
21392139+ match s with
21402140+ | "internalerror" ->
21412141+ Rresult.R.bind
21422142+ (t.tget (let open Rpc.Types in Basic String))
21432143+ (function | a0 -> Rresult.R.ok (InternalError a0))
21442144+ | _ ->
21452145+ Rresult.R.error_msg (Printf.sprintf "Unknown tag '%s'" s))
21282146 } : err Rpc.Types.variant)
21292147 and err =
21302148 {
···21502168 let _ = typ_of_opt_id
21512169 and _ = opt_id
21522170 end[@@ocaml.doc "@inline"][@@merlin.hide ]
21712171+type dependencies = string list[@@deriving rpcty][@@ocaml.doc
21722172+ " The ids of the cells that are dependencies "]
21732173+include
21742174+ struct
21752175+ let _ = fun (_ : dependencies) -> ()
21762176+ let rec typ_of_dependencies =
21772177+ Rpc.Types.List (let open Rpc.Types in Basic String)
21782178+ and dependencies =
21792179+ {
21802180+ Rpc.Types.name = "dependencies";
21812181+ Rpc.Types.description =
21822182+ ["The ids of the cells that are dependencies"];
21832183+ Rpc.Types.ty = typ_of_dependencies
21842184+ }
21852185+ let _ = typ_of_dependencies
21862186+ and _ = dependencies
21872187+ end[@@ocaml.doc "@inline"][@@merlin.hide ]
21532188module E =
21542189 (Idl.Error.Make)(struct
21552190 type t = err
···21742209 let unit_p = Param.mk Types.unit
21752210 let phrase_p = Param.mk Types.string
21762211 let id_p = Param.mk opt_id
22122212+ let dependencies_p = Param.mk dependencies
21772213 let typecheck_result_p = Param.mk exec_result
21782214 let exec_result_p = Param.mk exec_result
21792215 let source_p = Param.mk source
···21812217 let completions_p = Param.mk completions
21822218 let error_list_p = Param.mk error_list
21832219 let typed_enclosings_p = Param.mk typed_enclosings_list
22202220+ let is_toplevel_p = Param.mk ~name:"is_toplevel" Types.bool
21842221 let toplevel_script_p =
21852222 Param.mk
21862223 ~description:["A toplevel script is a sequence of toplevel phrases interspersed with";
···22242261 (id_p @-> (phrase_p @-> (returning phrase_p err)))
22252262 let complete_prefix =
22262263 declare "complete_prefix" ["Complete a prefix"]
22272227- (source_p @-> (position_p @-> (returning completions_p err)))
22642264+ (id_p @->
22652265+ (dependencies_p @->
22662266+ (source_p @-> (position_p @-> (returning completions_p err)))))
22282267 let query_errors =
22292268 declare "query_errors" ["Query the errors in the given source"]
22302230- (source_p @-> (returning error_list_p err))
22692269+ (id_p @->
22702270+ (dependencies_p @->
22712271+ (is_toplevel_p @-> (source_p @-> (returning error_list_p err)))))
22312272 let type_enclosing =
22322273 declare "type_enclosing" ["Get the type of the enclosing expression"]
22332233- (source_p @-> (position_p @-> (returning typed_enclosings_p err)))
22742274+ (id_p @->
22752275+ (dependencies_p @->
22762276+ (source_p @->
22772277+ (position_p @-> (returning typed_enclosings_p err)))))
22342278 end
···5566type captured = { stdout : string; stderr : string }
7788+let modname_of_id id = "Cell__" ^ id
99+810module JsooTopPpx = struct
911 open Js_of_ocaml_compiler.Stdlib
1012···206208 let filename_of_module unit_name =
207209 Printf.sprintf "%s.cmi" (String.uncapitalize_ascii unit_name)
208210211211+ let get_dirs () =
212212+ let {Load_path.visible; hidden} = Load_path.get_paths () in
213213+ visible @ hidden
214214+209215 let reset_dirs () =
210216 Ocaml_utils.Directory_content_cache.clear ();
211217 let open Ocaml_utils.Load_path in
212212- let dirs = get_paths () in
218218+ let dirs = get_dirs () in
213219 reset ();
214214- List.iter (fun p -> prepend_dir (Dir.create p)) dirs
220220+ List.iter (fun p -> prepend_dir (Dir.create ~hidden:false p)) dirs
215221216222 let reset_dirs_comp () =
217223 let open Load_path in
218218- let dirs = get_paths () in
224224+ let dirs = get_dirs () in
219225 reset ();
220220- List.iter (fun p -> prepend_dir (Dir.create p)) dirs
226226+ List.iter (fun p -> prepend_dir (Dir.create ~hidden:false p)) dirs
221227222228 let add_dynamic_cmis dcs =
223229 let fetch filename =
···238244 | None -> ())
239245 dcs.dcs_toplevel_modules;
240246241241- let new_load ~s ~old_loader ~unit_name =
247247+ let new_load ~s ~old_loader ~allow_hidden ~unit_name =
242248 Logs.info (fun m -> m "%s Loading: %s" s unit_name);
243249 let filename = filename_of_module unit_name in
244250···263269 | None ->
264270 Printf.eprintf "Warning: Expected to find cmi at: %s\n%!"
265271 (Filename.concat dcs.Toplevel_api_gen.dcs_url filename));
266266- old_loader ~unit_name
272272+ old_loader ~allow_hidden ~unit_name
267273 in
268274 let furl = "file://" in
269275 let l = String.length furl in
···462468 Logs.info (fun m -> m "Simplif...");
463469 let slam = Simplif.simplify_lambda lam in
464470 Logs.info (fun m -> m "Bytegen...");
465465- let init_code, fun_code = Bytegen.compile_phrase slam in
471471+ let code, _can_free = Bytegen.compile_phrase slam in
466472 Logs.info (fun m -> m "Emitcode...");
467467- let code, reloc, _events = Emitcode.to_memory init_code fun_code in
473473+ let code, reloc, _events = Emitcode.to_memory code in
468474 Toploop.toplevel_env := newenv;
469475 (* let prims = split_primitives (Symtable.data_primitive_names ()) in *)
470476 let b = Buffer.create 100 in
471477 let cmo =
472478 Cmo_format.
473479 {
474474- cu_name = "test";
480480+ cu_name = Compunit "test";
475481 cu_pos = 0;
476476- cu_codesize = Misc.LongString.length code;
482482+ cu_codesize = Bigarray.Array1.dim code;
477483 cu_reloc = reloc;
478484 cu_imports = [];
479479- cu_required_globals = [];
485485+ cu_required_compunits = [];
480486 cu_primitives = [];
481487 cu_force_link = false;
482488 cu_debug = 0;
···489495 Symtable.check_global_initialized reloc;
490496 Symtable.update_global_table(); *)
491497 let oc = open_out "/tmp/test.cmo" in
492492- Misc.LongString.output oc code 0 (Misc.LongString.length code);
498498+ Emitcode.marshal_to_channel_with_possibly_32bit_compat ~filename:"/tmp/test.cmo" ~kind:"bytecode unit" oc cmo;
493499494500 (* let code = String.init (Misc.LongString.length code) ~f:(fun i -> Misc.LongString.get code i) in *)
495501 close_out oc;
···516522 then (
517523 Printf.eprintf
518524 "Warning, ignoring toplevel block without a leading '# '.\n";
519519- IdlM.ErrM.return { Toplevel_api_gen.script = stripped; mime_vals = [] })
525525+ IdlM.ErrM.return { Toplevel_api_gen.script = stripped; mime_vals = []; parts=[] })
520526 else
521527 let s = String.sub stripped 2 (String.length stripped - 2) in
522528 let list = Ocamltop.parse_toplevel s in
523529 let buf = Buffer.create 1024 in
524530 let mime_vals =
525531 List.fold_left
526526- (fun acc (phr, _output) ->
532532+ (fun acc (phr, _junk, _output) ->
527533 let new_output =
528534 execute phr |> IdlM.T.get |> M.run |> Result.get_ok
529535 in
···545551 let content_txt =
546552 String.sub content_txt 0 (String.length content_txt - 1)
547553 in
548548- let result = { Toplevel_api_gen.script = content_txt; mime_vals } in
554554+ let result = { Toplevel_api_gen.script = content_txt; mime_vals; parts=[] } in
549555 IdlM.ErrM.return result
550556551557 let exec_toplevel (phrase : string) = handle_toplevel phrase
···660666 Some (from, to_, wdispatch source query)
661667 end
662668663663- let complete_prefix source position =
669669+670670+ let complete_prefix _id _deps source position =
664671 let source = Merlin_kernel.Msource.make source in
665672 let map_kind :
666673 [ `Value
···708715 | None ->
709716 IdlM.ErrM.return { Toplevel_api_gen.from = 0; to_ = 0; entries = [] }
710717711711- let query_errors source =
718718+ let add_cmi id deps source =
719719+ Logs.info (fun m -> m "add_cmi");
720720+ let dep_modules = List.map modname_of_id deps in
721721+ let loc = Location.none in
722722+ let env = Typemod.initial_env ~loc ~initially_opened_module:(Some "Stdlib") ~open_implicit_modules:dep_modules in
723723+ let path =
724724+ match !path with Some p -> p | None -> failwith "Path not set"
725725+ in
726726+ let prefix = Printf.sprintf "%s/%s" path (modname_of_id id) in
727727+ let filename = Printf.sprintf "%s.ml" prefix in
728728+ Logs.info (fun m -> m "prefix: %s\n%!" prefix);
729729+ let oc = open_out filename in
730730+ Printf.fprintf oc "%s" source;
731731+ close_out oc;
732732+ let unit_info = Unit_info.make ~source_file:filename prefix in
712733 try
713713- let source = Merlin_kernel.Msource.make source in
734734+ Logs.info (fun m -> m "Parsing...\n%!");
735735+ let lexbuf = Lexing.from_string source in
736736+ let ast = Parse.implementation lexbuf in
737737+ Logs.info (fun m -> m "got ast\n%!");
738738+ let _ = Typemod.type_implementation unit_info env ast in
739739+ Logs.info (fun m -> m "typed\n%!");
740740+ let b = Sys.file_exists (prefix ^ ".cmi") in
741741+ Logs.info (fun m -> m "b: %b\n%!" b);
742742+ (* reset_dirs () *) ()
743743+ with exn ->
744744+ let s = Printexc.to_string exn in
745745+ Logs.err (fun m -> m "Error in add_cmi: %s" s);
746746+ let ppf = Format.err_formatter in
747747+ let _ = Location.report_exception ppf exn in
748748+ ()
749749+750750+ let mangle_toplevel orig_source =
751751+ if String.length orig_source < 2 || orig_source.[0] <> '#' || orig_source.[1] <> ' '
752752+ then (Logs.err (fun m -> m "Warning, ignoring toplevel block without a leading '# '.\n%!"); orig_source)
753753+ else begin
754754+ try
755755+ let s = String.sub orig_source 2 (String.length orig_source - 2) in
756756+ let list = Ocamltop.parse_toplevel s in
757757+ let buff = Buffer.create 100 in
758758+ List.iter (fun (phr, junk, output) ->
759759+ Printf.bprintf buff " %s%s\n" phr (String.make (String.length junk) ' ');
760760+ List.iter (fun x ->
761761+ Printf.bprintf buff " %s\n" (String.make (String.length x) ' ')) output) list;
762762+ Buffer.contents buff
763763+ with e ->
764764+ Logs.err (fun m -> m "Error in mangle_toplevel: %s" (Printexc.to_string e));
765765+ let ppf = Format.err_formatter in
766766+ let _ = Location.report_exception ppf e in
767767+ orig_source
768768+ end
769769+770770+ let query_errors id deps is_toplevel orig_source =
771771+ try
772772+ Logs.info (fun m -> m "About to mangle toplevel");
773773+ let src = if is_toplevel then mangle_toplevel orig_source else orig_source in
774774+ Logs.info (fun m -> m "src: %s" src);
775775+ let id = Option.get id in
776776+ let line1 = List.map (fun id ->
777777+ Printf.sprintf "open %s" (modname_of_id id)) deps |> String.concat " " in
778778+ let line1 = line1 ^ "\n" in
779779+ let source = Merlin_kernel.Msource.make (line1 ^ src) in
714780 let query =
715781 Query_protocol.Errors { lexing = true; parsing = true; typing = true }
716782 in
···726792 String.trim (Format.flush_str_formatter ())
727793 in
728794 let loc = Ocaml_parsing.Location.loc_of_report error in
795795+ let map_pos pos =
796796+ Lexing.{ pos with
797797+ pos_bol = pos.pos_bol - String.length line1;
798798+ pos_lnum = pos.pos_lnum - 1;
799799+ pos_cnum = pos.pos_cnum - String.length line1;
800800+ } in
801801+ let loc = { loc with
802802+ Ocaml_utils.Warnings.loc_start = map_pos loc.loc_start;
803803+ Ocaml_utils.Warnings.loc_end = map_pos loc.loc_end;
804804+ } in
729805 let main =
730806 Format.asprintf "@[%a@]" Ocaml_parsing.Location.print_main
731807 error
···739815 source;
740816 })
741817 in
818818+ if List.length errors = 0 then
819819+ add_cmi id deps src;
820820+ Logs.info (fun m -> m "Got to end");
742821 IdlM.ErrM.return errors
743822 with e ->
823823+ Logs.info (fun m -> m "Error: %s" (Printexc.to_string e));
744824 IdlM.ErrM.return_err
745825 (Toplevel_api_gen.InternalError (Printexc.to_string e))
746826747747- let type_enclosing source position =
827827+ let type_enclosing _id _deps source position =
748828 let position =
749829 match position with
750830 | Toplevel_api_gen.Start -> `Start
+2-2
lib/ocamltop.ml
···1616 let _phr = !Toploop.parse_toplevel_phrase lexbuf in
1717 let new_pos = Lexing.lexeme_end lexbuf in
1818 let phr = String.sub s pos (new_pos - pos) in
1919- let cont, is_legacy, output = Toplexer.entry lexbuf in
1919+ let (junk, (cont, is_legacy, output)) = Toplexer.entry lexbuf in
2020 if is_legacy then
2121 Logs.warn (fun m -> m "Warning: Legacy toplevel output detected");
2222 let new_pos = Lexing.lexeme_end lexbuf in
2323- if cont then (phr, output) :: loop new_pos else [ (phr, output) ]
2323+ if cont then (phr, junk, output) :: loop new_pos else [ (phr, junk, output) ]
2424 in
2525 loop 0
···69697070module M = Impl.Make (S)
71717272+let test () =
7373+ let oc = open_out "/tmp/mytest.txt" in
7474+ Printf.fprintf oc "Hello, world\n%!";
7575+ close_out oc
7676+7277let run () =
7378 (* Here we bind the server stub functions to the implementations *)
7479 let open Js_of_ocaml in
···7681 try
7782 Console.console##log (Js.string "Starting worker...");
78838484+ let _ = test () in
7985 Logs.set_reporter (Logs_browser.console_reporter ());
8086 Logs.set_level (Some Logs.Info);
8187 Server.exec execute;
+9-7
test/cram/simple.t/run.t
···66 unix_worker: [INFO] Setup complete
77 unix_worker: [INFO] setup() finished
88 {mime_vals:[];stderr:S(error while evaluating #enable "pretty";;
99- error while evaluating #disable "shortvar";;);stdout:S(OCaml version 5.1.0
1010- Unknown directive `enable'.
1111- Unknown directive `disable'.)}
99+ error while evaluating #disable "shortvar";;);stdout:S(OCaml version 5.2.0
1010+ Unknown directive enable.
1111+ Unknown directive disable.)}
1212 unix_worker: [WARNING] Parsing toplevel phrases
1313- {mime_vals:[];script:S(# Printf.printf "Hello, world\n";;
1313+ {mime_vals:[];parts:[];script:S(# Printf.printf "Hello, world\n";;
1414 Hello, world
1515 - : unit = ())}
1616 unix_worker: [WARNING] Parsing toplevel phrases
1717 unix_worker: [WARNING] Warning: Legacy toplevel output detected
1818 unix_worker: [WARNING] Warning: Legacy toplevel output detected
1919- {mime_vals:[];script:S(# let x = 1 + 2;;
1919+ {mime_vals:[];parts:[];script:S(# let x = 1 + 2;;
2020 val x : int = 3
2121 # let x = 2+3;;
2222 val x : int = 5)}
2323 unix_worker: [WARNING] Parsing toplevel phrases
2424- {mime_vals:[];script:S(# let x = 1 + 2;;
2525- val x : int = 3)}
2424+ {mime_vals:[];parts:[];script:S(# let x = 1 + 2;;
2525+ val x : int = 3
2626+ # let x = 2+3;;
2727+ val x : int = 5)}