forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonProvider.ts
More file actions
40 lines (37 loc) · 2.17 KB
/
Copy pathpythonProvider.ts
File metadata and controls
40 lines (37 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { inject, injectable } from 'inversify';
import { Uri } from 'vscode';
import { IServiceContainer } from '../../ioc/types';
import { AttachRequestArgumentsV1, DebugOptions, LaunchRequestArgumentsV1 } from '../Common/Contracts';
import { BaseConfigurationProvider, PythonAttachDebugConfiguration, PythonLaunchDebugConfiguration } from './baseProvider';
import { IConfigurationProviderUtils } from './types';
@injectable()
export class PythonDebugConfigurationProvider extends BaseConfigurationProvider<LaunchRequestArgumentsV1, AttachRequestArgumentsV1> {
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super('python', serviceContainer);
}
protected async provideLaunchDefaults(workspaceFolder: Uri, debugConfiguration: PythonLaunchDebugConfiguration<LaunchRequestArgumentsV1>): Promise<void> {
await super.provideLaunchDefaults(workspaceFolder, debugConfiguration);
// Always redirect output.
if (debugConfiguration.debugOptions!.indexOf(DebugOptions.RedirectOutput) === -1) {
debugConfiguration.debugOptions!.push(DebugOptions.RedirectOutput);
}
if (debugConfiguration.debugOptions!.indexOf(DebugOptions.Pyramid) >= 0) {
const utils = this.serviceContainer.get<IConfigurationProviderUtils>(IConfigurationProviderUtils);
debugConfiguration.program = (await utils.getPyramidStartupScriptFilePath(workspaceFolder))!;
}
}
protected async provideAttachDefaults(workspaceFolder: Uri | undefined, debugConfiguration: PythonAttachDebugConfiguration<AttachRequestArgumentsV1>): Promise<void> {
await super.provideAttachDefaults(workspaceFolder, debugConfiguration);
const debugOptions = debugConfiguration.debugOptions!;
// Always redirect output.
if (debugOptions.indexOf(DebugOptions.RedirectOutput) === -1) {
debugOptions.push(DebugOptions.RedirectOutput);
}
if (!debugConfiguration.localRoot && workspaceFolder) {
debugConfiguration.localRoot = workspaceFolder.fsPath;
}
}
}