diff options
Diffstat (limited to 'editors/code/src/commands/index.ts')
-rw-r--r-- | editors/code/src/commands/index.ts | 66 |
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 @@ | |||
1 | import * as analyzerStatus from './analyzer_status'; | 1 | import * as vscode from 'vscode'; |
2 | import * as applySourceChange from './apply_source_change'; | 2 | import * as lc from 'vscode-languageclient'; |
3 | import * as expandMacro from './expand_macro'; | 3 | |
4 | import * as inlayHints from './inlay_hints'; | 4 | import { Ctx, Cmd } from '../ctx'; |
5 | import * as joinLines from './join_lines'; | 5 | import * as sourceChange from '../source_change'; |
6 | import * as matchingBrace from './matching_brace'; | 6 | |
7 | import * as onEnter from './on_enter'; | 7 | import { analyzerStatus } from './analyzer_status'; |
8 | import * as parentModule from './parent_module'; | 8 | import { matchingBrace } from './matching_brace'; |
9 | import * as runnables from './runnables'; | 9 | import { joinLines } from './join_lines'; |
10 | import * as syntaxTree from './syntaxTree'; | 10 | import { onEnter } from './on_enter'; |
11 | import { parentModule } from './parent_module'; | ||
12 | import { syntaxTree } from './syntax_tree'; | ||
13 | import { expandMacro } from './expand_macro'; | ||
14 | import { run, runSingle } from './runnables'; | ||
15 | |||
16 | function collectGarbage(ctx: Ctx): Cmd { | ||
17 | return async () => { | ||
18 | ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null); | ||
19 | }; | ||
20 | } | ||
21 | |||
22 | function 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 | |||
36 | function applySourceChange(ctx: Ctx): Cmd { | ||
37 | return async (change: sourceChange.SourceChange) => { | ||
38 | sourceChange.applySourceChange(ctx, change); | ||
39 | }; | ||
40 | } | ||
41 | |||
42 | function reload(ctx: Ctx): Cmd { | ||
43 | return async () => { | ||
44 | vscode.window.showInformationMessage('Reloading rust-analyzer...'); | ||
45 | await ctx.restartServer(); | ||
46 | }; | ||
47 | } | ||
11 | 48 | ||
12 | export { | 49 | export { |
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 | }; |