Skip to content

Commit

Permalink
extension: prefer naked returns over Promise.resolve()
Browse files Browse the repository at this point in the history
Also switch to using the void helper method showErroMessage at some more
sites.

Signed-off-by: Paul Jolly <[email protected]>
Change-Id: I3ec5603b74fbcd2562eebbe7463ff16dbf9f0b5c
Reviewed-on: https://review.gerrithub.io/c/cue-lang/vscode-cue/+/1206541
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
myitcv committed Jan 1, 2025
1 parent 486feba commit 500d3b9
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class Extension {
// configuration graph. This appears to be mitigated by calling
// s.affectsConfiguration('cue') to determine if there has been a change.
if (s !== undefined && !s.affectsConfiguration('cue')) {
return Promise.resolve();
return;
}

// As https://github.com/Microsoft/vscode/issues/35451 clearly explains,
Expand Down Expand Up @@ -267,7 +267,7 @@ export class Extension {
}

vscode.window.showInformationMessage('Welcome to CUE!');
return Promise.resolve();
return;
};

// cmdStartLSP is used to explicitly (re)start the LSP server. It can only be
Expand All @@ -278,8 +278,7 @@ export class Extension {
}

if (!this.config!.useLanguageServer) {
vscode.window.showErrorMessage(`useLanguageServer is configured to false`);
return Promise.resolve();
return this.showErrorMessage(`useLanguageServer is configured to false`);
}
this.manualLspStop = false;
return this.startCueLsp('manually');
Expand Down Expand Up @@ -314,7 +313,7 @@ export class Extension {
// handled elsewhere. And in case the user has manually stopped the LSP,
// we should only run it if explicitly asked to via a command. And if we
// had been through that path, then manualLspStop would be false.
return Promise.resolve();
return;
}

if (source !== '') {
Expand Down Expand Up @@ -348,14 +347,12 @@ export class Extension {
[, err] = await ve(osexecRun(cueHelpLsp));
if (err !== null) {
if (isErrnoException(err)) {
vscode.window.showErrorMessage(`failed to run ${JSON.stringify(cueHelpLsp)}: ${err}`);
return Promise.resolve();
return this.showErrorMessage(`failed to run ${JSON.stringify(cueHelpLsp)}: ${err}`);
}
// Probably running an early version of CUE with no LSP support.
vscode.window.showErrorMessage(
return this.showErrorMessage(
`the version of cmd/cue at ${JSON.stringify(cueCommand)} does not support 'cue lsp'. Please upgrade to at least v0.11.0`
);
return Promise.resolve();
}

const serverOptions: lcnode.ServerOptions = {
Expand Down Expand Up @@ -403,8 +400,6 @@ export class Extension {

// At this point, all events happend via callbacks in terms of state changes,
// or the client-server interaction of the LSP protocol.

return Promise.resolve();
};

// stopCueLsp kills the running LSP client, if there is one.
Expand All @@ -414,7 +409,7 @@ export class Extension {
}

if (this.client === undefined) {
return Promise.resolve();
return;
}

if (source !== '') {
Expand All @@ -439,8 +434,6 @@ export class Extension {
// process?
return Promise.reject(new Error(`failed to stop cue lsp: ${err}`));
}

return Promise.resolve();
};

cueLspStateChange = (s: lc.StateChangeEvent): void => {
Expand Down

0 comments on commit 500d3b9

Please sign in to comment.