本文整理匯總了TypeScript中vscode.debug.startDebugging方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript debug.startDebugging方法的具體用法?TypeScript debug.startDebugging怎麽用?TypeScript debug.startDebugging使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode.debug
的用法示例。
在下文中一共展示了debug.startDebugging方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: catch
vscode.window.showQuickPick(items, {placeHolder: (items.length === 0 ? "No compiler found" : "Select a compiler" )}).then(async selection => {
if (!selection) {
return; // User canceled it.
}
if (selection.label.startsWith("cl.exe")) {
if (!process.env.DevEnvDir || process.env.DevEnvDir.length === 0) {
vscode.window.showErrorMessage('cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS.');
return;
}
}
if (selection.configuration.preLaunchTask) {
if (folder) {
try {
await util.ensureBuildTaskExists(selection.configuration.preLaunchTask);
Telemetry.logDebuggerEvent("buildAndDebug", { "success": "false" });
} catch (e) {
if (e && e.message === util.failedToParseTasksJson) {
vscode.window.showErrorMessage(util.failedToParseTasksJson);
}
return Promise.resolve();
}
} else {
return Promise.resolve();
// TODO uncomment this when single file mode works correctly.
// const buildTasks: vscode.Task[] = await getBuildTasks(true);
// const task: vscode.Task = buildTasks.find(task => task.name === selection.configuration.preLaunchTask);
// await vscode.tasks.executeTask(task);
// delete selection.configuration.preLaunchTask;
}
}
// Attempt to use the user's (possibly) modified configuration before using the generated one.
try {
await vscode.debug.startDebugging(folder, selection.configuration.name);
Telemetry.logDebuggerEvent("buildAndDebug", { "success": "true" });
} catch (e) {
try {
vscode.debug.startDebugging(folder, selection.configuration);
} catch (e) {
Telemetry.logDebuggerEvent("buildAndDebug", { "success": "false" });
}
}
});
示例2: test
test("Starting .NET Core Launch (console) from the workspace root should create an Active Debug Session", async () => {
await vscode.debug.startDebugging(vscode.workspace.workspaceFolders[0], ".NET Core Launch (console)");
let debugSessionTerminated = new Promise(resolve => {
vscode.debug.onDidTerminateDebugSession((e) => resolve());
});
vscode.debug.activeDebugSession.type.should.equal("coreclr");
await debugSessionTerminated;
});
示例3: test
test("Starting .NET Core Launch (console) from the workspace root should create an Active Debug Session", async () => {
let result = await vscode.debug.startDebugging(vscode.workspace.workspaceFolders[0], ".NET Core Launch (console)");
expect(result, "Debugger could not be started.");
let debugSessionTerminated = new Promise(resolve => {
vscode.debug.onDidTerminateDebugSession((e) => resolve());
});
expect(vscode.debug.activeDebugSession).not.to.be.undefined;
expect(vscode.debug.activeDebugSession.type).to.equal("coreclr");
await debugSessionTerminated;
});
示例4: test
test("Starting (gdb) Launch from the workspace root should create an Active Debug Session", async () => {
// If it is failing on startDebugging. Investigate the SimpleCppProject's tasks.json or launch.json.
await vscode.debug.startDebugging(vscode.workspace.workspaceFolders[0], "(gdb) Launch");
let debugSessionTerminated: Promise<void> = new Promise(resolve => {
vscode.debug.onDidTerminateDebugSession((e) => resolve());
});
try {
assert.equal(vscode.debug.activeDebugSession.type, "cppdbg");
} catch (e) {
assert.fail("Debugger failed to launch. Did the extension activate correctly?");
}
await debugSessionTerminated;
});
示例5: Error
launchDef.promise.then(() => {
if (!Array.isArray(workspace.workspaceFolders) || workspace.workspaceFolders.length === 0) {
throw new Error('Please open a workspace');
}
let workspaceFolder = workspace.getWorkspaceFolder(Uri.file(rootDirectory));
if (!workspaceFolder) {
workspaceFolder = workspace.workspaceFolders[0];
}
return debug.startDebugging(workspaceFolder, {
"name": "Debug Unit Test",
"type": "python",
"request": "attach",
"localRoot": rootDirectory,
"remoteRoot": rootDirectory,
"port": pythonSettings.unitTest.debugPort,
"secret": "my_secret",
"host": "localhost"
});
}).catch(reason => {
示例6: startDebugging
export function startDebugging(scriptName: string, protocol: string, port: number, folder: WorkspaceFolder) {
let p = 'inspector';
if (protocol === 'debug') {
p = 'legacy';
}
let packageManager = getPackageManager(folder);
const config: DebugConfiguration = {
type: 'node',
request: 'launch',
name: `Debug ${scriptName}`,
runtimeExecutable: packageManager,
runtimeArgs: [
'run',
scriptName,
],
port: port,
protocol: p
};
if (folder) {
debug.startDebugging(folder, config);
}
}