Skip to content

Commit f200595

Browse files
committed
use predef paths so weird type lookups do not happen
1 parent 3887cdf commit f200595

File tree

1 file changed

+15
-41
lines changed

1 file changed

+15
-41
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -778,43 +778,21 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
778778
match contextPath with
779779
| CPString ->
780780
if Debug.verbose () then print_endline "[ctx_path]--> CPString";
781-
[
782-
Completion.create "dummy" ~env
783-
~kind:
784-
(Completion.Value
785-
(Ctype.newconstr (Path.Pident (Ident.create "string")) []));
786-
]
781+
[Completion.create "dummy" ~env ~kind:(Completion.Value Predef.type_string)]
787782
| CPBool ->
788783
if Debug.verbose () then print_endline "[ctx_path]--> CPBool";
789-
[
790-
Completion.create "dummy" ~env
791-
~kind:
792-
(Completion.Value
793-
(Ctype.newconstr (Path.Pident (Ident.create "bool")) []));
794-
]
784+
[Completion.create "dummy" ~env ~kind:(Completion.Value Predef.type_bool)]
795785
| CPInt ->
796786
if Debug.verbose () then print_endline "[ctx_path]--> CPInt";
797-
[
798-
Completion.create "dummy" ~env
799-
~kind:
800-
(Completion.Value
801-
(Ctype.newconstr (Path.Pident (Ident.create "int")) []));
802-
]
787+
[Completion.create "dummy" ~env ~kind:(Completion.Value Predef.type_int)]
803788
| CPFloat ->
804789
if Debug.verbose () then print_endline "[ctx_path]--> CPFloat";
805-
[
806-
Completion.create "dummy" ~env
807-
~kind:
808-
(Completion.Value
809-
(Ctype.newconstr (Path.Pident (Ident.create "float")) []));
810-
]
790+
[Completion.create "dummy" ~env ~kind:(Completion.Value Predef.type_float)]
811791
| CPArray None ->
812792
if Debug.verbose () then print_endline "[ctx_path]--> CPArray (no payload)";
813793
[
814794
Completion.create "array" ~env
815-
~kind:
816-
(Completion.Value
817-
(Ctype.newconstr (Path.Pident (Ident.create "array")) []));
795+
~kind:(Completion.Value (Ctype.newconstr Predef.path_array []));
818796
]
819797
| CPArray (Some cp) -> (
820798
if Debug.verbose () then
@@ -839,9 +817,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
839817
what inner type it has. *)
840818
[
841819
Completion.create "dummy" ~env
842-
~kind:
843-
(Completion.Value
844-
(Ctype.newconstr (Path.Pident (Ident.create "array")) []));
820+
~kind:(Completion.Value (Ctype.newconstr Predef.path_array []));
845821
])
846822
| CPOption cp -> (
847823
if Debug.verbose () then print_endline "[ctx_path]--> CPOption";
@@ -1722,9 +1698,7 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
17221698
if prefix = "" then
17231699
[
17241700
create "\"\"" ~includesSnippets:true ~insertText:"\"$0\"" ~sortText:"A"
1725-
~kind:
1726-
(Value (Ctype.newconstr (Path.Pident (Ident.create "string")) []))
1727-
~env;
1701+
~kind:(Value Predef.type_string) ~env;
17281702
]
17291703
else []
17301704
| Tfunction {env; typ; args; returnType} when prefix = "" && mode = Expression
@@ -1912,7 +1886,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
19121886
stamp = -1;
19131887
fname = {loc = Location.none; txt = name};
19141888
optional = true;
1915-
typ = Ctype.newconstr (Path.Pident (Ident.create primitive)) [];
1889+
typ = Ctype.newconstr primitive [];
19161890
docstring = [];
19171891
deprecated = None;
19181892
}
@@ -1924,9 +1898,9 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
19241898
definition = `NameOnly "jsxConfig";
19251899
fields =
19261900
[
1927-
mkField ~name:"version" ~primitive:"int";
1928-
mkField ~name:"module_" ~primitive:"string";
1929-
mkField ~name:"mode" ~primitive:"string";
1901+
mkField ~name:"version" ~primitive:Predef.path_int;
1902+
mkField ~name:"module_" ~primitive:Predef.path_string;
1903+
mkField ~name:"mode" ~primitive:Predef.path_string;
19301904
];
19311905
}
19321906
in
@@ -1942,7 +1916,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
19421916
stamp = -1;
19431917
fname = {loc = Location.none; txt = name};
19441918
optional = true;
1945-
typ = Ctype.newconstr (Path.Pident (Ident.create primitive)) [];
1919+
typ = Ctype.newconstr primitive [];
19461920
docstring = [];
19471921
deprecated = None;
19481922
}
@@ -1952,7 +1926,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
19521926
{
19531927
env;
19541928
definition = `NameOnly "importAttributesConfig";
1955-
fields = [mkField ~name:"type_" ~primitive:"string"];
1929+
fields = [mkField ~name:"type_" ~primitive:Predef.path_string];
19561930
}
19571931
in
19581932
let rootConfig : completionType =
@@ -1962,8 +1936,8 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
19621936
definition = `NameOnly "moduleConfig";
19631937
fields =
19641938
[
1965-
mkField ~name:"from" ~primitive:"string";
1966-
mkField ~name:"with" ~primitive:"string";
1939+
mkField ~name:"from" ~primitive:Predef.path_string;
1940+
mkField ~name:"with" ~primitive:Predef.path_string;
19671941
];
19681942
}
19691943
in

0 commit comments

Comments
 (0)