File tree 11 files changed +307
-169
lines changed
11 files changed +307
-169
lines changed Original file line number Diff line number Diff line change 18
18
19
19
## 1.52.0
20
20
21
+ #### :rocket : New Feature
22
+
23
+ - Experimental support for caching the project config to reduce latency. https://github.com/rescript-lang/rescript-vscode/pull/1000
24
+
21
25
#### :bug : Bug Fix
22
26
23
27
- Fix highlighting of other languages being affected by rescript-vscode. https://github.com/rescript-lang/rescript-vscode/pull/973
Original file line number Diff line number Diff line change @@ -110,6 +110,23 @@ let main () =
110
110
path line col
111
111
in
112
112
match args with
113
+ | [_; " cache-project" ; rootPath] -> (
114
+ Cfg. readProjectConfigCache := false ;
115
+ let uri = Uri. fromPath rootPath in
116
+ match Packages. getPackage ~uri with
117
+ | Some package -> Cache. cacheProject package
118
+ | None -> print_endline " \" ERR\" " )
119
+ | [_; " cache-delete" ; rootPath] -> (
120
+ Cfg. readProjectConfigCache := false ;
121
+ let uri = Uri. fromPath rootPath in
122
+ match Packages. findRoot ~uri (Hashtbl. create 0 ) with
123
+ | Some (`Bs rootPath ) -> (
124
+ match BuildSystem. getLibBs rootPath with
125
+ | None -> print_endline " \" ERR\" "
126
+ | Some libBs ->
127
+ Cache. deleteCache (Cache. targetFileFromLibBs libBs);
128
+ print_endline " \" OK\" " )
129
+ | _ -> print_endline " \" ERR: Did not find root \" " )
113
130
| [_; " completion" ; path; line; col; currentFile] ->
114
131
printHeaderInfo path line col;
115
132
Commands. completion ~debug ~path
Original file line number Diff line number Diff line change
1
+ open SharedTypes
2
+
3
+ type cached = {
4
+ projectFiles : FileSet .t ;
5
+ dependenciesFiles : FileSet .t ;
6
+ pathsForModule : (file , paths ) Hashtbl .t ;
7
+ }
8
+
9
+ let writeCache filename (data : cached ) =
10
+ let oc = open_out_bin filename in
11
+ Marshal. to_channel oc data [] ;
12
+ close_out oc
13
+
14
+ let readCache filename =
15
+ if ! Cfg. readProjectConfigCache && Sys. file_exists filename then
16
+ try
17
+ let ic = open_in_bin filename in
18
+ let data : cached = Marshal. from_channel ic in
19
+ close_in ic;
20
+ Some data
21
+ with _ -> None
22
+ else None
23
+
24
+ let deleteCache filename = try Sys. remove filename with _ -> ()
25
+
26
+ let targetFileFromLibBs libBs = Filename. concat libBs " .project-files-cache"
27
+
28
+ let cacheProject (package : package ) =
29
+ let cached =
30
+ {
31
+ projectFiles = package.projectFiles;
32
+ dependenciesFiles = package.dependenciesFiles;
33
+ pathsForModule = package.pathsForModule;
34
+ }
35
+ in
36
+ match BuildSystem. getLibBs package.rootPath with
37
+ | None -> print_endline " \" ERR\" "
38
+ | Some libBs ->
39
+ let targetFile = targetFileFromLibBs libBs in
40
+ writeCache targetFile cached;
41
+ print_endline " \" OK\" "
Original file line number Diff line number Diff line change @@ -9,3 +9,11 @@ let inIncrementalTypecheckingMode =
9
9
| "true" -> true
10
10
| _ -> false
11
11
with _ -> false )
12
+
13
+ let readProjectConfigCache =
14
+ ref
15
+ (try
16
+ match Sys. getenv " RESCRIPT_PROJECT_CONFIG_CACHE" with
17
+ | "true" -> true
18
+ | _ -> false
19
+ with _ -> false )
You can’t perform that action at this time.
0 commit comments