From 31d9932d18151bffe94e4137ac3b5d10df37641f Mon Sep 17 00:00:00 2001 From: Veetaha Date: Tue, 25 Feb 2020 00:50:36 +0200 Subject: vscode: migrate expand_macro to rust-analyzer-api.ts --- editors/code/src/commands/expand_macro.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'editors') 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 @@ import * as vscode from 'vscode'; -import * as lc from 'vscode-languageclient'; +import * as ra from '../rust-analyzer-api'; import { Ctx, Cmd } from '../ctx'; @@ -26,12 +26,7 @@ export function expandMacro(ctx: Ctx): Cmd { }; } -interface ExpandedMacro { - name: string; - expansion: string; -} - -function codeFormat(expanded: ExpandedMacro): string { +function codeFormat(expanded: ra.ExpandedMacro): string { let result = `// Recursive expansion of ${expanded.name}! macro\n`; result += '// ' + '='.repeat(result.length - 3); result += '\n\n'; @@ -54,14 +49,11 @@ class TextDocumentContentProvider if (!editor || !client) return ''; const position = editor.selection.active; - const request: lc.TextDocumentPositionParams = { + + const expanded = await client.sendRequest(ra.expandMacro, { textDocument: { uri: editor.document.uri.toString() }, position, - }; - const expanded = await client.sendRequest( - 'rust-analyzer/expandMacro', - request, - ); + }); if (expanded == null) return 'Not available'; -- cgit v1.2.3