aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/commands.ts15
-rw-r--r--editors/code/src/lsp_ext.ts3
2 files changed, 15 insertions, 3 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 1f3a7cf7e..d0faf4745 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -185,15 +185,22 @@ 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 const selections = editor.selections;
194 const textDocument = { uri: editor.document.uri.toString() };
190 195
191 const options: vscode.InputBoxOptions = { 196 const options: vscode.InputBoxOptions = {
192 value: "() ==>> ()", 197 value: "() ==>> ()",
193 prompt: "Enter request, for example 'Foo($a) ==> Foo::new($a)' ", 198 prompt: "Enter request, for example 'Foo($a) ==> Foo::new($a)' ",
194 validateInput: async (x: string) => { 199 validateInput: async (x: string) => {
195 try { 200 try {
196 await client.sendRequest(ra.ssr, { query: x, parseOnly: true }); 201 await client.sendRequest(ra.ssr, {
202 query: x, parseOnly: true, textDocument, position, selections,
203 });
197 } catch (e) { 204 } catch (e) {
198 return e.toString(); 205 return e.toString();
199 } 206 }
@@ -208,7 +215,9 @@ export function ssr(ctx: Ctx): Cmd {
208 title: "Structured search replace in progress...", 215 title: "Structured search replace in progress...",
209 cancellable: false, 216 cancellable: false,
210 }, async (_progress, _token) => { 217 }, async (_progress, _token) => {
211 const edit = await client.sendRequest(ra.ssr, { query: request, parseOnly: false }); 218 const edit = await client.sendRequest(ra.ssr, {
219 query: request, parseOnly: false, textDocument, position, selections,
220 });
212 221
213 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); 222 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit));
214 }); 223 });
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index 5f32cb40e..494d51c83 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -93,6 +93,9 @@ 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;
98 selections: lc.Range[];
96} 99}
97export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr'); 100export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr');
98 101