Skip to content

Commit

Permalink
Enable incremental typechecking by default (#1047)
Browse files Browse the repository at this point in the history
* enable incremental typechecking by default

* changelog

* also change name in package.json

* change wording + default value in package.json

* enable project cache config by default

* adjust changelog
  • Loading branch information
zth authored Oct 24, 2024
1 parent 5705458 commit 8849a58
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
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

0 comments on commit 8849a58

Please sign in to comment.