Skip to content

Incremental typechecking #939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"--extensionDevelopmentPath=${workspaceRoot}"
],
"outFiles": [
"${workspaceRoot}/client/out/*.js"
"${workspaceRoot}/client/out/**/*.js"
],
"preLaunchTask": {
"type": "npm",
Expand All @@ -25,7 +25,7 @@
"port": 6009,
"restart": true,
"outFiles": [
"${workspaceRoot}/server/out/*.js"
"${workspaceRoot}/server/out/**/*.js"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ tools.opam
client/node_modules
server/node_modules
_opam
_build
_build
Makefile
26 changes: 19 additions & 7 deletions analysis/src/Cmt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,25 @@ let fullFromUri ~uri =
let moduleName =
BuildSystem.namespacedName package.namespace (FindFiles.getName path)
in
match Hashtbl.find_opt package.pathsForModule moduleName with
| Some paths ->
let cmt = getCmtPath ~uri paths in
fullForCmt ~moduleName ~package ~uri cmt
| None ->
prerr_endline ("can't find module " ^ moduleName);
None)
let incrementalCmtPath =
package.rootPath ^ "/lib/bs/___incremental" ^ "/" ^ moduleName
^
match Files.classifySourceFile path with
| Resi -> ".cmti"
| _ -> ".cmt"
in
match fullForCmt ~moduleName ~package ~uri incrementalCmtPath with
| Some cmtInfo ->
if Debug.verbose () then Printf.printf "[cmt] Found incremental cmt\n";
Some cmtInfo
| None -> (
match Hashtbl.find_opt package.pathsForModule moduleName with
| Some paths ->
let cmt = getCmtPath ~uri paths in
fullForCmt ~moduleName ~package ~uri cmt
| None ->
prerr_endline ("can't find module " ^ moduleName);
None))

let fullsFromModule ~package ~moduleName =
if Hashtbl.mem package.pathsForModule moduleName then
Expand Down
21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@
"default": true,
"description": "Enable signature help for function calls."
},
"rescript.settings.incrementalTypechecking.enabled": {
"type": "boolean",
"default": false,
"description": "(beta/experimental) Enable incremental type checking."
},
"rescript.settings.incrementalTypechecking.acrossFiles": {
"type": "boolean",
"default": false,
"description": "(beta/experimental) Enable incremental type checking across files, so that unsaved file A gets access to unsaved file B."
},
"rescript.settings.incrementalTypechecking.debugLogging": {
"type": "boolean",
"default": false,
"description": "(debug) Enable debug logging (ends up in the extension output)."
},
"rescript.settings.binaryPath": {
"type": [
"string",
Expand Down Expand Up @@ -230,9 +245,9 @@
},
"scripts": {
"clean": "rm -rf client/out server/out",
"vscode:prepublish": "npm run clean && npm run compile && npm run bundle",
"compile": "tsc",
"watch": "tsc -w",
"vscode:prepublish": "npm run clean && npm run bundle",
"compile": "tsc -b",
"watch": "tsc -b -w",
"postinstall": "cd server && npm i && cd ../client && npm i && cd ../tools && npm i && cd ../tools/tests && npm i && cd ../../analysis/tests && npm i && cd ../reanalyze/examples/deadcode && npm i && cd ../termination && npm i",
"bundle-server": "esbuild server/src/cli.ts --bundle --sourcemap --outfile=server/out/cli.js --format=cjs --platform=node --loader:.node=file --minify",
"bundle-client": "esbuild client/src/extension.ts --bundle --external:vscode --sourcemap --outfile=client/out/extension.js --format=cjs --platform=node --loader:.node=file --minify",
Expand Down
49 changes: 49 additions & 0 deletions server/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Message } from "vscode-languageserver-protocol";

export type send = (msg: Message) => void;

export interface extensionConfiguration {
allowBuiltInFormatter: boolean;
askToStartBuild: boolean;
inlayHints: {
enable: boolean;
maxLength: number | null;
};
codeLens: boolean;
binaryPath: string | null;
platformPath: string | null;
signatureHelp: {
enabled: boolean;
};
incrementalTypechecking: {
enabled: boolean;
acrossFiles: boolean;
debugLogging: boolean;
};
}

// All values here are temporary, and will be overridden as the server is
// initialized, and the current config is received from the client.
let config: { extensionConfiguration: extensionConfiguration } = {
extensionConfiguration: {
allowBuiltInFormatter: false,
askToStartBuild: true,
inlayHints: {
enable: false,
maxLength: 25,
},
codeLens: false,
binaryPath: null,
platformPath: null,
signatureHelp: {
enabled: true,
},
incrementalTypechecking: {
enabled: false,
acrossFiles: true,
debugLogging: true,
},
},
};

export default config;
Loading