@@ -18,9 +18,14 @@ let findRecordField ~env ~package ~fieldName typ =
18
18
| Some (_recordEnv , fields , _decl ) ->
19
19
fields |> List. find_opt (fun (field : field ) -> field.fname.txt = fieldName)
20
20
21
- let completeEmptyPattern ~env ~package typ =
21
+ type patternOrExpr = Pattern | Expr
22
+ let completeEmpty ~(mode : patternOrExpr ) ~env ~package typ =
23
+ ignore mode;
22
24
match TypeUtils. extractType ~env ~package typ with
23
- | None -> []
25
+ | None ->
26
+ if Debug. verbose () then
27
+ print_endline " ⚠️ Could not extract completable type" ;
28
+ []
24
29
| Some (completionType , typeArgContext ) -> (
25
30
(* Fill this out with the different completions *)
26
31
match completionType with
@@ -62,22 +67,27 @@ let processCompletable ~debug ~full ~scope ~env ~pos
62
67
match completable with
63
68
| Cexpression {kind; typeLoc} -> (
64
69
match TypeUtils. findTypeViaLoc typeLoc ~full ~debug with
65
- | None -> []
70
+ | None ->
71
+ if Debug. verbose () then print_endline " ⚠️ No type found for loc" ;
72
+ []
66
73
| Some typ -> (
74
+ if Debug. verbose () then
75
+ print_endline (" ✅ Found type at loc:" ^ Shared. typeToString typ);
67
76
match kind with
77
+ | Empty -> completeEmpty ~mode: Expr ~env ~package typ
68
78
| Field {hint} -> findFields ~env ~package ~hint typ))
69
79
| Cpattern {kind; typeLoc} -> (
70
80
match TypeUtils. findTypeViaLoc typeLoc ~full ~debug with
71
81
| None -> []
72
82
| Some typ -> (
73
83
match kind with
74
- | Empty -> completeEmptyPattern ~env ~package typ
84
+ | Empty -> completeEmpty ~mode: Pattern ~env ~package typ
75
85
| Field {hint; seenFields} ->
76
86
findFields ~env ~package ~hint ~seen Fields typ
77
87
| FieldValue {fieldName} -> (
78
88
match findRecordField ~env ~package ~field Name typ with
79
89
| None -> []
80
- | Some field -> completeEmptyPattern ~env ~package field.typ)))
90
+ | Some field -> completeEmpty ~mode: Pattern ~env ~package field.typ)))
81
91
| Cnone -> []
82
92
| CextensionNode _ -> []
83
93
| Cdecorator prefix ->
0 commit comments