aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/expand_macro.ts
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-25 09:55:56 +0000
committerGitHub <[email protected]>2020-02-25 09:55:56 +0000
commit5e6f4ca6905e02a5fa34ef292fa2abefcd982222 (patch)
tree413691f3aab076538aac3c49bef015fb945d5320 /editors/code/src/commands/expand_macro.ts
parent558d263a0c602ef12914cbb10c263a9e2bb96bf2 (diff)
parent18b97d9d367d5fc1533c48157ebca7bb18b62e3c (diff)
Merge #3299
3299: vscode: migrate to request type api r=matklad a=Veetaha More type-safety to the god of type-safety. Co-authored-by: Veetaha <[email protected]>
Diffstat (limited to 'editors/code/src/commands/expand_macro.ts')
-rw-r--r--editors/code/src/commands/expand_macro.ts18
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 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as ra from '../rust-analyzer-api';
3 3
4import { Ctx, Cmd } from '../ctx'; 4import { Ctx, Cmd } from '../ctx';
5 5
@@ -26,12 +26,7 @@ export function expandMacro(ctx: Ctx): Cmd {
26 }; 26 };
27} 27}
28 28
29interface ExpandedMacro { 29function codeFormat(expanded: ra.ExpandedMacro): string {
30 name: string;
31 expansion: string;
32}
33
34function 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