aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/package.json2
-rw-r--r--editors/code/src/client.ts2
-rw-r--r--editors/code/src/config.ts17
-rw-r--r--editors/code/src/ctx.ts4
-rw-r--r--editors/code/src/installation/interfaces.ts13
5 files changed, 35 insertions, 3 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index a607c2148..96b8e9eb0 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -6,7 +6,7 @@
6 "private": true, 6 "private": true,
7 "icon": "icon.png", 7 "icon": "icon.png",
8 "//": "The real version is in release.yaml, this one just needs to be bigger", 8 "//": "The real version is in release.yaml, this one just needs to be bigger",
9 "version": "0.2.0-dev", 9 "version": "0.2.20200211-dev",
10 "publisher": "matklad", 10 "publisher": "matklad",
11 "repository": { 11 "repository": {
12 "url": "https://github.com/rust-analyzer/rust-analyzer.git", 12 "url": "https://github.com/rust-analyzer/rust-analyzer.git",
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 12c97be2f..efef820ab 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -11,7 +11,7 @@ export async function createClient(config: Config): Promise<null | lc.LanguageCl
11 // It might be a good idea to test if the uri points to a file. 11 // It might be a good idea to test if the uri points to a file.
12 const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.'; 12 const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.';
13 13
14 const serverPath = await ensureServerBinary(config.serverBinarySource); 14 const serverPath = await ensureServerBinary(config.serverSource);
15 if (!serverPath) return null; 15 if (!serverPath) return null;
16 16
17 const run: lc.Executable = { 17 const run: lc.Executable = {
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 7866ed7e1..4335c3a71 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -24,6 +24,19 @@ export class Config {
24 ] 24 ]
25 .map(opt => `${Config.rootSection}.${opt}`); 25 .map(opt => `${Config.rootSection}.${opt}`);
26 26
27 private static readonly extensionVersion: string = (() => {
28 const packageJsonVersion = vscode
29 .extensions
30 .getExtension("matklad.rust-analyzer")!
31 .packageJSON
32 .version as string; // n.n.YYYYMMDD
33
34 const realVersionRegexp = /^\d+\.\d+\.(\d{4})(\d{2})(\d{2})/;
35 const [, yyyy, mm, dd] = packageJsonVersion.match(realVersionRegexp)!;
36
37 return `${yyyy}-${mm}-${dd}`;
38 })();
39
27 private cfg!: vscode.WorkspaceConfiguration; 40 private cfg!: vscode.WorkspaceConfiguration;
28 41
29 constructor(private readonly ctx: vscode.ExtensionContext) { 42 constructor(private readonly ctx: vscode.ExtensionContext) {
@@ -98,7 +111,7 @@ export class Config {
98 } 111 }
99 } 112 }
100 113
101 get serverBinarySource(): null | BinarySource { 114 get serverSource(): null | BinarySource {
102 const serverPath = RA_LSP_DEBUG ?? this.cfg.get<null | string>("raLspServerPath"); 115 const serverPath = RA_LSP_DEBUG ?? this.cfg.get<null | string>("raLspServerPath");
103 116
104 if (serverPath) { 117 if (serverPath) {
@@ -116,6 +129,8 @@ export class Config {
116 type: BinarySource.Type.GithubRelease, 129 type: BinarySource.Type.GithubRelease,
117 dir: this.ctx.globalStoragePath, 130 dir: this.ctx.globalStoragePath,
118 file: prebuiltBinaryName, 131 file: prebuiltBinaryName,
132 storage: this.ctx.globalState,
133 version: Config.extensionVersion,
119 repo: { 134 repo: {
120 name: "rust-analyzer", 135 name: "rust-analyzer",
121 owner: "rust-analyzer", 136 owner: "rust-analyzer",
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 70042a479..9fcf2ec38 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -60,6 +60,10 @@ export class Ctx {
60 this.pushCleanup(d); 60 this.pushCleanup(d);
61 } 61 }
62 62
63 get globalState(): vscode.Memento {
64 return this.extCtx.globalState;
65 }
66
63 get subscriptions(): Disposable[] { 67 get subscriptions(): Disposable[] {
64 return this.extCtx.subscriptions; 68 return this.extCtx.subscriptions;
65 } 69 }
diff --git a/editors/code/src/installation/interfaces.ts b/editors/code/src/installation/interfaces.ts
index 93ea577d4..e40839e4b 100644
--- a/editors/code/src/installation/interfaces.ts
+++ b/editors/code/src/installation/interfaces.ts
@@ -1,3 +1,5 @@
1import * as vscode from "vscode";
2
1export interface GithubRepo { 3export interface GithubRepo {
2 name: string; 4 name: string;
3 owner: string; 5 owner: string;
@@ -50,6 +52,17 @@ export namespace BinarySource {
50 * and in local `.dir`. 52 * and in local `.dir`.
51 */ 53 */
52 file: string; 54 file: string;
55
56 /**
57 * Tag of github release that denotes a version required by this extension.
58 */
59 version: string;
60
61 /**
62 * Object that provides `get()/update()` operations to store metadata
63 * about the actual binary, e.g. its actual version.
64 */
65 storage: vscode.Memento;
53 } 66 }
54 67
55} 68}