aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorHannes De Valkeneer <[email protected]>2020-03-09 21:06:45 +0000
committerHannes De Valkeneer <[email protected]>2020-03-11 21:26:47 +0000
commite903fd0d9726dc6343a26ddeb919099fb8e4979e (patch)
tree23c2de00603542c434cc8e413c7d7cc425869cd2 /editors
parent05b4fc6d79060fc3120f92b01119e3a851c37829 (diff)
feat: add debug code lens
Refs #3539
Diffstat (limited to 'editors')
-rw-r--r--editors/code/package.json3
-rw-r--r--editors/code/src/commands/runnables.ts28
-rw-r--r--editors/code/src/main.ts1
-rw-r--r--editors/code/src/rust-analyzer-api.ts3
4 files changed, 32 insertions, 3 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 1fe8e9f8a..744585721 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -51,6 +51,9 @@
51 "typescript-formatter": "^7.2.2", 51 "typescript-formatter": "^7.2.2",
52 "vsce": "^1.74.0" 52 "vsce": "^1.74.0"
53 }, 53 },
54 "extensionDependencies": [
55 "vadimcn.vscode-lldb"
56 ],
54 "activationEvents": [ 57 "activationEvents": [
55 "onLanguage:rust", 58 "onLanguage:rust",
56 "onCommand:rust-analyzer.analyzerStatus", 59 "onCommand:rust-analyzer.analyzerStatus",
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 06b513466..faa92799c 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -3,6 +3,7 @@ import * as lc from 'vscode-languageclient';
3import * as ra from '../rust-analyzer-api'; 3import * as ra from '../rust-analyzer-api';
4 4
5import { Ctx, Cmd } from '../ctx'; 5import { Ctx, Cmd } from '../ctx';
6import { debug } from 'vscode';
6 7
7export function run(ctx: Ctx): Cmd { 8export function run(ctx: Ctx): Cmd {
8 let prevRunnable: RunnableQuickPick | undefined; 9 let prevRunnable: RunnableQuickPick | undefined;
@@ -62,6 +63,31 @@ export function runSingle(ctx: Ctx): Cmd {
62 }; 63 };
63} 64}
64 65
66export function debugSingle(ctx: Ctx): Cmd {
67 return async (config: ra.Runnable) => {
68 const editor = ctx.activeRustEditor;
69 if (!editor) return;
70
71 if (config.args[0] === 'run') {
72 config.args[0] = 'build';
73 } else {
74 config.args.push('--no-run');
75 }
76
77 const debugConfig = {
78 type: "lldb",
79 request: "launch",
80 name: config.label,
81 cargo: {
82 args: config.args,
83 },
84 args: config.extraArgs,
85 cwd: config.cwd
86 };
87 return debug.startDebugging(undefined, debugConfig);
88 };
89}
90
65class RunnableQuickPick implements vscode.QuickPickItem { 91class RunnableQuickPick implements vscode.QuickPickItem {
66 public label: string; 92 public label: string;
67 public description?: string | undefined; 93 public description?: string | undefined;
@@ -87,7 +113,7 @@ function createTask(spec: ra.Runnable): vscode.Task {
87 type: 'cargo', 113 type: 'cargo',
88 label: spec.label, 114 label: spec.label,
89 command: spec.bin, 115 command: spec.bin,
90 args: spec.args, 116 args: spec.extraArgs ? [...spec.args, '--', ...spec.extraArgs] : spec.args,
91 env: spec.env, 117 env: spec.env,
92 }; 118 };
93 119
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index ecf53cf77..e01c89cc7 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -83,6 +83,7 @@ export async function activate(context: vscode.ExtensionContext) {
83 83
84 // Internal commands which are invoked by the server. 84 // Internal commands which are invoked by the server.
85 ctx.registerCommand('runSingle', commands.runSingle); 85 ctx.registerCommand('runSingle', commands.runSingle);
86 ctx.registerCommand('debugSingle', commands.debugSingle);
86 ctx.registerCommand('showReferences', commands.showReferences); 87 ctx.registerCommand('showReferences', commands.showReferences);
87 ctx.registerCommand('applySourceChange', commands.applySourceChange); 88 ctx.registerCommand('applySourceChange', commands.applySourceChange);
88 ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); 89 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..e09a203c9 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 {