Skip to content

Commit d1c3eb2

Browse files
committed
Optional dig
1 parent 609453c commit d1c3eb2

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -966,11 +966,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
966966
(* should not happen, but just ignore extra arguments *) []
967967
in
968968

969-
(* (match typ.desc with
970-
| Tarrow _ -> print_endline "its an arrow"
971-
| Tconstr _ -> print_endline "it's an alias"
972-
| _ -> print_endline "something else"); *)
973-
match TypeUtils.extractFunctionType ~env ~package typ with
969+
match TypeUtils.extractFunctionType ~env ~package ~digInto:false typ with
974970
| args, tRet when args <> [] ->
975971
let args = processApply args labels in
976972
let retType = reconstructFunctionType args tRet in
@@ -1052,7 +1048,6 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
10521048
| None -> [])
10531049
| None -> [])
10541050
| CPPipe {contextPath = cp; id = prefix; lhsLoc; inJsx; synthetic} -> (
1055-
(* TODO: resolve somewhere in here a potential alias *)
10561051
if Debug.verbose () then print_endline "[ctx_path]--> CPPipe";
10571052
match
10581053
cp

analysis/src/TypeUtils.ml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,21 @@ let rec extractObjectType ~env ~package (t : Types.type_expr) =
243243
| _ -> None)
244244
| _ -> None
245245

246-
let extractFunctionType ~env ~package typ =
246+
let extractFunctionType ~env ~package ?(digInto = true) typ =
247247
let rec loop ~env acc (t : Types.type_expr) =
248248
match t.desc with
249249
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> loop ~env acc t1
250250
| Tarrow (label, tArg, tRet, _, _) -> loop ~env ((label, tArg) :: acc) tRet
251+
| Tconstr (path, typeArgs, _) when digInto -> (
252+
match References.digConstructor ~env ~package path with
253+
| Some
254+
( env,
255+
{
256+
item = {decl = {type_manifest = Some t1; type_params = typeParams}};
257+
} ) ->
258+
let t1 = t1 |> instantiateType ~typeParams ~typeArgs in
259+
loop ~env acc t1
260+
| _ -> (List.rev acc, t))
251261
| _ -> (List.rev acc, t)
252262
in
253263
loop ~env [] typ

0 commit comments

Comments
 (0)