File tree Expand file tree Collapse file tree 12 files changed +114
-11
lines changed
Expand file tree Collapse file tree 12 files changed +114
-11
lines changed Original file line number Diff line number Diff line change 44 (flags
55 :standard
66 -open Ocaml_parsing
7+ -open Ocaml_utils
78 -open Merlin_utils
89 -open Merlin_kernel)
910 (libraries
1011 merlin-lib.ocaml_parsing
1112 merlin-lib.utils
1213 merlin-lib.kernel
1314 merlin-lib.query_protocol
14- merlin-lib.query_commands))
15+ merlin-lib.query_commands
16+ merlin-lib.ocaml_utils))
Original file line number Diff line number Diff line change @@ -867,6 +867,11 @@ let all_commands =
867867 run buffer (Query_protocol. Signature_help sh)
868868 end;
869869 (* Used only for testing *)
870+ command " version" ~spec: [] ~default: () ~doc: " Print version information"
871+ begin
872+ fun buffer () -> run buffer Query_protocol. Version
873+ end;
874+ (* Used only for testing *)
870875 command " dump"
871876 ~spec:
872877 [ arg " -what"
Original file line number Diff line number Diff line change @@ -514,4 +514,8 @@ let json_of_response (type a) (query : a t) (response : a) : json =
514514 let with_file = scope = `Project in
515515 `List (List. map locations ~f: (fun loc -> with_location ~with_file loc [] ))
516516 | Signature_help _ , s -> json_of_signature_help s
517- | Version , version -> `String version
517+ | Version , (version , magic_numbers ) ->
518+ `Assoc
519+ [ (" version" , `String version);
520+ (" magicNumbers" , Config.Magic_numbers. to_json magic_numbers)
521+ ]
Original file line number Diff line number Diff line change 22 (name query_protocol)
33 (public_name merlin-lib.query_protocol)
44 (modules query_protocol)
5- (flags :standard -open Merlin_utils -open Merlin_kernel -open Ocaml_parsing -open Merlin_kernel )
6- (libraries merlin_kernel merlin_utils ocaml_parsing))
5+ (flags :standard -open Merlin_utils -open Merlin_kernel -open Ocaml_parsing -open Ocaml_utils )
6+ (libraries merlin_kernel merlin_utils ocaml_parsing ocaml_utils ))
77
88(library
99 (name query_commands)
Original file line number Diff line number Diff line change @@ -978,5 +978,9 @@ let dispatch pipeline (type a) : a Query_protocol.t -> a = function
978978 }
979979 | None -> None )
980980 | Version ->
981- Printf. sprintf " The Merlin toolkit version %s, for Ocaml %s\n "
982- Merlin_config. version Sys. ocaml_version
981+ let version =
982+ Printf. sprintf " The Merlin toolkit version %s, for Ocaml %s\n "
983+ Merlin_config. version Sys. ocaml_version
984+ in
985+ let magic_numbers = Config.Magic_numbers. current in
986+ (version, magic_numbers)
Original file line number Diff line number Diff line change @@ -272,4 +272,4 @@ type _ t =
272272 (* * In current version, Merlin only uses the parameter [position] to answer
273273 signature_help queries. The additionnal parameters are described in the
274274 LSP protocol and might enable finer behaviour in the future. *)
275- | Version : string t
275+ | Version : ( string * Config.Magic_numbers .t ) t
Original file line number Diff line number Diff line change 22 (name ocaml_index)
33 (public_name ocaml-index)
44 (package ocaml-index)
5- (libraries lib ocaml_typing ocaml_utils merlin_index_format)
5+ (libraries lib ocaml_typing ocaml_utils merlin_index_format merlin_utils yojson )
66 (flags
77 :standard
88 -open Ocaml_typing
Original file line number Diff line number Diff line change @@ -15,14 +15,21 @@ let rewrite_root = ref false
1515let store_shapes = ref false
1616let do_not_use_cmt_loadpath = ref false
1717
18- type command = Aggregate | Dump | Dump_file_stats | Stats | Gather_shapes
18+ type command =
19+ | Aggregate
20+ | Dump
21+ | Dump_file_stats
22+ | Stats
23+ | Gather_shapes
24+ | Magic_numbers
1925
2026let parse_command = function
2127 | "aggregate" -> Some Aggregate
2228 | "dump" -> Some Dump
2329 | "dump-file-stats" -> Some Dump_file_stats
2430 | "stats" -> Some Stats
2531 | "gather-shapes" -> Some Gather_shapes
32+ | "magic-numbers" -> Some Magic_numbers
2633 | _ -> None
2734
2835let command = ref None
@@ -128,5 +135,9 @@ let () =
128135 (Hashtbl. length cu_shape)
129136 (Option. value ~default: " none" root_directory))
130137 (List. rev ! input_files_rev)
131- | _ -> Printf. printf " Nothing to do.\n %!" );
138+ | Some Magic_numbers ->
139+ let json = Config.Magic_numbers. (to_json current) in
140+ Yojson.Basic. to_channel stdout json;
141+ print_newline ()
142+ | None -> Printf. printf " Nothing to do.\n %!" );
132143 exit 0
Original file line number Diff line number Diff line change @@ -48,3 +48,38 @@ let reserved_header_bits = 8
4848let runtime5 = true
4949
5050let merlin = true
51+
52+ module Magic_numbers = struct
53+ type t =
54+ { cmi_magic_number : string ;
55+ ast_intf_magic_number : string ;
56+ ast_impl_magic_number : string ;
57+ cmt_magic_number : string ;
58+ cms_magic_number : string ;
59+ index_magic_number : string
60+ }
61+
62+ let current =
63+ { cmi_magic_number;
64+ ast_intf_magic_number;
65+ ast_impl_magic_number;
66+ cmt_magic_number;
67+ cms_magic_number;
68+ index_magic_number
69+ }
70+
71+ let to_json t =
72+ let nums =
73+ [ (" cmi_magic_number" , t.cmi_magic_number);
74+ (" ast_intf_magic_number" , t.ast_intf_magic_number);
75+ (" ast_impl_magic_number" , t.ast_impl_magic_number);
76+ (" cmt_magic_number" , t.cmt_magic_number);
77+ (" cms_magic_number" , t.cms_magic_number);
78+ (" index_magic_number" , t.index_magic_number)
79+ ]
80+ in
81+ `Assoc
82+ (List. map
83+ (fun (key , value ) -> (key, Merlin_utils.Std.Json. string value))
84+ nums)
85+ end
Original file line number Diff line number Diff line change @@ -46,4 +46,19 @@ val runtime5 : bool
4646
4747val merlin : bool
4848
49+ module Magic_numbers : sig
50+ type t =
51+ { cmi_magic_number : string ;
52+ ast_intf_magic_number : string ;
53+ ast_impl_magic_number : string ;
54+ cmt_magic_number : string ;
55+ cms_magic_number : string ;
56+ index_magic_number : string
57+ }
58+
59+ val current : t
60+
61+ val to_json : t -> Std .json
62+ end
63+
4964(* */**)
You can’t perform that action at this time.
0 commit comments