2020-02-10 22:45:38 +00:00
|
|
|
import * as vscode from 'vscode';
|
2020-02-25 00:56:57 +02:00
|
|
|
import * as ra from "../rust-analyzer-api";
|
|
|
|
|
|
|
|
|
|
import { Ctx, Cmd } from '../ctx';
|
|
|
|
|
import { applySourceChange } from '../source_change';
|
2020-02-10 22:45:38 +00:00
|
|
|
|
|
|
|
|
export function ssr(ctx: Ctx): Cmd {
|
|
|
|
|
return async () => {
|
|
|
|
|
const client = ctx.client;
|
|
|
|
|
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;
|
|
|
|
|
}
|
2020-02-17 22:09:44 +02:00
|
|
|
return "Enter request: pattern ==>> template";
|
2020-02-10 22:45:38 +00:00
|
|
|
}
|
2020-02-17 22:09:44 +02:00
|
|
|
};
|
2020-02-10 22:45:38 +00:00
|
|
|
const request = await vscode.window.showInputBox(options);
|
|
|
|
|
|
|
|
|
|
if (!request) return;
|
|
|
|
|
|
2020-02-25 00:56:57 +02:00
|
|
|
const change = await client.sendRequest(ra.ssr, { arg: request },);
|
2020-02-10 22:45:38 +00:00
|
|
|
|
|
|
|
|
await applySourceChange(ctx, change);
|
|
|
|
|
};
|
|
|
|
|
}
|