@@ -45,8 +45,12 @@ let hover ~path ~line ~col ~currentFile ~debug =
4545 in
4646 match completions with
4747 | {kind = Label typString } :: _ ->
48- Protocol. stringifyHover {contents = Hover. codeBlock typString}
49- | _ -> Protocol. null)
48+ Protocol. stringifyHover (Hover. codeBlock typString)
49+ | _ -> (
50+ match CompletionBackEnd. completionsGetTypeEnv completions with
51+ | Some (typ , _env ) ->
52+ Protocol. stringifyHover (Hover. codeBlock (Shared. typeToString typ))
53+ | None -> Protocol. null))
5054 | Some locItem -> (
5155 let isModule =
5256 match locItem.locType with
@@ -70,7 +74,7 @@ let hover ~path ~line ~col ~currentFile ~debug =
7074 let hoverText = Hover. newHover ~full locItem in
7175 match hoverText with
7276 | None -> Protocol. null
73- | Some s -> Protocol. stringifyHover {contents = s} ))
77+ | Some s -> Protocol. stringifyHover s ))
7478 in
7579 print_endline result
7680
@@ -259,6 +263,30 @@ let test ~path =
259263 | Some text ->
260264 let lines = text |> String. split_on_char '\n' in
261265 let processLine i line =
266+ let createCurrentFile () =
267+ let currentFile, cout = Filename. open_temp_file " def" " txt" in
268+ let removeLineComment l =
269+ let len = String. length l in
270+ let rec loop i =
271+ if i + 2 < = len && l.[i] = '/' && l.[i + 1 ] = '/' then Some (i + 2 )
272+ else if i + 2 < len && l.[i] = ' ' then loop (i + 1 )
273+ else None
274+ in
275+ match loop 0 with
276+ | None -> l
277+ | Some indexAfterComment ->
278+ String. make indexAfterComment ' '
279+ ^ String. sub l indexAfterComment (len - indexAfterComment)
280+ in
281+ lines
282+ |> List. iteri (fun j l ->
283+ let lineToOutput =
284+ if j == i - 1 then removeLineComment l else l
285+ in
286+ Printf. fprintf cout " %s\n " lineToOutput);
287+ close_out cout;
288+ currentFile
289+ in
262290 if Str. string_match (Str. regexp " ^ *//[ ]*\\ ^" ) line 0 then
263291 let matched = Str. matched_string line in
264292 let len = line |> String. length in
@@ -284,7 +312,9 @@ let test ~path =
284312 print_endline
285313 (" Hover " ^ path ^ " " ^ string_of_int line ^ " :"
286314 ^ string_of_int col);
287- hover ~path ~line ~col ~current File:path ~debug: true
315+ let currentFile = createCurrentFile () in
316+ hover ~path ~line ~col ~current File ~debug: true ;
317+ Sys. remove currentFile
288318 | "ref" ->
289319 print_endline
290320 (" References " ^ path ^ " " ^ string_of_int line ^ " :"
@@ -305,28 +335,7 @@ let test ~path =
305335 print_endline
306336 (" Complete " ^ path ^ " " ^ string_of_int line ^ " :"
307337 ^ string_of_int col);
308- let currentFile, cout = Filename. open_temp_file " def" " txt" in
309- let removeLineComment l =
310- let len = String. length l in
311- let rec loop i =
312- if i + 2 < = len && l.[i] = '/' && l.[i + 1 ] = '/' then
313- Some (i + 2 )
314- else if i + 2 < len && l.[i] = ' ' then loop (i + 1 )
315- else None
316- in
317- match loop 0 with
318- | None -> l
319- | Some indexAfterComment ->
320- String. make indexAfterComment ' '
321- ^ String. sub l indexAfterComment (len - indexAfterComment)
322- in
323- lines
324- |> List. iteri (fun j l ->
325- let lineToOutput =
326- if j == i - 1 then removeLineComment l else l
327- in
328- Printf. fprintf cout " %s\n " lineToOutput);
329- close_out cout;
338+ let currentFile = createCurrentFile () in
330339 completion ~debug: true ~path ~pos: (line, col) ~current File;
331340 Sys. remove currentFile
332341 | "hig" ->
0 commit comments