3540: Swtches to rust SSR query check r=matklad a=mikhail-m1

related to #3186 

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
This commit is contained in:
bors[bot] 2020-03-16 09:48:09 +00:00 committed by GitHub
commit a99cac671c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 20 deletions

View file

@ -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);
};