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

Null checks for various extension config things #944

Merged
merged 2 commits into from
Mar 7, 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

#### :bug: Bug Fix

- Fix null checks for editor config, so things don't blow up. https://github.com/rescript-lang/rescript-vscode/pull/944

## 1.44.0

#### :rocket: New Feature
Expand Down
8 changes: 4 additions & 4 deletions server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ export type send = (msg: Message) => void;
export interface extensionConfiguration {
allowBuiltInFormatter: boolean;
askToStartBuild: boolean;
inlayHints: {
inlayHints?: {
enable: boolean;
maxLength: number | null;
};
codeLens: boolean;
binaryPath: string | null;
platformPath: string | null;
signatureHelp: {
signatureHelp?: {
enabled: boolean;
};
incrementalTypechecking: {
incrementalTypechecking?: {
enabled: boolean;
acrossFiles: boolean;
debugLogging: boolean;
Expand All @@ -40,7 +40,7 @@ let config: { extensionConfiguration: extensionConfiguration } = {
},
incrementalTypechecking: {
enabled: false,
acrossFiles: true,
acrossFiles: false,
debugLogging: true,
},
},
Expand Down
6 changes: 4 additions & 2 deletions server/src/incrementalCompilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import * as c from "./constants";
import * as chokidar from "chokidar";

function debug() {
return config.extensionConfiguration.incrementalTypechecking.debugLogging;
return (
config.extensionConfiguration.incrementalTypechecking?.debugLogging ?? false
);
}

const INCREMENTAL_FOLDER_NAME = "___incremental";
Expand Down Expand Up @@ -420,7 +422,7 @@ async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) {

let callArgs: Array<string> = [];

if (config.extensionConfiguration.incrementalTypechecking.acrossFiles) {
if (config.extensionConfiguration.incrementalTypechecking?.acrossFiles) {
callArgs.push(
"-I",
path.resolve(entry.project.rootPath, INCREMENTAL_FILE_FOLDER_LOCATION)
Expand Down
12 changes: 6 additions & 6 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ let deleteProjectDiagnostics = (projectRootPath: string) => {
});

projectsFiles.delete(projectRootPath);
if (config.extensionConfiguration.incrementalTypechecking.enabled) {
if (config.extensionConfiguration.incrementalTypechecking?.enabled) {
ic.removeIncrementalFileFolder(projectRootPath);
}
}
Expand Down Expand Up @@ -239,7 +239,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?.enabled) {
ic.recreateIncrementalFileFolder(projectRootPath);
}
projectRootState = {
Expand Down Expand Up @@ -319,7 +319,7 @@ let openedFile = (fileUri: string, fileContent: string) => {
let closedFile = (fileUri: string) => {
let filePath = fileURLToPath(fileUri);

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

Expand Down Expand Up @@ -349,7 +349,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?.enabled) {
ic.handleUpdateOpenedFile(filePath, fileContent, send, () => {
if (config.extensionConfiguration.codeLens) {
sendCodeLensRefresh();
Expand Down Expand Up @@ -418,7 +418,7 @@ function inlayHint(msg: p.RequestMessage) {
filePath,
params.range.start.line,
params.range.end.line,
config.extensionConfiguration.inlayHints.maxLength,
config.extensionConfiguration.inlayHints?.maxLength,
],
msg
);
Expand Down Expand Up @@ -794,7 +794,7 @@ function format(msg: p.RequestMessage): Array<p.Message> {
}

let updateDiagnosticSyntax = (fileUri: string, fileContent: string) => {
if (config.extensionConfiguration.incrementalTypechecking.enabled) {
if (config.extensionConfiguration.incrementalTypechecking?.enabled) {
// The incremental typechecking already sends syntax diagnostics.
return;
}
Expand Down
Loading