aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-30 19:07:04 +0000
committerAleksey Kladov <[email protected]>2019-12-30 19:07:04 +0000
commit3d008a78d0ab1d43629326d58d4b2a157303dd00 (patch)
tree393c5cb5ad9249409808dc46cc7a344b79958ab1 /editors/code/src/main.ts
parentda80b6c1e1c09831b2f30233ddacaf50fa58f812 (diff)
Move all commands to ctx
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts23
1 files changed, 6 insertions, 17 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 7ad5e6934..4a3e1ab7c 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -13,6 +13,8 @@ let ctx!: Ctx;
13 13
14export async function activate(context: vscode.ExtensionContext) { 14export async function activate(context: vscode.ExtensionContext) {
15 ctx = new Ctx(context); 15 ctx = new Ctx(context);
16
17 // Commands which invokes manually via command pallet, shortcut, etc.
16 ctx.registerCommand('analyzerStatus', commands.analyzerStatus); 18 ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
17 ctx.registerCommand('collectGarbage', commands.collectGarbage); 19 ctx.registerCommand('collectGarbage', commands.collectGarbage);
18 ctx.registerCommand('matchingBrace', commands.matchingBrace); 20 ctx.registerCommand('matchingBrace', commands.matchingBrace);
@@ -21,28 +23,15 @@ export async function activate(context: vscode.ExtensionContext) {
21 ctx.registerCommand('syntaxTree', commands.syntaxTree); 23 ctx.registerCommand('syntaxTree', commands.syntaxTree);
22 ctx.registerCommand('expandMacro', commands.expandMacro); 24 ctx.registerCommand('expandMacro', commands.expandMacro);
23 ctx.registerCommand('run', commands.run); 25 ctx.registerCommand('run', commands.run);
24 ctx.registerCommand('runSingle', commands.runSingle); // Internal action for lenses 26
27 // Internal commands which are invoked by the server.
28 ctx.registerCommand('runSingle', commands.runSingle);
29 ctx.registerCommand('showReferences', commands.showReferences);
25 30
26 function disposeOnDeactivation(disposable: vscode.Disposable) { 31 function disposeOnDeactivation(disposable: vscode.Disposable) {
27 context.subscriptions.push(disposable); 32 context.subscriptions.push(disposable);
28 } 33 }
29 34
30 function registerCommand(name: string, f: any) {
31 disposeOnDeactivation(vscode.commands.registerCommand(name, f));
32 }
33
34 registerCommand(
35 'rust-analyzer.showReferences',
36 (uri: string, position: lc.Position, locations: lc.Location[]) => {
37 vscode.commands.executeCommand(
38 'editor.action.showReferences',
39 vscode.Uri.parse(uri),
40 Server.client.protocol2CodeConverter.asPosition(position),
41 locations.map(Server.client.protocol2CodeConverter.asLocation),
42 );
43 },
44 );
45
46 if (Server.config.enableEnhancedTyping) { 35 if (Server.config.enableEnhancedTyping) {
47 ctx.overrideCommand('type', commands.onEnter); 36 ctx.overrideCommand('type', commands.onEnter);
48 } 37 }