blob: 5d40a64d28e9067548f5e528a89749484c95fbea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import * as vscode from 'vscode';
import * as ra from "../rust-analyzer-api";
import { Ctx, Cmd } from '../ctx';
export function ssr(ctx: Ctx): Cmd {
return async () => {
const client = ctx.client;
if (!client) return;
const options: vscode.InputBoxOptions = {
value: "() ==>> ()",
prompt: "Enter request, for example 'Foo($a:expr) ==> Foo::new($a)' ",
validateInput: async (x: string) => {
try {
await client.sendRequest(ra.ssr, { query: x, parseOnly: true });
} catch (e) {
return e.toString();
}
return null;
}
};
const request = await vscode.window.showInputBox(options);
if (!request) return;
const edit = await client.sendRequest(ra.ssr, { query: request, parseOnly: false });
await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit));
};
}
|