aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/src/ctx.ts16
-rw-r--r--editors/code/src/main.ts20
2 files changed, 16 insertions, 20 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 9dd2b7d4f..87f1574d3 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -2,30 +2,26 @@ import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3import { Server } from './server'; 3import { Server } from './server';
4 4
5
6export class Ctx { 5export class Ctx {
7 private extCtx: vscode.ExtensionContext 6 private extCtx: vscode.ExtensionContext;
8 7
9 constructor(extCtx: vscode.ExtensionContext) { 8 constructor(extCtx: vscode.ExtensionContext) {
10 this.extCtx = extCtx 9 this.extCtx = extCtx;
11 } 10 }
12 11
13 get client(): lc.LanguageClient { 12 get client(): lc.LanguageClient {
14 return Server.client 13 return Server.client;
15 } 14 }
16 15
17 registerCommand( 16 registerCommand(name: string, factory: (ctx: Ctx) => Cmd) {
18 name: string, 17 const fullName = `rust-analyzer.${name}`;
19 factory: (ctx: Ctx) => Cmd,
20 ) {
21 const fullName = `rust-analyzer.${name}`
22 const cmd = factory(this); 18 const cmd = factory(this);
23 const d = vscode.commands.registerCommand(fullName, cmd); 19 const d = vscode.commands.registerCommand(fullName, cmd);
24 this.pushCleanup(d); 20 this.pushCleanup(d);
25 } 21 }
26 22
27 pushCleanup(d: { dispose(): any }) { 23 pushCleanup(d: { dispose(): any }) {
28 this.extCtx.subscriptions.push(d) 24 this.extCtx.subscriptions.push(d);
29 } 25 }
30} 26}
31 27
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 9500219ca..f96fb1962 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -9,7 +9,7 @@ import { StatusDisplay } from './commands/watch_status';
9import * as events from './events'; 9import * as events from './events';
10import * as notifications from './notifications'; 10import * as notifications from './notifications';
11import { Server } from './server'; 11import { Server } from './server';
12import { Ctx } from './ctx' 12import { Ctx } from './ctx';
13 13
14let ctx!: Ctx; 14let ctx!: Ctx;
15 15
@@ -94,15 +94,15 @@ export async function activate(context: vscode.ExtensionContext) {
94 string, 94 string,
95 lc.GenericNotificationHandler, 95 lc.GenericNotificationHandler,
96 ]> = [ 96 ]> = [
97 [ 97 [
98 'rust-analyzer/publishDecorations', 98 'rust-analyzer/publishDecorations',
99 notifications.publishDecorations.handle, 99 notifications.publishDecorations.handle,
100 ], 100 ],
101 [ 101 [
102 '$/progress', 102 '$/progress',
103 params => watchStatus.handleProgressNotification(params), 103 params => watchStatus.handleProgressNotification(params),
104 ], 104 ],
105 ]; 105 ];
106 const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); 106 const syntaxTreeContentProvider = new SyntaxTreeContentProvider();
107 const expandMacroContentProvider = new ExpandMacroContentProvider(); 107 const expandMacroContentProvider = new ExpandMacroContentProvider();
108 108