mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Swtches to rust SSR query check
This commit is contained in:
parent
530ff9f57f
commit
b150965ed7
7 changed files with 63 additions and 20 deletions
|
@ -10,20 +10,22 @@ export function ssr(ctx: Ctx): Cmd {
|
|||
if (!client) return;
|
||||
|
||||
const options: vscode.InputBoxOptions = {
|
||||
placeHolder: "foo($a:expr, $b:expr) ==>> bar($a, foo($b))",
|
||||
prompt: "Enter request",
|
||||
validateInput: (x: string) => {
|
||||
if (x.includes('==>>')) {
|
||||
return null;
|
||||
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 "Enter request: pattern ==>> template";
|
||||
return null;
|
||||
}
|
||||
};
|
||||
const request = await vscode.window.showInputBox(options);
|
||||
|
||||
if (!request) return;
|
||||
|
||||
const change = await client.sendRequest(ra.ssr, { arg: request });
|
||||
const change = await client.sendRequest(ra.ssr, { query: request, parseOnly: false });
|
||||
|
||||
await applySourceChange(ctx, change);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue