diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-21 10:34:58 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-21 10:34:58 +0000 |
commit | db1bbb11fbe85a5230452359e80535a2169d0929 (patch) | |
tree | a6570ab4e6691853804a71598135f5541723f691 /editors/code/src | |
parent | 88014fcec04721350abc156efb1e18889fca5255 (diff) | |
parent | 319a09847b47086b73ea7184ee39b3be0b924c60 (diff) |
Merge #3247
3247: Improve RA version display r=matklad a=edwin0cheng
There are 2 problems of current implementation for displaying current version of RA binary:
1. If that binary is coming from built by source, the `REV` may not be updated somehow. (See discussion in [Zuilp](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/vscode.20version.20in.20console))
2. We must go through the VSCode debugger console to see the output of `console.log`.
This PR implemented a new VSCode command "Show RA Version" to display the version, which fixed the first problem. And added some `rerun-if` flags in `build.rs` to fix the second one.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/commands/index.ts | 1 | ||||
-rw-r--r-- | editors/code/src/commands/server_version.ts | 21 | ||||
-rw-r--r-- | editors/code/src/main.ts | 1 |
3 files changed, 23 insertions, 0 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index bebd99ca9..839245f48 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts | |||
@@ -13,6 +13,7 @@ export * from './syntax_tree'; | |||
13 | export * from './expand_macro'; | 13 | export * from './expand_macro'; |
14 | export * from './runnables'; | 14 | export * from './runnables'; |
15 | export * from './ssr'; | 15 | export * from './ssr'; |
16 | export * from './server_version'; | ||
16 | 17 | ||
17 | export function collectGarbage(ctx: Ctx): Cmd { | 18 | export function collectGarbage(ctx: Ctx): Cmd { |
18 | return async () => { | 19 | return async () => { |
diff --git a/editors/code/src/commands/server_version.ts b/editors/code/src/commands/server_version.ts new file mode 100644 index 000000000..421301b42 --- /dev/null +++ b/editors/code/src/commands/server_version.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | import { ensureServerBinary } from '../installation/server'; | ||
3 | import { Ctx, Cmd } from '../ctx'; | ||
4 | import { spawnSync } from 'child_process'; | ||
5 | |||
6 | export function serverVersion(ctx: Ctx): Cmd { | ||
7 | return async () => { | ||
8 | const binaryPath = await ensureServerBinary(ctx.config.serverSource); | ||
9 | |||
10 | if (binaryPath == null) { | ||
11 | throw new Error( | ||
12 | "Rust Analyzer Language Server is not available. " + | ||
13 | "Please, ensure its [proper installation](https://rust-analyzer.github.io/manual.html#installation)." | ||
14 | ); | ||
15 | } | ||
16 | |||
17 | const version = spawnSync(binaryPath, ["--version"], { encoding: "utf8" }).stdout; | ||
18 | vscode.window.showInformationMessage('rust-analyzer version : ' + version); | ||
19 | }; | ||
20 | } | ||
21 | |||
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index a22e0bc66..de19a44e5 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -55,6 +55,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
55 | ctx.registerCommand('run', commands.run); | 55 | ctx.registerCommand('run', commands.run); |
56 | ctx.registerCommand('onEnter', commands.onEnter); | 56 | ctx.registerCommand('onEnter', commands.onEnter); |
57 | ctx.registerCommand('ssr', commands.ssr); | 57 | ctx.registerCommand('ssr', commands.ssr); |
58 | ctx.registerCommand('serverVersion', commands.serverVersion); | ||
58 | 59 | ||
59 | // Internal commands which are invoked by the server. | 60 | // Internal commands which are invoked by the server. |
60 | ctx.registerCommand('runSingle', commands.runSingle); | 61 | ctx.registerCommand('runSingle', commands.runSingle); |