diff options
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/analyzer_status.ts | 19 | ||||
-rw-r--r-- | editors/code/src/commands/index.ts | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts index 5840e8fc0..6e92c50ef 100644 --- a/editors/code/src/commands/analyzer_status.ts +++ b/editors/code/src/commands/analyzer_status.ts | |||
@@ -1,19 +1,19 @@ | |||
1 | import * as vscode from 'vscode'; | 1 | import * as vscode from 'vscode'; |
2 | import { Server } from '../server'; | 2 | import { Ctx } from '../ctx'; |
3 | // Shows status of rust-analyzer (for debugging) | 3 | // Shows status of rust-analyzer (for debugging) |
4 | 4 | ||
5 | export function makeCommand(context: vscode.ExtensionContext) { | 5 | export function analyzerStatus(ctx: Ctx) { |
6 | let poller: NodeJS.Timer | null = null; | 6 | let poller: NodeJS.Timer | null = null; |
7 | const tdcp = new TextDocumentContentProvider(); | 7 | const tdcp = new TextDocumentContentProvider(ctx); |
8 | 8 | ||
9 | context.subscriptions.push( | 9 | ctx.pushCleanup( |
10 | vscode.workspace.registerTextDocumentContentProvider( | 10 | vscode.workspace.registerTextDocumentContentProvider( |
11 | 'rust-analyzer-status', | 11 | 'rust-analyzer-status', |
12 | tdcp, | 12 | tdcp, |
13 | ), | 13 | ), |
14 | ); | 14 | ); |
15 | 15 | ||
16 | context.subscriptions.push({ | 16 | ctx.pushCleanup({ |
17 | dispose() { | 17 | dispose() { |
18 | if (poller != null) { | 18 | if (poller != null) { |
19 | clearInterval(poller); | 19 | clearInterval(poller); |
@@ -39,9 +39,16 @@ export function makeCommand(context: vscode.ExtensionContext) { | |||
39 | 39 | ||
40 | class TextDocumentContentProvider | 40 | class TextDocumentContentProvider |
41 | implements vscode.TextDocumentContentProvider { | 41 | implements vscode.TextDocumentContentProvider { |
42 | |||
42 | uri = vscode.Uri.parse('rust-analyzer-status://status'); | 43 | uri = vscode.Uri.parse('rust-analyzer-status://status'); |
43 | eventEmitter = new vscode.EventEmitter<vscode.Uri>(); | 44 | eventEmitter = new vscode.EventEmitter<vscode.Uri>(); |
44 | 45 | ||
46 | ctx: Ctx | ||
47 | |||
48 | constructor(ctx: Ctx) { | ||
49 | this.ctx = ctx | ||
50 | } | ||
51 | |||
45 | provideTextDocumentContent( | 52 | provideTextDocumentContent( |
46 | _uri: vscode.Uri, | 53 | _uri: vscode.Uri, |
47 | ): vscode.ProviderResult<string> { | 54 | ): vscode.ProviderResult<string> { |
@@ -49,7 +56,7 @@ class TextDocumentContentProvider | |||
49 | if (editor == null) { | 56 | if (editor == null) { |
50 | return ''; | 57 | return ''; |
51 | } | 58 | } |
52 | return Server.client.sendRequest<string>( | 59 | return this.ctx.client.sendRequest<string>( |
53 | 'rust-analyzer/analyzerStatus', | 60 | 'rust-analyzer/analyzerStatus', |
54 | null, | 61 | null, |
55 | ); | 62 | ); |
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index 13a696758..ec1995396 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as analyzerStatus from './analyzer_status'; | 1 | import { analyzerStatus } from './analyzer_status'; |
2 | import * as applySourceChange from './apply_source_change'; | 2 | import * as applySourceChange from './apply_source_change'; |
3 | import * as expandMacro from './expand_macro'; | 3 | import * as expandMacro from './expand_macro'; |
4 | import * as inlayHints from './inlay_hints'; | 4 | import * as inlayHints from './inlay_hints'; |