Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
ecc1ca9
Fix Microsoft/vscode#37627 (#1368)
octref Nov 3, 2017
7c5778c
Version 0.7.0 of extension (#1381)
DonJayamanne Nov 9, 2017
9d1bf82
Update README.md
DonJayamanne Nov 9, 2017
ffba179
Update README.md
DonJayamanne Nov 9, 2017
905c713
sync fork with upstream
DonJayamanne Nov 10, 2017
acc2109
fix readme
DonJayamanne Nov 10, 2017
d470523
Merge branch 'master' of https://github.com/Microsoft/vscode-python
DonJayamanne Nov 16, 2017
d392e8b
merged upstream
DonJayamanne Nov 16, 2017
92f775f
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 20, 2017
32a6e53
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 21, 2017
4b30f2c
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
e396752
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
eff4792
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
4553c28
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
3c6520a
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
966e516
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
63d2d65
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
f6d469e
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
029e055
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 30, 2017
e8c71c0
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 30, 2017
51cf9d2
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 1, 2017
7aadc43
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 1, 2017
f0f5c59
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 4, 2017
b2b9da9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 4, 2017
30a4091
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 5, 2017
b16d2f9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 6, 2017
c8db345
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 7, 2017
0df7f16
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 8, 2017
3ccc881
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 9, 2017
bb0709e
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 11, 2017
2c19004
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 11, 2017
8f224ab
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 11, 2017
41b7080
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 12, 2017
dab38dc
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 12, 2017
ae22dd4
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 12, 2017
d2340d2
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 14, 2017
52bb7ae
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 15, 2017
b6b2531
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 19, 2017
8d8d2fc
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 19, 2017
c425a55
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 3, 2018
3963217
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 3, 2018
a696f2a
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 3, 2018
a31e659
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 4, 2018
2663cd5
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 4, 2018
7c85e0b
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 5, 2018
beb82c2
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 9, 2018
01e722a
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 10, 2018
d84da8e
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 17, 2018
78da3e1
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 19, 2018
685b683
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 23, 2018
43364fd
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 23, 2018
8701636
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 24, 2018
5c8addf
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 25, 2018
588c2f9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 30, 2018
66b1382
Merge branch 'master' of https://github.com/DonJayamanne/pythonVSCode
DonJayamanne Jan 30, 2018
e6b4b48
Merge remote-tracking branch 'upstream/master'
DonJayamanne Jan 31, 2018
6aa9a2d
Merge remote-tracking branch 'upstream/master'
DonJayamanne Feb 4, 2018
57f3982
Merge remote-tracking branch 'upstream/master'
DonJayamanne Feb 6, 2018
15aab64
Merge branch 'master' of https://github.com/DonJayamanne/pythonVSCode
DonJayamanne Feb 6, 2018
0e7888f
Merge remote-tracking branch 'upstream/master'
DonJayamanne Feb 8, 2018
8bc4982
Merge remote-tracking branch 'upstream/master'
DonJayamanne Feb 9, 2018
c05d035
Merge remote-tracking branch 'upstream/master'
DonJayamanne Feb 9, 2018
08476d1
Merge branch 'master' of https://github.com/DonJayamanne/pythonVSCode
DonJayamanne Feb 9, 2018
aeade06
Merge remote-tracking branch 'upstream/master'
DonJayamanne Feb 9, 2018
6850da2
Merge branch 'master' of https://github.com/DonJayamanne/pythonVSCode
DonJayamanne Feb 9, 2018
04add73
Merge remote-tracking branch 'upstream/master'
DonJayamanne Feb 11, 2018
4240c34
Merge remote-tracking branch 'upstream/master'
DonJayamanne Feb 12, 2018
713033e
:bug: resolve pythonPath in debug config fixes #691
DonJayamanne Feb 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions src/client/common/variables/systemVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,6 @@ import * as Types from './sysTypes';
import { IStringDictionary, ISystemVariables } from './types';
/* tslint:disable:rule1 no-any no-unnecessary-callback-wrapper jsdoc-format no-for-in prefer-const no-increment-decrement */

export abstract class Parser {

protected static merge<T>(destination: T, source: T, overwrite: boolean): void {
Object.keys(source).forEach((key) => {
const destValue = (destination as any as { [key: string]: string })[key];
const sourceValue = (source as any as { [key: string]: string })[key];
if (Types.isUndefined(sourceValue)) {
return;
}
if (Types.isUndefined(destValue)) {
(destination as any as { [key: string]: string })[key] = sourceValue;
} else {
if (overwrite) {
if (Types.isObject(destValue) && Types.isObject(sourceValue)) {
this.merge(destValue, sourceValue, overwrite);
} else {
(destination as any as { [key: string]: string })[key] = sourceValue;
}
}
}
});
}

// tslint:disable-next-line:no-empty
protected log(message: string): void { }

// tslint:disable-next-line:no-any
protected is(value: any, func: (value: any) => boolean, wrongTypeState?: any, wrongTypeMessage?: string, undefinedState?: any, undefinedMessage?: string): boolean {
if (Types.isUndefined(value)) {
return false;
}
if (!func(value)) {
return false;
}
return true;
}
}

export abstract class AbstractSystemVariables implements ISystemVariables {

public resolve(value: string): string;
Expand Down
4 changes: 3 additions & 1 deletion src/client/debugger/Common/Contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export interface ExceptionHandling {
unhandled: string[];
}

export type DebuggerType = 'python' | 'pythonExperimental';

export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
type?: 'python' | 'pythonExperimental';
type?: DebuggerType;
/** An absolute path to the program to debug. */
module?: string;
program: string;
Expand Down
85 changes: 85 additions & 0 deletions src/client/debugger/configProviders/baseProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

import { injectable, unmanaged } from 'inversify';
import * as path from 'path';
import { CancellationToken, DebugConfiguration, DebugConfigurationProvider, ProviderResult, Uri, WorkspaceFolder } from 'vscode';
import { IDocumentManager, IWorkspaceService } from '../../common/application/types';
import { PythonLanguage } from '../../common/constants';
import { IConfigurationService } from '../../common/types';
import { IServiceContainer } from '../../ioc/types';
import { DebuggerType, LaunchRequestArguments } from '../Common/Contracts';

// tslint:disable:no-invalid-template-strings

export type PythonDebugConfiguration = DebugConfiguration & LaunchRequestArguments;

@injectable()
export abstract class BaseConfigurationProvider implements DebugConfigurationProvider {
constructor(@unmanaged() public debugType: DebuggerType, private serviceContainer: IServiceContainer) { }
public resolveDebugConfiguration(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration> {
const config = debugConfiguration as PythonDebugConfiguration;
const numberOfSettings = Object.keys(config);
const provideDefaultConfigSettings = (config.noDebug === true && numberOfSettings.length === 1) || numberOfSettings.length === 0;
const workspaceFolder = this.getWorkspaceFolder(folder, config);
if (!provideDefaultConfigSettings) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for workspaceFolder to be undefined?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

this.resolveAndUpdatePythonPath(workspaceFolder, config);
return config;
}

const configService = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
const pythonPath = configService.getSettings(workspaceFolder).pythonPath;
const defaultProgram = this.getProgram(config);
const envFile = workspaceFolder ? path.join(workspaceFolder.fsPath, '.env') : '';

config.name = 'Launch';
config.type = this.debugType;
config.request = 'launch';
config.pythonPath = pythonPath;
config.program = defaultProgram ? defaultProgram : '';
config.cwd = workspaceFolder ? workspaceFolder.fsPath : undefined;
config.envFile = envFile;
config.env = {};
config.debugOptions = [];

this.provideDefaults(config);
return config;
}
protected abstract provideDefaults(debugConfiguration: PythonDebugConfiguration): void;
private getWorkspaceFolder(folder: WorkspaceFolder | undefined, config: PythonDebugConfiguration): Uri | undefined {
if (folder) {
return folder.uri;
}
const program = this.getProgram(config);
const workspaceService = this.serviceContainer.get<IWorkspaceService>(IWorkspaceService);
if (!Array.isArray(workspaceService.workspaceFolders) || workspaceService.workspaceFolders.length === 0) {
return program ? Uri.file(path.dirname(program)) : undefined;
}
if (workspaceService.workspaceFolders.length === 1) {
return workspaceService.workspaceFolders[0].uri;
}
if (program) {
const workspaceFolder = workspaceService.getWorkspaceFolder(Uri.file(program));
if (workspaceFolder) {
return workspaceFolder.uri;
}
}

@MikhailArkhipov Mikhail Arkhipov (MikhailArkhipov) Feb 13, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with multiple workspaceFolders return value is undefined.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this would happen if the file being debugged doesn't belong to any of the current workspaces.

}
private getProgram(config: PythonDebugConfiguration): string | undefined {
const documentManager = this.serviceContainer.get<IDocumentManager>(IDocumentManager);
const editor = documentManager.activeTextEditor;
if (editor && editor.document.languageId === PythonLanguage.language) {
return editor.document.fileName;
}
}
private resolveAndUpdatePythonPath(workspaceFolder: Uri | undefined, debugConfiguration: PythonDebugConfiguration): void {
if (!debugConfiguration || debugConfiguration.pythonPath !== '${config:python.pythonPath}') {
return;
}
const configService = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
const pythonPath = configService.getSettings(workspaceFolder).pythonPath;
debugConfiguration.pythonPath = pythonPath;
}
}
19 changes: 19 additions & 0 deletions src/client/debugger/configProviders/pyhtonV2Provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

import { inject, injectable } from 'inversify';
import { IServiceContainer } from '../../ioc/types';
import { BaseConfigurationProvider, PythonDebugConfiguration } from './baseProvider';

@injectable()
export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvider {
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super('pythonExperimental', serviceContainer);
}
protected provideDefaults(debugConfiguration: PythonDebugConfiguration): void {
debugConfiguration.stopOnEntry = false;
debugConfiguration.console = 'integratedTerminal';
}
}
21 changes: 21 additions & 0 deletions src/client/debugger/configProviders/pythonProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

import { inject, injectable } from 'inversify';
import { IServiceContainer } from '../../ioc/types';
import { BaseConfigurationProvider, PythonDebugConfiguration } from './baseProvider';

@injectable()
export class PythonDebugConfigurationProvider extends BaseConfigurationProvider {
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super('python', serviceContainer);
}
protected provideDefaults(debugConfiguration: PythonDebugConfiguration): void {
debugConfiguration.stopOnEntry = true;
debugConfiguration.debugOptions = [
'RedirectOutput'
];
}
}
15 changes: 15 additions & 0 deletions src/client/debugger/configProviders/serviceRegistry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

