Skip to content
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

Enable incremental typechecking by default #1047

Merged
merged 6 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

## master

#### :rocket: New Feature

- Enable incremental typechecking and project config cache by default. https://github.com/rescript-lang/rescript-vscode/pull/1047

## 1.58.0

#### :bug: Bug fix
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@
"default": true,
"description": "Enable signature help for variant constructor payloads."
},
"rescript.settings.incrementalTypechecking.enabled": {
"rescript.settings.incrementalTypechecking.enable": {
"type": "boolean",
"default": false,
"description": "(beta/experimental) Enable incremental type checking."
"default": true,
"description": "Enable incremental type checking."
},
"rescript.settings.incrementalTypechecking.acrossFiles": {
"type": "boolean",
Expand All @@ -192,10 +192,10 @@
"default": false,
"description": "(debug) Enable debug logging (ends up in the extension output)."
},
"rescript.settings.cache.projectConfig.enabled": {
"rescript.settings.cache.projectConfig.enable": {
"type": "boolean",
"default": false,
"description": "(beta/experimental) Enable project config caching. Can speed up latency dramatically."
"default": true,
"description": "Enable project config caching. Can speed up latency dramatically."
},
"rescript.settings.binaryPath": {
"type": [
Expand Down
8 changes: 4 additions & 4 deletions server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export interface extensionConfiguration {
forConstructorPayloads?: boolean;
};
incrementalTypechecking?: {
enabled?: boolean;
enable?: boolean;
acrossFiles?: boolean;
debugLogging?: boolean;
};
cache?: {
projectConfig?: {
enabled?: boolean;
enable?: boolean;
};
};
}
Expand All @@ -46,13 +46,13 @@ let config: { extensionConfiguration: extensionConfiguration } = {
forConstructorPayloads: true,
},
incrementalTypechecking: {
enabled: false,
enable: true,
acrossFiles: false,
debugLogging: false,
},
cache: {
projectConfig: {
enabled: false,
enable: true,
},
},
},
Expand Down
18 changes: 7 additions & 11 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ let deleteProjectDiagnostics = (projectRootPath: string) => {
});

projectsFiles.delete(projectRootPath);
if (config.extensionConfiguration.incrementalTypechecking?.enabled) {
if (config.extensionConfiguration.incrementalTypechecking?.enable) {
ic.removeIncrementalFileFolder(projectRootPath);
}
}
Expand Down Expand Up @@ -218,9 +218,7 @@ let compilerLogsWatcher = chokidar
})
.on("all", (_e, changedPath) => {
if (changedPath.includes("build.ninja")) {
if (
config.extensionConfiguration.cache?.projectConfig?.enabled === true
) {
if (config.extensionConfiguration.cache?.projectConfig?.enable === true) {
let projectRoot = utils.findProjectRootOfFile(changedPath);
if (projectRoot != null) {
syncProjectConfigCache(projectRoot);
Expand Down Expand Up @@ -259,7 +257,7 @@ let openedFile = (fileUri: string, fileContent: string) => {
if (projectRootPath != null) {
let projectRootState = projectsFiles.get(projectRootPath);
if (projectRootState == null) {
if (config.extensionConfiguration.incrementalTypechecking?.enabled) {
if (config.extensionConfiguration.incrementalTypechecking?.enable) {
ic.recreateIncrementalFileFolder(projectRootPath);
}
const namespaceName =
Expand All @@ -284,9 +282,7 @@ let openedFile = (fileUri: string, fileContent: string) => {
compilerLogsWatcher.add(
path.join(projectRootPath, c.compilerLogPartialPath)
);
if (
config.extensionConfiguration.cache?.projectConfig?.enabled === true
) {
if (config.extensionConfiguration.cache?.projectConfig?.enable === true) {
compilerLogsWatcher.add(
path.join(projectRootPath, c.buildNinjaPartialPath)
);
Expand Down Expand Up @@ -354,7 +350,7 @@ let openedFile = (fileUri: string, fileContent: string) => {
let closedFile = (fileUri: string) => {
let filePath = fileURLToPath(fileUri);

if (config.extensionConfiguration.incrementalTypechecking?.enabled) {
if (config.extensionConfiguration.incrementalTypechecking?.enable) {
ic.handleClosedFile(filePath);
}

Expand Down Expand Up @@ -388,7 +384,7 @@ let updateOpenedFile = (fileUri: string, fileContent: string) => {
let filePath = fileURLToPath(fileUri);
assert(stupidFileContentCache.has(filePath));
stupidFileContentCache.set(filePath, fileContent);
if (config.extensionConfiguration.incrementalTypechecking?.enabled) {
if (config.extensionConfiguration.incrementalTypechecking?.enable) {
ic.handleUpdateOpenedFile(filePath, fileContent, send, () => {
if (config.extensionConfiguration.codeLens) {
sendCodeLensRefresh();
Expand Down Expand Up @@ -862,7 +858,7 @@ function format(msg: p.RequestMessage): Array<p.Message> {
}

let updateDiagnosticSyntax = (fileUri: string, fileContent: string) => {
if (config.extensionConfiguration.incrementalTypechecking?.enabled) {
if (config.extensionConfiguration.incrementalTypechecking?.enable) {
// The incremental typechecking already sends syntax diagnostics.
return;
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ export let runAnalysisAfterSanityCheck = (
...process.env,
RESCRIPT_VERSION: rescriptVersion,
RESCRIPT_INCREMENTAL_TYPECHECKING:
config.extensionConfiguration.incrementalTypechecking?.enabled === true
config.extensionConfiguration.incrementalTypechecking?.enable === true
? "true"
: undefined,
RESCRIPT_PROJECT_CONFIG_CACHE:
config.extensionConfiguration.cache?.projectConfig?.enabled === true
config.extensionConfiguration.cache?.projectConfig?.enable === true
? "true"
: undefined,
},
Expand Down