diff options
| author | Mikhail Modin <mikhailm1@gmail.com> | 2020-02-10 22:45:38 +0000 |
|---|---|---|
| committer | Mikhail Modin <mikhailm1@gmail.com> | 2020-02-14 21:45:42 +0000 |
| commit | f8f454ab5c19c6e7d91b3a4e6bb63fb9bf5f2673 (patch) | |
| tree | e80fbf31a2f69916c86b5569da4f673e7818d8ec /editors/code/src/commands | |
| parent | 6fb36dfdcb91f67c28f51e51514ebe420ec3aa22 (diff) | |
| download | rust-f8f454ab5c19c6e7d91b3a4e6bb63fb9bf5f2673.tar.gz rust-f8f454ab5c19c6e7d91b3a4e6bb63fb9bf5f2673.zip | |
Init implementation of structural search replace
Diffstat (limited to 'editors/code/src/commands')
| -rw-r--r-- | editors/code/src/commands/index.ts | 1 | ||||
| -rw-r--r-- | editors/code/src/commands/ssr.ts | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index aee96943201..b5ebec117f3 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -12,6 +12,7 @@ export * from './parent_module'; export * from './syntax_tree'; export * from './expand_macro'; export * from './runnables'; +export * from './ssr'; export function collectGarbage(ctx: Ctx): Cmd { return async () => { diff --git a/editors/code/src/commands/ssr.ts b/editors/code/src/commands/ssr.ts new file mode 100644 index 00000000000..6287bf47b42 --- /dev/null +++ b/editors/code/src/commands/ssr.ts @@ -0,0 +1,36 @@ +import { Ctx, Cmd } from '../ctx'; +import { applySourceChange, SourceChange } from '../source_change'; +import * as vscode from 'vscode'; + +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; + } + return "Enter request: pattern ==>> template" + } + } + const request = await vscode.window.showInputBox(options); + + if (!request) return; + + const ssrRequest: SsrRequest = { arg: request }; + const change = await client.sendRequest<SourceChange>( + 'rust-analyzer/ssr', + ssrRequest, + ); + + await applySourceChange(ctx, change); + }; +} + +interface SsrRequest { + arg: string; +} |