import { DebugConfigurationProvider } from 'vscode';
import { PythonDebugConfigurationProvider, PythonV2DebugConfigurationProvider } from '..';
import { IServiceManager } from '../../ioc/types';
import { IDebugConfigurationProvider } from '../types';

export function registerTypes(serviceManager: IServiceManager) {
serviceManager.addSingleton<DebugConfigurationProvider>(IDebugConfigurationProvider, PythonDebugConfigurationProvider);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<IDebugConfigurationProvider> ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't, this is a native VSCode interface

serviceManager.addSingleton<DebugConfigurationProvider>(IDebugConfigurationProvider, PythonV2DebugConfigurationProvider);
}
67 changes: 0 additions & 67 deletions src/client/debugger/configProviders/simpleProvider.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/client/debugger/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './configProviders/simpleProvider';
export * from './configProviders/pythonProvider';
export * from './configProviders/pyhtonV2Provider';
2 changes: 2 additions & 0 deletions src/client/debugger/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ export const IProtocolMessageWriter = Symbol('IProtocolMessageWriter');
export interface IProtocolMessageWriter {
write(stream: Socket | NodeJS.WriteStream, message: Message): void;
}

export const IDebugConfigurationProvider = Symbol('DebugConfigurationProvider');
14 changes: 7 additions & 7 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ if ((Reflect as any).metadata === undefined) {
require('reflect-metadata');
}
import { Container } from 'inversify';
import * as os from 'os';
import * as vscode from 'vscode';
import { Disposable, Memento, OutputChannel, window } from 'vscode';
import { BannerService } from './banner';
Expand All @@ -23,7 +22,9 @@ import { IProcessService } from './common/process/types';
import { registerTypes as commonRegisterTypes } from './common/serviceRegistry';
import { GLOBAL_MEMENTO, IDisposableRegistry, ILogger, IMemento, IOutputChannel, IPersistentStateFactory, WORKSPACE_MEMENTO } from './common/types';
import { registerTypes as variableRegisterTypes } from './common/variables/serviceRegistry';
import { SimpleConfigurationProvider } from './debugger';
import { BaseConfigurationProvider } from './debugger/configProviders/baseProvider';
import { registerTypes as debugConfigurationRegisterTypes } from './debugger/configProviders/serviceRegistry';
import { IDebugConfigurationProvider } from './debugger/types';
import { registerTypes as formattersRegisterTypes } from './formatters/serviceRegistry';
import { InterpreterSelector } from './interpreter/configuration/interpreterSelector';
import { ICondaService, IInterpreterService, IInterpreterVersionService } from './interpreter/contracts';
Expand Down Expand Up @@ -92,6 +93,7 @@ export async function activate(context: vscode.ExtensionContext) {
platformRegisterTypes(serviceManager);
installerRegisterTypes(serviceManager);
commonRegisterTerminalTypes(serviceManager);
debugConfigurationRegisterTypes(serviceManager);

serviceManager.get<ICodeExecutionManager>(ICodeExecutionManager).registerCommands();

Expand Down Expand Up @@ -193,11 +195,9 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.languages.registerOnTypeFormattingEditProvider(PYTHON, new BlockFormatProviders(), ':'));
context.subscriptions.push(vscode.languages.registerOnTypeFormattingEditProvider(PYTHON, new OnEnterFormatter(), '\n'));

// In case we have CR LF
const triggerCharacters: string[] = os.EOL.split('');
triggerCharacters.shift();

context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('python', new SimpleConfigurationProvider()));
serviceContainer.getAll<BaseConfigurationProvider>(IDebugConfigurationProvider).forEach(debugConfig => {
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider(debugConfig.debugType, debugConfig));
});
activationDeferred.resolve();

// tslint:disable-next-line:no-unused-expression
Expand Down
Loading