aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands/index.ts')
-rw-r--r--editors/code/src/commands/index.ts25
1 files changed, 18 insertions, 7 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts
index c28709c8a..4431fdcf6 100644
--- a/editors/code/src/commands/index.ts
+++ b/editors/code/src/commands/index.ts
@@ -15,18 +15,21 @@ import { run, runSingle } from './runnables';
15 15
16function collectGarbage(ctx: Ctx): Cmd { 16function collectGarbage(ctx: Ctx): Cmd {
17 return async () => { 17 return async () => {
18 ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null); 18 ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null);
19 }; 19 };
20} 20}
21 21
22function showReferences(ctx: Ctx): Cmd { 22function showReferences(ctx: Ctx): Cmd {
23 return (uri: string, position: lc.Position, locations: lc.Location[]) => { 23 return (uri: string, position: lc.Position, locations: lc.Location[]) => {
24 vscode.commands.executeCommand( 24 let client = ctx.client;
25 'editor.action.showReferences', 25 if (client) {
26 vscode.Uri.parse(uri), 26 vscode.commands.executeCommand(
27 ctx.client.protocol2CodeConverter.asPosition(position), 27 'editor.action.showReferences',
28 locations.map(ctx.client.protocol2CodeConverter.asLocation), 28 vscode.Uri.parse(uri),
29 ); 29 client.protocol2CodeConverter.asPosition(position),
30 locations.map(client.protocol2CodeConverter.asLocation),
31 );
32 }
30 }; 33 };
31} 34}
32 35
@@ -36,6 +39,13 @@ function applySourceChange(ctx: Ctx): Cmd {
36 } 39 }
37} 40}
38 41
42function reload(ctx: Ctx): Cmd {
43 return async () => {
44 vscode.window.showInformationMessage('Reloading rust-analyzer...');
45 await ctx.restartServer();
46 }
47}
48
39export { 49export {
40 analyzerStatus, 50 analyzerStatus,
41 expandMacro, 51 expandMacro,
@@ -49,4 +59,5 @@ export {
49 runSingle, 59 runSingle,
50 showReferences, 60 showReferences,
51 applySourceChange, 61 applySourceChange,
62 reload
52}; 63};