aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/client.ts1
-rw-r--r--editors/code/src/commands/runnables.ts22
-rw-r--r--editors/code/src/commands/ssr.ts16
-rw-r--r--editors/code/src/main.ts1
-rw-r--r--editors/code/src/rust-analyzer-api.ts6
5 files changed, 35 insertions, 11 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index b2c830b30..d65454275 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -46,6 +46,7 @@ export async function createClient(config: Config, serverPath: string): Promise<
46 withSysroot: config.withSysroot, 46 withSysroot: config.withSysroot,
47 cargoFeatures: config.cargoFeatures, 47 cargoFeatures: config.cargoFeatures,
48 rustfmtArgs: config.rustfmtArgs, 48 rustfmtArgs: config.rustfmtArgs,
49 vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null,
49 }, 50 },
50 traceOutputChannel, 51 traceOutputChannel,
51 middleware: { 52 middleware: {
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 06b513466..357155163 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -62,6 +62,26 @@ export function runSingle(ctx: Ctx): Cmd {
62 }; 62 };
63} 63}
64 64
65export function debugSingle(ctx: Ctx): Cmd {
66 return async (config: ra.Runnable) => {
67 const editor = ctx.activeRustEditor;
68 if (!editor) return;
69
70 const debugConfig = {
71 type: "lldb",
72 request: "launch",
73 name: config.label,
74 cargo: {
75 args: config.args,
76 },
77 args: config.extraArgs,
78 cwd: config.cwd
79 };
80
81 return vscode.debug.startDebugging(undefined, debugConfig);
82 };
83}
84
65class RunnableQuickPick implements vscode.QuickPickItem { 85class RunnableQuickPick implements vscode.QuickPickItem {
66 public label: string; 86 public label: string;
67 public description?: string | undefined; 87 public description?: string | undefined;
@@ -87,7 +107,7 @@ function createTask(spec: ra.Runnable): vscode.Task {
87 type: 'cargo', 107 type: 'cargo',
88 label: spec.label, 108 label: spec.label,
89 command: spec.bin, 109 command: spec.bin,
90 args: spec.args, 110 args: spec.extraArgs ? [...spec.args, '--', ...spec.extraArgs] : spec.args,
91 env: spec.env, 111 env: spec.env,
92 }; 112 };
93 113
diff --git a/editors/code/src/commands/ssr.ts b/editors/code/src/commands/ssr.ts
index eee48c693..6fee051fd 100644
--- a/editors/code/src/commands/ssr.ts
+++ b/editors/code/src/commands/ssr.ts
@@ -10,20 +10,22 @@ export function ssr(ctx: Ctx): Cmd {
10 if (!client) return; 10 if (!client) return;
11 11
12 const options: vscode.InputBoxOptions = { 12 const options: vscode.InputBoxOptions = {
13 placeHolder: "foo($a:expr, $b:expr) ==>> bar($a, foo($b))", 13 value: "() ==>> ()",
14 prompt: "Enter request", 14 prompt: "EnteR request, for example 'Foo($a:expr) ==> Foo::new($a)' ",
15 validateInput: (x: string) => { 15 validateInput: async (x: string) => {
16 if (x.includes('==>>')) { 16 try {
17 return null; 17 await client.sendRequest(ra.ssr, { query: x, parseOnly: true });
18 } catch (e) {
19 return e.toString();
18 } 20 }
19 return "Enter request: pattern ==>> template"; 21 return null;
20 } 22 }
21 }; 23 };
22 const request = await vscode.window.showInputBox(options); 24 const request = await vscode.window.showInputBox(options);
23 25
24 if (!request) return; 26 if (!request) return;
25 27
26 const change = await client.sendRequest(ra.ssr, { arg: request }); 28 const change = await client.sendRequest(ra.ssr, { query: request, parseOnly: false });
27 29
28 await applySourceChange(ctx, change); 30 await applySourceChange(ctx, change);
29 }; 31 };
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 8a7c81727..bd4661a36 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -90,6 +90,7 @@ export async function activate(context: vscode.ExtensionContext) {
90 90
91 // Internal commands which are invoked by the server. 91 // Internal commands which are invoked by the server.
92 ctx.registerCommand('runSingle', commands.runSingle); 92 ctx.registerCommand('runSingle', commands.runSingle);
93 ctx.registerCommand('debugSingle', commands.debugSingle);
93 ctx.registerCommand('showReferences', commands.showReferences); 94 ctx.registerCommand('showReferences', commands.showReferences);
94 ctx.registerCommand('applySourceChange', commands.applySourceChange); 95 ctx.registerCommand('applySourceChange', commands.applySourceChange);
95 ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); 96 ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange);
diff --git a/editors/code/src/rust-analyzer-api.ts b/editors/code/src/rust-analyzer-api.ts
index bd6e3ada0..9846f7343 100644
--- a/editors/code/src/rust-analyzer-api.ts
+++ b/editors/code/src/rust-analyzer-api.ts
@@ -80,13 +80,12 @@ export interface Runnable {
80 label: string; 80 label: string;
81 bin: string; 81 bin: string;
82 args: Vec<string>; 82 args: Vec<string>;
83 extraArgs: Vec<string>;
83 env: FxHashMap<string, string>; 84 env: FxHashMap<string, string>;
84 cwd: Option<string>; 85 cwd: Option<string>;
85} 86}
86export const runnables = request<RunnablesParams, Vec<Runnable>>("runnables"); 87export const runnables = request<RunnablesParams, Vec<Runnable>>("runnables");
87 88
88
89
90export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint; 89export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint;
91 90
92export namespace InlayHint { 91export namespace InlayHint {
@@ -108,7 +107,8 @@ export const inlayHints = request<InlayHintsParams, Vec<InlayHint>>("inlayHints"
108 107
109 108
110export interface SsrParams { 109export interface SsrParams {
111 arg: string; 110 query: string;
111 parseOnly: boolean;
112} 112}
113export const ssr = request<SsrParams, SourceChange>("ssr"); 113export const ssr = request<SsrParams, SourceChange>("ssr");
114 114