diff options
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/runnables.ts | 22 | ||||
-rw-r--r-- | editors/code/src/commands/server_version.ts | 3 | ||||
-rw-r--r-- | editors/code/src/commands/ssr.ts | 16 |
3 files changed, 31 insertions, 10 deletions
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 | ||
65 | export 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 | |||
65 | class RunnableQuickPick implements vscode.QuickPickItem { | 85 | class 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/server_version.ts b/editors/code/src/commands/server_version.ts index 421301b42..c4d84b443 100644 --- a/editors/code/src/commands/server_version.ts +++ b/editors/code/src/commands/server_version.ts | |||
@@ -5,7 +5,7 @@ import { spawnSync } from 'child_process'; | |||
5 | 5 | ||
6 | export function serverVersion(ctx: Ctx): Cmd { | 6 | export function serverVersion(ctx: Ctx): Cmd { |
7 | return async () => { | 7 | return async () => { |
8 | const binaryPath = await ensureServerBinary(ctx.config.serverSource); | 8 | const binaryPath = await ensureServerBinary(ctx.config); |
9 | 9 | ||
10 | if (binaryPath == null) { | 10 | if (binaryPath == null) { |
11 | throw new Error( | 11 | throw new Error( |
@@ -18,4 +18,3 @@ export function serverVersion(ctx: Ctx): Cmd { | |||
18 | vscode.window.showInformationMessage('rust-analyzer version : ' + version); | 18 | vscode.window.showInformationMessage('rust-analyzer version : ' + version); |
19 | }; | 19 | }; |
20 | } | 20 | } |
21 | |||
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 | }; |