vscode-postrefactor: minor config refactorings

This commit is contained in:
Veetaha 2020-03-14 02:00:34 +02:00
parent 607d017229
commit 7f02d4657b
2 changed files with 5 additions and 4 deletions

View File

@ -35,6 +35,7 @@ export class Config {
private readonly rootSection = "rust-analyzer";
private readonly requiresReloadOpts = [
"serverPath",
"cargoFeatures",
"cargo-watch",
"highlighting.semanticTokens",
@ -50,7 +51,7 @@ export class Config {
.extensions
.getExtension(this.extensionId)!
.packageJSON
.version as string;
.version as string; // n.n.YYYYMMDD[-nightly]
if (packageJsonVersion.endsWith(NIGHTLY_TAG)) return NIGHTLY_TAG;
@ -193,7 +194,7 @@ export class Config {
// We don't do runtime config validation here for simplicity. More on stackoverflow:
// https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension
get serverPath() { return this.cfg.get("serverPath") as null | string; }
private get serverPath() { return this.cfg.get("serverPath") as null | string; }
get updatesChannel() { return this.cfg.get("updates.channel") as UpdatesChannel; }
get askBeforeDownload() { return this.cfg.get("updates.askBeforeDownload") as boolean; }
get highlightingSemanticTokens() { return this.cfg.get("highlighting.semanticTokens") as boolean; }

View File

@ -4,7 +4,7 @@ import { promises as fs } from 'fs';
import { vscodeReinstallExtension, vscodeReloadWindow, log, vscodeInstallExtensionFromVsix, assert, notReentrant } from "../util";
import { Config, UpdatesChannel } from "../config";
import { ArtifactReleaseInfo } from "./interfaces";
import { ArtifactReleaseInfo, ArtifactSource } from "./interfaces";
import { downloadArtifactWithProgressUi } from "./downloads";
import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info";
@ -16,7 +16,7 @@ const HEURISTIC_NIGHTLY_RELEASE_PERIOD_IN_HOURS = 25;
*/
export async function ensureProperExtensionVersion(config: Config): Promise<never | void> {
// User has built lsp server from sources, she should manage updates manually
if (config.serverPath !== null) return;
if (config.serverSource?.type === ArtifactSource.Type.ExplicitPath) return;
const currentUpdChannel = config.installedExtensionUpdateChannel;
const desiredUpdChannel = config.updatesChannel;