diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package-lock.json | 2 | ||||
-rw-r--r-- | editors/code/src/config.ts | 36 | ||||
-rw-r--r-- | editors/code/src/installation/extension.ts | 16 |
3 files changed, 31 insertions, 23 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json index 575dc7c4a..1b497edd7 100644 --- a/editors/code/package-lock.json +++ b/editors/code/package-lock.json | |||
@@ -1,6 +1,6 @@ | |||
1 | { | 1 | { |
2 | "name": "rust-analyzer", | 2 | "name": "rust-analyzer", |
3 | "version": "0.2.20200309-nightly", | 3 | "version": "0.2.20200309", |
4 | "lockfileVersion": 1, | 4 | "lockfileVersion": 1, |
5 | "requires": true, | 5 | "requires": true, |
6 | "dependencies": { | 6 | "dependencies": { |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 93f72409d..f63e1d20e 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as os from "os"; | 1 | import * as os from "os"; |
2 | import * as vscode from 'vscode'; | 2 | import * as vscode from 'vscode'; |
3 | import { ArtifactSource } from "./installation/interfaces"; | 3 | import { ArtifactSource } from "./installation/interfaces"; |
4 | import { log } from "./util"; | 4 | import { log, vscodeReloadWindow } from "./util"; |
5 | 5 | ||
6 | const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; | 6 | const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; |
7 | 7 | ||
@@ -43,20 +43,20 @@ export class Config { | |||
43 | ] | 43 | ] |
44 | .map(opt => `${this.rootSection}.${opt}`); | 44 | .map(opt => `${this.rootSection}.${opt}`); |
45 | 45 | ||
46 | readonly packageJsonVersion = vscode | ||
47 | .extensions | ||
48 | .getExtension(this.extensionId)! | ||
49 | .packageJSON | ||
50 | .version as string; // n.n.YYYYMMDD[-nightly] | ||
51 | |||
46 | /** | 52 | /** |
47 | * Either `nightly` or `YYYY-MM-DD` (i.e. `stable` release) | 53 | * Either `nightly` or `YYYY-MM-DD` (i.e. `stable` release) |
48 | */ | 54 | */ |
49 | readonly extensionReleaseTag: string = (() => { | 55 | readonly extensionReleaseTag: string = (() => { |
50 | const packageJsonVersion = vscode | 56 | if (this.packageJsonVersion.endsWith(NIGHTLY_TAG)) return NIGHTLY_TAG; |
51 | .extensions | ||
52 | .getExtension(this.extensionId)! | ||
53 | .packageJSON | ||
54 | .version as string; // n.n.YYYYMMDD[-nightly] | ||
55 | |||
56 | if (packageJsonVersion.endsWith(NIGHTLY_TAG)) return NIGHTLY_TAG; | ||
57 | 57 | ||
58 | const realVersionRegexp = /^\d+\.\d+\.(\d{4})(\d{2})(\d{2})/; | 58 | const realVersionRegexp = /^\d+\.\d+\.(\d{4})(\d{2})(\d{2})/; |
59 | const [, yyyy, mm, dd] = packageJsonVersion.match(realVersionRegexp)!; | 59 | const [, yyyy, mm, dd] = this.packageJsonVersion.match(realVersionRegexp)!; |
60 | 60 | ||
61 | return `${yyyy}-${mm}-${dd}`; | 61 | return `${yyyy}-${mm}-${dd}`; |
62 | })(); | 62 | })(); |
@@ -72,7 +72,10 @@ export class Config { | |||
72 | this.cfg = vscode.workspace.getConfiguration(this.rootSection); | 72 | this.cfg = vscode.workspace.getConfiguration(this.rootSection); |
73 | const enableLogging = this.cfg.get("trace.extension") as boolean; | 73 | const enableLogging = this.cfg.get("trace.extension") as boolean; |
74 | log.setEnabled(enableLogging); | 74 | log.setEnabled(enableLogging); |
75 | log.debug("Using configuration:", this.cfg); | 75 | log.debug( |
76 | "Extension version:", this.packageJsonVersion, | ||
77 | "using configuration:", this.cfg | ||
78 | ); | ||
76 | } | 79 | } |
77 | 80 | ||
78 | private async onConfigChange(event: vscode.ConfigurationChangeEvent) { | 81 | private async onConfigChange(event: vscode.ConfigurationChangeEvent) { |
@@ -90,7 +93,7 @@ export class Config { | |||
90 | ); | 93 | ); |
91 | 94 | ||
92 | if (userResponse === "Reload now") { | 95 | if (userResponse === "Reload now") { |
93 | vscode.commands.executeCommand("workbench.action.reloadWindow"); | 96 | await vscodeReloadWindow(); |
94 | } | 97 | } |
95 | } | 98 | } |
96 | 99 | ||
@@ -180,16 +183,11 @@ export class Config { | |||
180 | } | 183 | } |
181 | 184 | ||
182 | readonly installedNightlyExtensionReleaseDate = new DateStorage( | 185 | readonly installedNightlyExtensionReleaseDate = new DateStorage( |
183 | "rust-analyzer-installed-nightly-extension-release-date", | 186 | "installed-nightly-extension-release-date", |
184 | this.ctx.globalState | 187 | this.ctx.globalState |
185 | ); | 188 | ); |
186 | readonly serverReleaseDate = new DateStorage( | 189 | readonly serverReleaseDate = new DateStorage("server-release-date", this.ctx.globalState); |
187 | "rust-analyzer-server-release-date", | 190 | readonly serverReleaseTag = new Storage<null | string>("server-release-tag", this.ctx.globalState, null); |
188 | this.ctx.globalState | ||
189 | ); | ||
190 | readonly serverReleaseTag = new Storage<null | string>( | ||
191 | "rust-analyzer-release-tag", this.ctx.globalState, null | ||
192 | ); | ||
193 | 191 | ||
194 | // We don't do runtime config validation here for simplicity. More on stackoverflow: | 192 | // We don't do runtime config validation here for simplicity. More on stackoverflow: |
195 | // https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension | 193 | // https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension |
diff --git a/editors/code/src/installation/extension.ts b/editors/code/src/installation/extension.ts index f6dd20d82..0d69b8d0c 100644 --- a/editors/code/src/installation/extension.ts +++ b/editors/code/src/installation/extension.ts | |||
@@ -44,10 +44,20 @@ export async function ensureProperExtensionVersion(config: Config): Promise<neve | |||
44 | 44 | ||
45 | const currentExtReleaseDate = config.installedNightlyExtensionReleaseDate.get(); | 45 | const currentExtReleaseDate = config.installedNightlyExtensionReleaseDate.get(); |
46 | 46 | ||
47 | assert(currentExtReleaseDate !== null, "nightly release date must've been set during installation"); | 47 | if (currentExtReleaseDate === null) { |
48 | void vscode.window.showErrorMessage( | ||
49 | "Nightly release date must've been set during the installation. " + | ||
50 | "Did you download and install the nightly .vsix package manually?" | ||
51 | ); | ||
52 | throw new Error("Nightly release date was not set in globalStorage"); | ||
53 | } | ||
48 | 54 | ||
49 | const hoursSinceLastUpdate = diffInHours(currentExtReleaseDate, new Date()); | 55 | const dateNow = new Date; |
50 | log.debug(`Current rust-analyzer nightly was downloaded ${hoursSinceLastUpdate} hours ago`); | 56 | const hoursSinceLastUpdate = diffInHours(currentExtReleaseDate, dateNow); |
57 | log.debug( | ||
58 | "Current rust-analyzer nightly was downloaded", hoursSinceLastUpdate, | ||
59 | "hours ago, namely:", currentExtReleaseDate, "and now is", dateNow | ||
60 | ); | ||
51 | 61 | ||
52 | if (hoursSinceLastUpdate < HEURISTIC_NIGHTLY_RELEASE_PERIOD_IN_HOURS) { | 62 | if (hoursSinceLastUpdate < HEURISTIC_NIGHTLY_RELEASE_PERIOD_IN_HOURS) { |
53 | return; | 63 | return; |