aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/commands.ts14
-rw-r--r--editors/code/src/lsp_ext.ts2
2 files changed, 13 insertions, 3 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 1f3a7cf7e..3ae995705 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -185,15 +185,21 @@ export function parentModule(ctx: Ctx): Cmd {
185 185
186export function ssr(ctx: Ctx): Cmd { 186export function ssr(ctx: Ctx): Cmd {
187 return async () => { 187 return async () => {
188 const editor = vscode.window.activeTextEditor;
188 const client = ctx.client; 189 const client = ctx.client;
189 if (!client) return; 190 if (!editor || !client) return;
191
192 const position = editor.selection.active;
193 let textDocument = { uri: editor.document.uri.toString() };
190 194
191 const options: vscode.InputBoxOptions = { 195 const options: vscode.InputBoxOptions = {
192 value: "() ==>> ()", 196 value: "() ==>> ()",
193 prompt: "Enter request, for example 'Foo($a) ==> Foo::new($a)' ", 197 prompt: "Enter request, for example 'Foo($a) ==> Foo::new($a)' ",
194 validateInput: async (x: string) => { 198 validateInput: async (x: string) => {
195 try { 199 try {
196 await client.sendRequest(ra.ssr, { query: x, parseOnly: true }); 200 await client.sendRequest(ra.ssr, {
201 query: x, parseOnly: true, textDocument, position,
202 });
197 } catch (e) { 203 } catch (e) {
198 return e.toString(); 204 return e.toString();
199 } 205 }
@@ -208,7 +214,9 @@ export function ssr(ctx: Ctx): Cmd {
208 title: "Structured search replace in progress...", 214 title: "Structured search replace in progress...",
209 cancellable: false, 215 cancellable: false,
210 }, async (_progress, _token) => { 216 }, async (_progress, _token) => {
211 const edit = await client.sendRequest(ra.ssr, { query: request, parseOnly: false }); 217 const edit = await client.sendRequest(ra.ssr, {
218 query: request, parseOnly: false, textDocument, position
219 });
212 220
213 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); 221 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit));
214 }); 222 });
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index 5f32cb40e..149f9a0d6 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -93,6 +93,8 @@ export const inlayHints = new lc.RequestType<InlayHintsParams, InlayHint[], void
93export interface SsrParams { 93export interface SsrParams {
94 query: string; 94 query: string;
95 parseOnly: boolean; 95 parseOnly: boolean;
96 textDocument: lc.TextDocumentIdentifier;
97 position: lc.Position;
96} 98}
97export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr'); 99export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr');
98 100