···5555 match data with
5656 | Protocol.Completions compl -> compl
5757 | _ -> assert false
5858+5959+let query_type worker (source : string) position =
6060+ let open Fut.Syntax in
6161+ let action = Protocol.Type_enclosing (source, position) in
6262+ let+ data : Protocol.answer = query ~action worker in
6363+ Console.(log ["Received typed enclosings:"; data]);
6464+ match data with
6565+ | Protocol.Typed_enclosings l -> l
6666+ | _ -> assert false
+3-7
merlinjs/merlin_worker.ml
···156156 | None ->
157157 Protocol.Completions { from = 0; to_ = 0; entries = []; }
158158 end
159159-160160- (*
161161- | Type_enclosing -> failwith "toto"
159159+ | Type_enclosing (source, position) ->
160160+ let source = Msource.make source in
162161 let query = Query_protocol.Type_enclosing (None, position, None) in
163163- let result_string = dispatch source query in
164164- Brr.Json.decode @@ Jstr.of_string result_string
165165- |> Stdlib.Result.get_ok *)
162162+ Protocol.Typed_enclosings (dispatch source query)
166163 | Protocol.All_errors source ->
167164 Console.(log ["w: Query errors"]);
168165 let source = Msource.make source in
···192189 })
193190 in
194191 Protocol.Errors errors
195195- | _ -> failwith "not implemented"
196192 in
197193 let res = Marshal.to_bytes res [] in
198194 Brr_webworkers.Worker.G.post res
+16-2
merlinjs/protocol/protocol.ml
···22module Location = Ocaml_parsing.Location
3344type source = string
55-type action = Complete_prefix of source * Msource.position | Type_enclosing | All_errors of source
55+66+type action =
77+ | Complete_prefix of source * Msource.position
88+ | Type_enclosing of source * Msource.position
99+ | All_errors of source
1010+611type error = {
712 kind : Location.report_kind;
813 loc: Location.t;
···1015 sub : string list;
1116 source : Location.error_source;
1217}
1818+1319type completions = {
1420 from: int;
1521 to_: int;
1622 entries : Query_protocol.Compl.entry list
1723}
2424+2525+type is_tail_position =
2626+ [`No | `Tail_position | `Tail_call]
2727+1828(* type errors = { from: int; to_: int; entries: error list } *)
1919-type answer = Errors of error list | Completions of completions
2929+type answer =
3030+ | Errors of error list
3131+ | Completions of completions
3232+ | Typed_enclosings of
3333+ (Location.t * [ `Index of int | `String of string ] * is_tail_position) list
20342135let report_source_to_string = function
2236 | Location.Lexer -> "lexer"