aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/runnables.ts
diff options
context:
space:
mode:
authorvsrs <[email protected]>2020-04-28 15:30:49 +0100
committervsrs <[email protected]>2020-04-28 15:30:49 +0100
commit48d6e828f1878436bb8633a1e7df02a6383d991a (patch)
tree24b1795e969c9fee0899f14a7e74bdce6764594e /editors/code/src/commands/runnables.ts
parent7a9ba1657daa9fd90c639dcd937da11b4f526675 (diff)
ms-vscode.cpptools debugger support, initial version.
Diffstat (limited to 'editors/code/src/commands/runnables.ts')
-rw-r--r--editors/code/src/commands/runnables.ts47
1 files changed, 35 insertions, 12 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 2635a1440..26db18156 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 { Cargo } from '../cargo';
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,25 +63,47 @@ export function runSingle(ctx: Ctx): Cmd {
62 }; 63 };
63} 64}
64 65
66function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration {
67 return {
68 type: "lldb",
69 request: "launch",
70 name: config.label,
71 cargo: {
72 args: config.args,
73 },
74 args: config.extraArgs,
75 cwd: config.cwd
76 };
77}
78
79async function getCppvsDebugConfig(config: ra.Runnable) : Promise<vscode.DebugConfiguration> {
80 let cargo = new Cargo(config.cwd || '.');
81 let executable = await cargo.executableFromArgs(config.args, config.extraArgs);
82
83 return {
84 type: "cppvsdbg",
85 request: "launch",
86 name: config.label,
87 program: executable,
88 args: config.extraArgs,
89 cwd: config.cwd,
90 };
91}
92
65export function debugSingle(ctx: Ctx): Cmd { 93export function debugSingle(ctx: Ctx): Cmd {
66 return async (config: ra.Runnable) => { 94 return async (config: ra.Runnable) => {
67 const editor = ctx.activeRustEditor; 95 const editor = ctx.activeRustEditor;
68 if (!editor) return; 96 if (!editor) return;
69 if (!vscode.extensions.getExtension("vadimcn.vscode-lldb")) { 97
70 vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` extension for debugging"); 98 const mscpp = vscode.extensions.getExtension("ms-vscode.cpptools");
99 const lldb = vscode.extensions.getExtension("vadimcn.vscode-lldb");
100
101 if (!(lldb || mscpp)) {
102 vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` or `ms-vscode.cpptools` extension for debugging");
71 return; 103 return;
72 } 104 }
73 105
74 const debugConfig = { 106 const debugConfig = lldb ? getLldbDebugConfig(config) : await getCppvsDebugConfig(config);
75 type: "lldb",
76 request: "launch",
77 name: config.label,
78 cargo: {
79 args: config.args,
80 },
81 args: config.extraArgs,
82 cwd: config.cwd
83 };
84 107
85 return vscode.debug.startDebugging(undefined, debugConfig); 108 return vscode.debug.startDebugging(undefined, debugConfig);
86 }; 109 };