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.ts66
1 files changed, 53 insertions, 13 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts
index 13a696758..9a1697dcb 100644
--- a/editors/code/src/commands/index.ts
+++ b/editors/code/src/commands/index.ts
@@ -1,23 +1,63 @@
1import * as analyzerStatus from './analyzer_status'; 1import * as vscode from 'vscode';
2import * as applySourceChange from './apply_source_change'; 2import * as lc from 'vscode-languageclient';
3import * as expandMacro from './expand_macro'; 3
4import * as inlayHints from './inlay_hints'; 4import { Ctx, Cmd } from '../ctx';
5import * as joinLines from './join_lines'; 5import * as sourceChange from '../source_change';
6import * as matchingBrace from './matching_brace'; 6
7import * as onEnter from './on_enter'; 7import { analyzerStatus } from './analyzer_status';
8import * as parentModule from './parent_module'; 8import { matchingBrace } from './matching_brace';
9import * as runnables from './runnables'; 9import { joinLines } from './join_lines';
10import * as syntaxTree from './syntaxTree'; 10import { onEnter } from './on_enter';
11import { parentModule } from './parent_module';
12import { syntaxTree } from './syntax_tree';
13import { expandMacro } from './expand_macro';
14import { run, runSingle } from './runnables';
15
16function collectGarbage(ctx: Ctx): Cmd {
17 return async () => {
18 ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null);
19 };
20}
21
22function showReferences(ctx: Ctx): Cmd {
23 return (uri: string, position: lc.Position, locations: lc.Location[]) => {
24 let client = ctx.client;
25 if (client) {
26 vscode.commands.executeCommand(
27 'editor.action.showReferences',
28 vscode.Uri.parse(uri),
29 client.protocol2CodeConverter.asPosition(position),
30 locations.map(client.protocol2CodeConverter.asLocation),
31 );
32 }
33 };
34}
35
36function applySourceChange(ctx: Ctx): Cmd {
37 return async (change: sourceChange.SourceChange) => {
38 sourceChange.applySourceChange(ctx, change);
39 };
40}
41
42function reload(ctx: Ctx): Cmd {
43 return async () => {
44 vscode.window.showInformationMessage('Reloading rust-analyzer...');
45 await ctx.restartServer();
46 };
47}
11 48
12export { 49export {
13 analyzerStatus, 50 analyzerStatus,
14 applySourceChange,
15 expandMacro, 51 expandMacro,
16 joinLines, 52 joinLines,
17 matchingBrace, 53 matchingBrace,
18 parentModule, 54 parentModule,
19 runnables,
20 syntaxTree, 55 syntaxTree,
21 onEnter, 56 onEnter,
22 inlayHints, 57 collectGarbage,
58 run,
59 runSingle,
60 showReferences,
61 applySourceChange,
62 reload
23}; 63};