@@ -990,35 +990,44 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
990
990
with
991
991
| Some (TypeExpr typ , env ) -> (
992
992
match typ |> TypeUtils. extractRecordType ~env ~package with
993
- | Some (env , fields , typDecl , path ) ->
993
+ | Some (env , fields , typDecl , path , attributes ) ->
994
994
Some
995
995
( env,
996
996
fields,
997
997
typDecl.item.decl |> Shared. declToString typDecl.name.txt,
998
- Some path )
998
+ Some path,
999
+ attributes )
999
1000
| None -> None )
1000
1001
| Some (ExtractedType typ , env ) -> (
1001
1002
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 )
1004
1010
| _ -> None )
1005
1011
| None -> None
1006
1012
in
1007
1013
match extracted with
1008
1014
| 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,
1016
1023
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 ) ->
1022
1031
(* Most of this is copied from the pipe completion code. Should probably be unified. *)
1023
1032
let completions =
1024
1033
completionPath @ [fieldName]
@@ -1046,10 +1055,8 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
1046
1055
match
1047
1056
TypeUtils. extractFunctionType ~env ~package: full.package t
1048
1057
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"
1053
1060
| _ -> false )
1054
1061
| _ -> false
1055
1062
in
@@ -2031,6 +2038,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
2031
2038
env;
2032
2039
definition = `NameOnly " jsxConfig" ;
2033
2040
path = None ;
2041
+ attributes = [] ;
2034
2042
fields =
2035
2043
[
2036
2044
mkField ~name: " version" ~primitive: " int" ;
@@ -2061,6 +2069,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
2061
2069
{
2062
2070
env;
2063
2071
path = None ;
2072
+ attributes = [] ;
2064
2073
definition = `NameOnly " importAttributesConfig" ;
2065
2074
fields = [mkField ~name: " type_" ~primitive: " string" ];
2066
2075
}
@@ -2070,6 +2079,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
2070
2079
{
2071
2080
env;
2072
2081
path = None ;
2082
+ attributes = [] ;
2073
2083
definition = `NameOnly " moduleConfig" ;
2074
2084
fields =
2075
2085
[
0 commit comments