aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/config.ts
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-03-14 01:01:14 +0000
committerVeetaha <[email protected]>2020-03-14 01:01:14 +0000
commit5e32a67c83d46862db0166c263efc65b6ecd5b52 (patch)
tree9fbc81a8cfef4d9d76b29d23d63c6a3126ee8f8e /editors/code/src/config.ts
parentd7b46e0527cd7b52845f37cffc57cbae4ba0b945 (diff)
vscode-postrefactor: more logging and better error handling
Diffstat (limited to 'editors/code/src/config.ts')
-rw-r--r--editors/code/src/config.ts36
1 files changed, 17 insertions, 19 deletions
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 @@
1import * as os from "os"; 1import * as os from "os";
2import * as vscode from 'vscode'; 2import * as vscode from 'vscode';
3import { ArtifactSource } from "./installation/interfaces"; 3import { ArtifactSource } from "./installation/interfaces";
4import { log } from "./util"; 4import { log, vscodeReloadWindow } from "./util";
5 5
6const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; 6const 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