@@ -11,18 +11,17 @@ let completion ~(debug : bool) ~path ~pos ~currentFile =
11
11
in
12
12
completions |> Protocol. array |> print_endline
13
13
14
- let completionRevamped ?(source = None ) ~debug ~path ~pos ~currentFile =
15
- let completions =
16
- match
17
- Completions. getCompletionsRevamped ~source ~debug ~path ~pos ~current File
18
- with
19
- | None -> []
20
- | Some (completions , full , _ ) ->
21
- completions
22
- |> List. map (CompletionBackEnd. completionToItem ~full )
23
- |> List. map Protocol. stringifyCompletionItem
24
- in
25
- completions |> Protocol. array |> print_endline
14
+ let completionRevamped ~debug ~path ~pos ~currentFile =
15
+ match Completions. getCompletionsRevamped ~debug ~pos ~current File ~path with
16
+ | None -> None
17
+ | Some (completable , completions , full , _ ) ->
18
+ Some
19
+ ( completable,
20
+ completions
21
+ |> List. map (CompletionBackEnd. completionToItem ~full )
22
+ |> List. map Protocol. stringifyCompletionItem
23
+ |> Protocol. array )
24
+
26
25
let completionResolve ~path ~modulePath =
27
26
(* We ignore the internal module path as of now because there's currently
28
27
no use case for it. But, if we wanted to move resolving documentation
@@ -380,15 +379,38 @@ let test ~path ~debug =
380
379
^ string_of_int col);
381
380
definition ~path ~pos: (line, col) ~debug: true
382
381
| "com" ->
383
- print_endline
384
- (" Complete " ^ path ^ " " ^ string_of_int line ^ " :"
385
- ^ string_of_int col);
386
382
let currentFile = createCurrentFile () in
387
- if ! Cfg. useRevampedCompletion then
383
+ if ! Cfg. useRevampedCompletion then (
388
384
let source = Files. readFile currentFile in
389
- completionRevamped ~source ~debug ~path ~pos: (line, col)
390
- ~current File
391
- else completion ~debug: true ~path ~pos: (line, col) ~current File;
385
+ let completions =
386
+ completionRevamped ~debug ~path ~pos: (line, col) ~current File
387
+ in
388
+ (match (completions, source) with
389
+ | None , _ ->
390
+ print_endline " Completion Frontend did not return completable"
391
+ | Some (completable , completionsText ), Some text -> (
392
+ match SharedTypes.CompletableRevamped. try_loc completable with
393
+ | Some loc ->
394
+ let range =
395
+ CodeFence.
396
+ {
397
+ start = loc.Location. loc_start.pos_cnum;
398
+ finish = loc.Warnings. loc_end.pos_cnum;
399
+ }
400
+ in
401
+ Printf. printf " Found Completable: %s\n\n "
402
+ (SharedTypes.CompletableRevamped. toString completable);
403
+ CodeFence. format_code_snippet_cropped text (Some range) 3
404
+ |> print_endline;
405
+ print_endline completionsText
406
+ | None -> () )
407
+ | _ -> print_endline " ERR: Unexpected completion result" );
408
+ () )
409
+ else (
410
+ print_endline
411
+ (" Complete " ^ path ^ " " ^ string_of_int line ^ " :"
412
+ ^ string_of_int col);
413
+ completion ~debug: true ~path ~pos: (line, col) ~current File);
392
414
Sys. remove currentFile
393
415
| "cre" ->
394
416
let modulePath = String. sub rest 3 (String. length rest - 3 ) in
0 commit comments