mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 14:43:58 +00:00
vscode: refactor levels of code nesting and string literals quotes
This commit is contained in:
parent
a3e3fba7bf
commit
3159e87c49
1 changed files with 32 additions and 28 deletions
|
@ -71,9 +71,10 @@ export async function ensureLanguageServerBinary(
|
||||||
if (isBinaryAvailable(langServerSource.path)) {
|
if (isBinaryAvailable(langServerSource.path)) {
|
||||||
return langServerSource.path;
|
return langServerSource.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
`Unable to run ${langServerSource.path} binary. ` +
|
`Unable to run ${langServerSource.path} binary. ` +
|
||||||
"To use the pre-built language server, set `rust-analyzer.raLspServerPath` " +
|
`To use the pre-built language server, set "rust-analyzer.raLspServerPath" ` +
|
||||||
"value to `null` or remove it from the settings to use it by default."
|
"value to `null` or remove it from the settings to use it by default."
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
|
@ -81,34 +82,37 @@ export async function ensureLanguageServerBinary(
|
||||||
case BinarySource.Type.GithubRelease: {
|
case BinarySource.Type.GithubRelease: {
|
||||||
const prebuiltBinaryPath = path.join(langServerSource.dir, langServerSource.file);
|
const prebuiltBinaryPath = path.join(langServerSource.dir, langServerSource.file);
|
||||||
|
|
||||||
if (!isBinaryAvailable(prebuiltBinaryPath)) {
|
if (isBinaryAvailable(prebuiltBinaryPath)) {
|
||||||
const userResponse = await vscode.window.showInformationMessage(
|
return prebuiltBinaryPath;
|
||||||
"Language server binary for rust-analyzer was not found. " +
|
|
||||||
"Do you want to download it now?",
|
|
||||||
"Download now", "Cancel"
|
|
||||||
);
|
|
||||||
if (userResponse !== "Download now") return null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await downloadLatestLanguageServer(langServerSource);
|
|
||||||
} catch (err) {
|
|
||||||
await vscode.window.showErrorMessage(
|
|
||||||
`Failed to download language server from ${langServerSource.repo.name} ` +
|
|
||||||
`GitHub repository: ${err.message}`
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
assert(
|
|
||||||
isBinaryAvailable(prebuiltBinaryPath),
|
|
||||||
"Downloaded language server binary is not functional"
|
|
||||||
);
|
|
||||||
|
|
||||||
vscode.window.showInformationMessage(
|
|
||||||
"Rust analyzer language server was successfully installed 🦀"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const userResponse = await vscode.window.showInformationMessage(
|
||||||
|
"Language server binary for rust-analyzer was not found. " +
|
||||||
|
"Do you want to download it now?",
|
||||||
|
"Download now", "Cancel"
|
||||||
|
);
|
||||||
|
if (userResponse !== "Download now") return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await downloadLatestLanguageServer(langServerSource);
|
||||||
|
} catch (err) {
|
||||||
|
await vscode.window.showErrorMessage(
|
||||||
|
`Failed to download language server from ${langServerSource.repo.name} ` +
|
||||||
|
`GitHub repository: ${err.message}`
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
assert(
|
||||||
|
isBinaryAvailable(prebuiltBinaryPath),
|
||||||
|
"Downloaded language server binary is not functional"
|
||||||
|
);
|
||||||
|
|
||||||
|
vscode.window.showInformationMessage(
|
||||||
|
"Rust analyzer language server was successfully installed 🦀"
|
||||||
|
);
|
||||||
|
|
||||||
return prebuiltBinaryPath;
|
return prebuiltBinaryPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue