@@ -45,8 +45,12 @@ let hover ~path ~line ~col ~currentFile ~debug =
45
45
in
46
46
match completions with
47
47
| {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))
50
54
| Some locItem -> (
51
55
let isModule =
52
56
match locItem.locType with
@@ -70,7 +74,7 @@ let hover ~path ~line ~col ~currentFile ~debug =
70
74
let hoverText = Hover. newHover ~full locItem in
71
75
match hoverText with
72
76
| None -> Protocol. null
73
- | Some s -> Protocol. stringifyHover {contents = s} ))
77
+ | Some s -> Protocol. stringifyHover s ))
74
78
in
75
79
print_endline result
76
80
@@ -259,6 +263,30 @@ let test ~path =
259
263
| Some text ->
260
264
let lines = text |> String. split_on_char '\n' in
261
265
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
262
290
if Str. string_match (Str. regexp " ^ *//[ ]*\\ ^" ) line 0 then
263
291
let matched = Str. matched_string line in
264
292
let len = line |> String. length in
@@ -284,7 +312,9 @@ let test ~path =
284
312
print_endline
285
313
(" Hover " ^ path ^ " " ^ string_of_int line ^ " :"
286
314
^ 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
288
318
| "ref" ->
289
319
print_endline
290
320
(" References " ^ path ^ " " ^ string_of_int line ^ " :"
@@ -305,28 +335,7 @@ let test ~path =
305
335
print_endline
306
336
(" Complete " ^ path ^ " " ^ string_of_int line ^ " :"
307
337
^ 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
330
339
completion ~debug: true ~path ~pos: (line, col) ~current File;
331
340
Sys. remove currentFile
332
341
| "hig" ->
0 commit comments