diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-25 11:17:40 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-25 11:17:40 +0100 |
commit | e4f91bfa578e57c1ef4be3343ebb4e8950e5dae6 (patch) | |
tree | cb0ab7180b97dfdf8347c15d6e445628f7802367 /editors/code/src/commands/analyzer_status.ts | |
parent | 1527feb744c7911b6ca482554f0399d3ef0ebfdc (diff) | |
parent | 6058b8b0f6a24ad5b905d99d780a31b9e3d578d7 (diff) |
Merge #4605
4605: Reorganize TypeScript r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code/src/commands/analyzer_status.ts')
-rw-r--r-- | editors/code/src/commands/analyzer_status.ts | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts deleted file mode 100644 index 09daa3402..000000000 --- a/editors/code/src/commands/analyzer_status.ts +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | |||
3 | import * as ra from '../rust-analyzer-api'; | ||
4 | import { Ctx, Cmd } from '../ctx'; | ||
5 | |||
6 | // Shows status of rust-analyzer (for debugging) | ||
7 | export function analyzerStatus(ctx: Ctx): Cmd { | ||
8 | let poller: NodeJS.Timer | undefined = undefined; | ||
9 | const tdcp = new TextDocumentContentProvider(ctx); | ||
10 | |||
11 | ctx.pushCleanup( | ||
12 | vscode.workspace.registerTextDocumentContentProvider( | ||
13 | 'rust-analyzer-status', | ||
14 | tdcp, | ||
15 | ), | ||
16 | ); | ||
17 | |||
18 | ctx.pushCleanup({ | ||
19 | dispose() { | ||
20 | if (poller !== undefined) { | ||
21 | clearInterval(poller); | ||
22 | } | ||
23 | }, | ||
24 | }); | ||
25 | |||
26 | return async () => { | ||
27 | if (poller === undefined) { | ||
28 | poller = setInterval(() => tdcp.eventEmitter.fire(tdcp.uri), 1000); | ||
29 | } | ||
30 | const document = await vscode.workspace.openTextDocument(tdcp.uri); | ||
31 | return vscode.window.showTextDocument(document, vscode.ViewColumn.Two, true); | ||
32 | }; | ||
33 | } | ||
34 | |||
35 | class TextDocumentContentProvider implements vscode.TextDocumentContentProvider { | ||
36 | readonly uri = vscode.Uri.parse('rust-analyzer-status://status'); | ||
37 | readonly eventEmitter = new vscode.EventEmitter<vscode.Uri>(); | ||
38 | |||
39 | constructor(private readonly ctx: Ctx) { | ||
40 | } | ||
41 | |||
42 | provideTextDocumentContent(_uri: vscode.Uri): vscode.ProviderResult<string> { | ||
43 | if (!vscode.window.activeTextEditor) return ''; | ||
44 | |||
45 | return this.ctx.client.sendRequest(ra.analyzerStatus, null); | ||
46 | } | ||
47 | |||
48 | get onDidChange(): vscode.Event<vscode.Uri> { | ||
49 | return this.eventEmitter.event; | ||
50 | } | ||
51 | } | ||