Change return type of expand_macro

This commit is contained in:
Edwin Cheng 2019-11-19 22:56:48 +08:00
parent 94c63d2802
commit 4012da07fd
5 changed files with 33 additions and 13 deletions

View file

@ -2,13 +2,16 @@ import * as vscode from 'vscode';
import { Position, TextDocumentIdentifier } from 'vscode-languageclient';
import { Server } from '../server';
type ExpandMacroResult = [string, string];
interface ExpandedMacro {
name: string,
expansion: string,
}
function code_format([name, text]: [string, string]): vscode.MarkdownString {
function code_format(expanded: ExpandedMacro): vscode.MarkdownString {
const markdown = new vscode.MarkdownString(
`#### Recursive expansion of ${name}! macro`
`#### Recursive expansion of ${expanded.name}! macro`
);
markdown.appendCodeblock(text, 'rust');
markdown.appendCodeblock(expanded.expansion, 'rust');
return markdown;
}
@ -23,7 +26,7 @@ export class ExpandMacroHoverProvider implements vscode.HoverProvider {
textDocument: { uri: document.uri.toString() },
position
};
const result = await Server.client.sendRequest<ExpandMacroResult>(
const result = await Server.client.sendRequest<ExpandedMacro>(
'rust-analyzer/expandMacro',
request
);