File tree Expand file tree Collapse file tree 3 files changed +53
-5
lines changed Expand file tree Collapse file tree 3 files changed +53
-5
lines changed Original file line number Diff line number Diff line change @@ -1283,10 +1283,16 @@ let rec getCompletionsForContextPath ~package ~opens ~rawOpens ~allFiles ~pos
1283
1283
|> completionsGetTypeEnv
1284
1284
with
1285
1285
| Some (typ , _envNotUsed ) -> (
1286
- let arrayModulePath = [" Js" ; " Array2" ] in
1287
- let listModulePath = [" Belt" ; " List" ] in
1288
- let optionModulePath = [" Belt" ; " Option" ] in
1289
- let stringModulePath = [" Js" ; " String2" ] in
1286
+ let {
1287
+ arrayModulePath;
1288
+ optionModulePath;
1289
+ stringModulePath;
1290
+ intModulePath;
1291
+ floatModulePath;
1292
+ promiseModulePath;
1293
+ } =
1294
+ package.builtInCompletionModules
1295
+ in
1290
1296
let getModulePath path =
1291
1297
let rec loop (path : Path.t ) =
1292
1298
match path with
@@ -1296,9 +1302,15 @@ let rec getCompletionsForContextPath ~package ~opens ~rawOpens ~allFiles ~pos
1296
1302
in
1297
1303
match path with
1298
1304
| Path. Pident id when Ident. name id = " array" -> arrayModulePath
1299
- | Path. Pident id when Ident. name id = " list" -> listModulePath
1300
1305
| Path. Pident id when Ident. name id = " option" -> optionModulePath
1301
1306
| Path. Pident id when Ident. name id = " string" -> stringModulePath
1307
+ | Path. Pident id when Ident. name id = " int" -> intModulePath
1308
+ | Path. Pident id when Ident. name id = " float" -> floatModulePath
1309
+ | Path. Pident id when Ident. name id = " promise" -> promiseModulePath
1310
+ | Path. Pident id when Ident. name id = " list" -> [" Belt" ; " List" ]
1311
+ | Path. Pident id when Ident. name id = " lazy_t" -> [" Lazy" ]
1312
+ | Path. Pident id when Ident. name id = " result" -> [" Belt" ; " Result" ]
1313
+ | Path. Pident id when Ident. name id = " char" -> [" Char" ]
1302
1314
| _ -> (
1303
1315
match loop path with
1304
1316
| _ :: rest -> List. rev rest
Original file line number Diff line number Diff line change @@ -93,6 +93,32 @@ let newBsPackage ~rootPath =
93
93
pathsForModule;
94
94
opens;
95
95
namespace;
96
+ builtInCompletionModules =
97
+ (if
98
+ opens_from_bsc_flags
99
+ |> List. find_opt (fun opn ->
100
+ match opn with
101
+ | [" ReScriptStdLib" ] -> true
102
+ | _ -> false )
103
+ |> Option. is_some
104
+ then
105
+ {
106
+ arrayModulePath = [" Array" ];
107
+ optionModulePath = [" Option" ];
108
+ stringModulePath = [" String" ];
109
+ intModulePath = [" Int" ];
110
+ floatModulePath = [" Float" ];
111
+ promiseModulePath = [" Promise" ];
112
+ }
113
+ else
114
+ {
115
+ arrayModulePath = [" Js" ; " Array2" ];
116
+ optionModulePath = [" Belt" ; " Option" ];
117
+ stringModulePath = [" Js" ; " String2" ];
118
+ intModulePath = [" Belt" ; " Int" ];
119
+ floatModulePath = [" Belt" ; " Float" ];
120
+ promiseModulePath = [" Js" ; " Promise" ];
121
+ });
96
122
})))
97
123
| None -> None )
98
124
Original file line number Diff line number Diff line change @@ -361,12 +361,22 @@ type file = string
361
361
362
362
module FileSet = Set. Make (String )
363
363
364
+ type builtInCompletionModules = {
365
+ arrayModulePath : string list ;
366
+ optionModulePath : string list ;
367
+ stringModulePath : string list ;
368
+ intModulePath : string list ;
369
+ floatModulePath : string list ;
370
+ promiseModulePath : string list ;
371
+ }
372
+
364
373
type package = {
365
374
rootPath : filePath ;
366
375
projectFiles : FileSet .t ;
367
376
dependenciesFiles : FileSet .t ;
368
377
pathsForModule : (file , paths ) Hashtbl .t ;
369
378
namespace : string option ;
379
+ builtInCompletionModules : builtInCompletionModules ;
370
380
opens : path list ;
371
381
}
372
382
You can’t perform that action at this time.
0 commit comments