Skip to content

Commit 7dcf626

Browse files
committed
wip
1 parent 6ec8a2a commit 7dcf626

13 files changed

+1546
-375
lines changed

analysis/src/Commands.ml

+15-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ let completion ~debug ~path ~pos ~currentFile =
1212
|> List.map Protocol.stringifyCompletionItem
1313
|> Protocol.array)
1414

15+
let completionNew ~debug ~path ~pos ~currentFile =
16+
let completions =
17+
match
18+
Completions.getCompletions2 ~debug ~path ~pos ~currentFile ~forHover:false
19+
with
20+
| None -> []
21+
| Some (completions, _, _) -> completions
22+
in
23+
print_endline
24+
(completions
25+
|> List.map CompletionBackEnd.completionToItem
26+
|> List.map Protocol.stringifyCompletionItem
27+
|> Protocol.array)
28+
1529
let inlayhint ~path ~pos ~maxLength ~debug =
1630
let result =
1731
match Hint.inlay ~path ~pos ~maxLength ~debug with
@@ -321,8 +335,7 @@ let test ~path =
321335
("Complete2 " ^ path ^ " " ^ string_of_int line ^ ":"
322336
^ string_of_int col);
323337
let currentFile = createCurrentFile () in
324-
Completions.getCompletions2 ~forHover:false ~debug:true ~path
325-
~pos:(line, col) ~currentFile;
338+
completionNew ~debug:true ~path ~pos:(line, col) ~currentFile;
326339
Sys.remove currentFile
327340
| "dce" ->
328341
print_endline ("DCE " ^ path);

analysis/src/CompletionBackEnd.ml

+6-3
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ let processLocalValue name loc contextPath ~prefix ~exact ~env
286286
Completion.create name ~env
287287
~kind:
288288
(match contextPath with
289-
| Some contextPath -> FollowContextPath contextPath
289+
| Some (Scope.Completable contextPath) ->
290+
FollowContextPath (`Completable contextPath)
291+
| Some (Scope.New contextPath) ->
292+
FollowContextPath (`New contextPath)
290293
| None ->
291294
Value
292295
(Ctype.newconstr
@@ -628,7 +631,7 @@ let rec completionsGetCompletionType2 ~debug ~full ~opens ~rawOpens ~pos ~scope
628631
| {Completion.kind = ObjLabel typ; env} :: _
629632
| {Completion.kind = Field ({typ}, _); env} :: _ ->
630633
Some (TypeExpr typ, env)
631-
| {Completion.kind = FollowContextPath ctxPath; env} :: _ ->
634+
| {Completion.kind = FollowContextPath (`Completable ctxPath); env} :: _ ->
632635
ctxPath
633636
|> getCompletionsForContextPath ~debug ~full ~env ~exact:true ~opens
634637
~rawOpens ~pos ~scope
@@ -647,7 +650,7 @@ and completionsGetTypeEnv2 ~debug (completions : Completion.t list) ~full ~opens
647650
| {Completion.kind = Value typ; env} :: _ -> Some (typ, env)
648651
| {Completion.kind = ObjLabel typ; env} :: _ -> Some (typ, env)
649652
| {Completion.kind = Field ({typ}, _); env} :: _ -> Some (typ, env)
650-
| {Completion.kind = FollowContextPath ctxPath; env} :: _ ->
653+
| {Completion.kind = FollowContextPath (`Completable ctxPath); env} :: _ ->
651654
ctxPath
652655
|> getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env
653656
~exact:true ~scope

0 commit comments

Comments
 (0)