From 4cee3e9f22a7d5845a97062fd1ab7a3e7119cb7f Mon Sep 17 00:00:00 2001 From: veetaha Date: Tue, 24 Mar 2020 01:11:36 +0200 Subject: vscode: more type safety --- editors/code/package.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'editors/code') diff --git a/editors/code/package.json b/editors/code/package.json index eb5748515..1d113ebb6 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -73,10 +73,18 @@ "type": "string" }, "args": { - "type": "array" + "type": "array", + "items": { + "type": "string" + } }, "env": { - "type": "object" + "type": "object", + "patternProperties": { + ".+": { + "type": "string" + } + } } } } -- cgit v1.2.3 From be4977da7fa78ae386b595ef2227d034ebb3a7e5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 24 Mar 2020 09:31:42 +0100 Subject: Don't try to enable proposed API's on stable --- editors/code/src/client.ts | 6 ++++-- editors/code/src/config.ts | 18 ++++++------------ editors/code/src/main.ts | 14 +++++++------- 3 files changed, 17 insertions(+), 21 deletions(-) (limited to 'editors/code') diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 08d821dd0..82ca749f3 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -99,8 +99,10 @@ export async function createClient(config: Config, serverPath: string): Promise< // Note that while the CallHierarchyFeature is stable the LSP protocol is not. res.registerFeature(new CallHierarchyFeature(res)); - if (config.highlightingSemanticTokens) { - res.registerFeature(new SemanticTokensFeature(res)); + if (config.package.enableProposedApi) { + if (config.highlightingSemanticTokens) { + res.registerFeature(new SemanticTokensFeature(res)); + } } return res; diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index be5296fcf..602538ea1 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -38,17 +38,11 @@ export class Config { ] .map(opt => `${this.rootSection}.${opt}`); - readonly packageJsonVersion: string = vscode - .extensions - .getExtension(this.extensionId)! - .packageJSON - .version; - - readonly releaseTag: string | undefined = vscode - .extensions - .getExtension(this.extensionId)! - .packageJSON - .releaseTag ?? undefined; + readonly package: { + version: string; + releaseTag: string | undefined; + enableProposedApi: boolean | undefined; + } = vscode.extensions.getExtension(this.extensionId)!.packageJSON; private cfg!: vscode.WorkspaceConfiguration; @@ -62,7 +56,7 @@ export class Config { const enableLogging = this.cfg.get("trace.extension") as boolean; log.setEnabled(enableLogging); log.debug( - "Extension version:", this.packageJsonVersion, + "Extension version:", this.package.version, "using configuration:", this.cfg ); } diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 5d2da9a76..7b7c19dfc 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -110,9 +110,9 @@ async function bootstrap(config: Config, state: PersistentState): Promise { - if (config.releaseTag === undefined) return; + if (config.package.releaseTag === undefined) return; if (config.channel === "stable") { - if (config.releaseTag === NIGHTLY_TAG) { + if (config.package.releaseTag === NIGHTLY_TAG) { vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension. To switch to stable, uninstall the extension and re-install it from the marketplace`); } @@ -185,7 +185,7 @@ async function getServer(config: Config, state: PersistentState): Promise artifact.name === binaryName); assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 }); - await state.updateServerVersion(config.packageJsonVersion); + await state.updateServerVersion(config.package.version); return dest; } -- cgit v1.2.3