aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/package.json15
-rw-r--r--editors/code/src/commands.ts14
-rw-r--r--editors/code/src/lsp_ext.ts2
3 files changed, 23 insertions, 8 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 448e2269f..658c913fd 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -200,11 +200,6 @@
200 "type": "object", 200 "type": "object",
201 "title": "Rust Analyzer", 201 "title": "Rust Analyzer",
202 "properties": { 202 "properties": {
203 "rust-analyzer.diagnostics.enable": {
204 "type": "boolean",
205 "default": true,
206 "markdownDescription": "Whether to show native rust-analyzer diagnostics."
207 },
208 "rust-analyzer.lruCapacity": { 203 "rust-analyzer.lruCapacity": {
209 "type": [ 204 "type": [
210 "null", 205 "null",
@@ -579,6 +574,16 @@
579 "type": "boolean", 574 "type": "boolean",
580 "default": true 575 "default": true
581 }, 576 },
577 "rust-analyzer.diagnostics.enable": {
578 "type": "boolean",
579 "default": true,
580 "markdownDescription": "Whether to show native rust-analyzer diagnostics."
581 },
582 "rust-analyzer.diagnostics.enableExperimental": {
583 "type": "boolean",
584 "default": true,
585 "markdownDescription": "Whether to show experimental rust-analyzer diagnostics that might have more false positives than usual."
586 },
582 "rust-analyzer.diagnostics.warningsAsInfo": { 587 "rust-analyzer.diagnostics.warningsAsInfo": {
583 "type": "array", 588 "type": "array",
584 "uniqueItems": true, 589 "uniqueItems": true,
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 1f3a7cf7e..c21e5597c 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 const 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