Skip to content

Commit d5ed8d1

Browse files
committed
basic PoC of doing a sort of incremental typechecking
1 parent 839349a commit d5ed8d1

File tree

7 files changed

+266
-17
lines changed

7 files changed

+266
-17
lines changed

analysis/src/Cmt.ml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@ let fullFromUri ~uri =
1616
let moduleName =
1717
BuildSystem.namespacedName package.namespace (FindFiles.getName path)
1818
in
19-
match Hashtbl.find_opt package.pathsForModule moduleName with
20-
| Some paths ->
21-
let cmt = getCmtPath ~uri paths in
22-
fullForCmt ~moduleName ~package ~uri cmt
23-
| None ->
24-
prerr_endline ("can't find module " ^ moduleName);
25-
None)
19+
let incrementalCmtPath =
20+
package.rootPath ^ "/lib/bs/___incremental" ^ "/" ^ moduleName ^ ".cmt"
21+
in
22+
match fullForCmt ~moduleName ~package ~uri incrementalCmtPath with
23+
| Some cmtInfo ->
24+
if Debug.verbose () then Printf.printf "[cmt] Found incremental cmt\n";
25+
Some cmtInfo
26+
| None -> (
27+
match Hashtbl.find_opt package.pathsForModule moduleName with
28+
| Some paths ->
29+
let cmt = getCmtPath ~uri paths in
30+
fullForCmt ~moduleName ~package ~uri cmt
31+
| None ->
32+
prerr_endline ("can't find module " ^ moduleName);
33+
None))
2634

2735
let fullsFromModule ~package ~moduleName =
2836
if Hashtbl.mem package.pathsForModule moduleName then

client/src/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ export function activate(context: ExtensionContext) {
294294
if (
295295
affectsConfiguration("rescript.settings.inlayHints") ||
296296
affectsConfiguration("rescript.settings.codeLens") ||
297-
affectsConfiguration("rescript.settings.signatureHelp")
297+
affectsConfiguration("rescript.settings.signatureHelp") ||
298+
affectsConfiguration("rescript.settings.incrementalTypechecking")
298299
) {
299300
commands.executeCommand("rescript-vscode.restart_language_server");
300301
} else {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "ReScript language support (official)",
55
"author": "ReScript Team",
66
"license": "MIT",
7-
"version": "1.42.0",
7+
"version": "1.44.0",
88
"repository": {
99
"type": "git",
1010
"url": "https://github.com/rescript-lang/rescript-vscode"
@@ -176,6 +176,11 @@
176176
"default": true,
177177
"description": "Enable signature help for function calls."
178178
},
179+
"rescript.settings.incrementalTypechecking": {
180+
"type": "boolean",
181+
"default": true,
182+
"description": "Enable incremental type checking."
183+
},
179184
"rescript.settings.binaryPath": {
180185
"type": [
181186
"string",

server/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@rescript/language-server",
33
"description": "LSP server for ReScript",
4-
"version": "1.42.0",
4+
"version": "1.44.0",
55
"author": "ReScript Team",
66
"license": "MIT",
77
"bin": {

0 commit comments

Comments
 (0)