@@ -990,35 +990,44 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
990990 with
991991 | Some (TypeExpr typ , env ) -> (
992992 match typ |> TypeUtils. extractRecordType ~env ~package with
993- | Some (env , fields , typDecl , path ) ->
993+ | Some (env , fields , typDecl , path , attributes ) ->
994994 Some
995995 ( env,
996996 fields,
997997 typDecl.item.decl |> Shared. declToString typDecl.name.txt,
998- Some path )
998+ Some path,
999+ attributes )
9991000 | None -> None )
10001001 | Some (ExtractedType typ , env ) -> (
10011002 match typ with
1002- | Trecord {fields; path} ->
1003- Some (env, fields, typ |> TypeUtils. extractedTypeToString, path)
1003+ | Trecord {fields; path; attributes} ->
1004+ Some
1005+ ( env,
1006+ fields,
1007+ typ |> TypeUtils. extractedTypeToString,
1008+ path,
1009+ attributes )
10041010 | _ -> None )
10051011 | None -> None
10061012 in
10071013 match extracted with
10081014 | None -> []
1009- | Some (env , fields , recordAsString , path ) ->
1010- let pipeCompletionsForModule =
1011- match path with
1012- | Some path ->
1013- let completionPath =
1014- (* Remove the last part of the path since we're only after the parent module *)
1015- match
1015+ | Some (env , fields , recordAsString , path , attributes ) ->
1016+ let pipeCompletion =
1017+ match
1018+ (path, ProcessAttributes. findMainTypeForModuleAttribute attributes)
1019+ with
1020+ | Some path , _ when Path. last path = " t" ->
1021+ Some
1022+ ( path,
10161023 path |> SharedTypes. pathIdentToString |> String. split_on_char '.'
1017- |> List. rev
1018- with
1019- | _ :: rest -> rest
1020- | [] -> []
1021- in
1024+ |> List. rev |> List. tl )
1025+ | Some path , Some modulePath -> Some (path, modulePath)
1026+ | _ -> None
1027+ in
1028+ let pipeCompletionsForModule =
1029+ match pipeCompletion with
1030+ | Some (path , completionPath ) ->
10221031 (* Most of this is copied from the pipe completion code. Should probably be unified. *)
10231032 let completions =
10241033 completionPath @ [fieldName]
@@ -1046,10 +1055,8 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
10461055 match
10471056 TypeUtils. extractFunctionType ~env ~package: full.package t
10481057 with
1049- | ( (Nolabel , {desc = Tconstr (Path. Pident {name = " t" }, _, _)})
1050- :: _,
1051- _ ) ->
1052- true
1058+ | (Nolabel, {desc = Tconstr (p , _ , _ )} ) :: _ , _ ->
1059+ Path. same p path || Path. name p = " t"
10531060 | _ -> false )
10541061 | _ -> false
10551062 in
@@ -2031,6 +2038,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
20312038 env;
20322039 definition = `NameOnly " jsxConfig" ;
20332040 path = None ;
2041+ attributes = [] ;
20342042 fields =
20352043 [
20362044 mkField ~name: " version" ~primitive: " int" ;
@@ -2061,6 +2069,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
20612069 {
20622070 env;
20632071 path = None ;
2072+ attributes = [] ;
20642073 definition = `NameOnly " importAttributesConfig" ;
20652074 fields = [mkField ~name: " type_" ~primitive: " string" ];
20662075 }
@@ -2070,6 +2079,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
20702079 {
20712080 env;
20722081 path = None ;
2082+ attributes = [] ;
20732083 definition = `NameOnly " moduleConfig" ;
20742084 fields =
20752085 [
0 commit comments