diff options
author | Veetaha <[email protected]> | 2020-02-24 22:50:36 +0000 |
---|---|---|
committer | Veetaha <[email protected]> | 2020-02-24 22:50:36 +0000 |
commit | 31d9932d18151bffe94e4137ac3b5d10df37641f (patch) | |
tree | c771d6872eb902c8ffa70461ddca6003b14d875d /editors | |
parent | 603bc71a57ce386d78f1b1c842714ff0dbeeaf9c (diff) |
vscode: migrate expand_macro to rust-analyzer-api.ts
Diffstat (limited to 'editors')
-rw-r--r-- | editors/code/src/commands/expand_macro.ts | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/editors/code/src/commands/expand_macro.ts b/editors/code/src/commands/expand_macro.ts index edec9bbc1..23f2ef1d5 100644 --- a/editors/code/src/commands/expand_macro.ts +++ b/editors/code/src/commands/expand_macro.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as vscode from 'vscode'; | 1 | import * as vscode from 'vscode'; |
2 | import * as lc from 'vscode-languageclient'; | 2 | import * as ra from '../rust-analyzer-api'; |
3 | 3 | ||
4 | import { Ctx, Cmd } from '../ctx'; | 4 | import { Ctx, Cmd } from '../ctx'; |
5 | 5 | ||
@@ -26,12 +26,7 @@ export function expandMacro(ctx: Ctx): Cmd { | |||
26 | }; | 26 | }; |
27 | } | 27 | } |
28 | 28 | ||
29 | interface ExpandedMacro { | 29 | function codeFormat(expanded: ra.ExpandedMacro): string { |
30 | name: string; | ||
31 | expansion: string; | ||
32 | } | ||
33 | |||
34 | function codeFormat(expanded: ExpandedMacro): string { | ||
35 | let result = `// Recursive expansion of ${expanded.name}! macro\n`; | 30 | let result = `// Recursive expansion of ${expanded.name}! macro\n`; |
36 | result += '// ' + '='.repeat(result.length - 3); | 31 | result += '// ' + '='.repeat(result.length - 3); |
37 | result += '\n\n'; | 32 | result += '\n\n'; |
@@ -54,14 +49,11 @@ class TextDocumentContentProvider | |||
54 | if (!editor || !client) return ''; | 49 | if (!editor || !client) return ''; |
55 | 50 | ||
56 | const position = editor.selection.active; | 51 | const position = editor.selection.active; |
57 | const request: lc.TextDocumentPositionParams = { | 52 | |
53 | const expanded = await client.sendRequest(ra.expandMacro, { | ||
58 | textDocument: { uri: editor.document.uri.toString() }, | 54 | textDocument: { uri: editor.document.uri.toString() }, |
59 | position, | 55 | position, |
60 | }; | 56 | }); |
61 | const expanded = await client.sendRequest<ExpandedMacro>( | ||
62 | 'rust-analyzer/expandMacro', | ||
63 | request, | ||
64 | ); | ||
65 | 57 | ||
66 | if (expanded == null) return 'Not available'; | 58 | if (expanded == null) return 'Not available'; |
67 | 59 | ||