Skip to content

Commit 5b1f3c7

Browse files
authored
Add command to enable source maps (microsoft#3478)
For microsoft#3477
1 parent e115b0b commit 5b1f3c7

14 files changed

Lines changed: 267 additions & 128 deletions

File tree

.travis.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,14 @@ script:
9696
- if [[ $AZURE_STORAGE_ACCOUNT && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then
9797
npm run clean;
9898
vsce package;
99-
azure storage blob upload python*.vsix $AZURE_STORAGE_CONTAINER ms-python-insiders.vsix --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --quiet;
99+
azure storage blob upload python*.vsix $AZURE_STORAGE_CONTAINER ms-python-insiders-unbundled.vsix --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --quiet;
100100
fi
101-
- if [[ $BUNDLE == "true" ]]; then
101+
- if [[ $BUNDLE == "true" && $AZURE_STORAGE_ACCOUNT && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then
102102
npm run clean;
103103
npm run package;
104104
npx gulp clean:cleanExceptTests;
105105
npm run testSmoke;
106-
fi
107-
- if [[ $BUNDLE == "true" && $AZURE_STORAGE_ACCOUNT && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then
108-
azure storage blob upload python*.vsix $AZURE_STORAGE_CONTAINER ms-python-insiders-bundled.vsix --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --quiet;
106+
azure storage blob upload python*.vsix $AZURE_STORAGE_CONTAINER ms-python-insiders.vsix --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --quiet;
109107
fi
110108
- if [[ $AZURE_STORAGE_ACCOUNT && "$TRAVIS_BRANCH" == release* && "$TRAVIS_PULL_REQUEST" == "false" ]]; then
111109
npm run clean;

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"onCommand:python.createTerminal",
8888
"onCommand:python.discoverTests",
8989
"onCommand:python.datascience.showhistorypane",
90-
"onCommand:python.datascience.importnotebook"
90+
"onCommand:python.datascience.importnotebook",
91+
"onCommand:python.python.enableSourceMapSupport"
9192
],
9293
"main": "./out/client/extension",
9394
"contributes": {
@@ -110,6 +111,11 @@
110111
}
111112
],
112113
"commands": [
114+
{
115+
"command": "python.enableSourceMapSupport",
116+
"title": "%python.command.python.enableSourceMapSupport.title%",
117+
"category": "Python"
118+
},
113119
{
114120
"command": "python.sortImports",
115121
"title": "%python.command.python.sortImports.title%",

package.nls.json

Lines changed: 116 additions & 113 deletions
Large diffs are not rendered by default.

src/client/application/diagnostics/applicationDiagnostics.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ import { STANDARD_OUTPUT_CHANNEL } from '../../common/constants';
99
import { ILogger, IOutputChannel } from '../../common/types';
1010
import { IServiceContainer } from '../../ioc/types';
1111
import { IApplicationDiagnostics } from '../types';
12-
import { IDiagnostic, IDiagnosticsService } from './types';
12+
import { IDiagnostic, IDiagnosticsService, ISourceMapSupportService } from './types';
1313

1414
@injectable()
1515
export class ApplicationDiagnostics implements IApplicationDiagnostics {
1616
constructor(@inject(IServiceContainer) private readonly serviceContainer: IServiceContainer) { }
17+
public register() {
18+
this.serviceContainer.get<ISourceMapSupportService>(ISourceMapSupportService).register();
19+
}
1720
public async performPreStartupHealthCheck(): Promise<void> {
1821
const diagnosticsServices = this.serviceContainer.getAll<IDiagnosticsService>(IDiagnosticsService);
1922
await Promise.all(diagnosticsServices.map(async diagnosticsService => {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
'use strict';
5+
6+
import { inject, injectable } from 'inversify';
7+
import { ConfigurationTarget } from 'vscode';
8+
import { IApplicationShell, ICommandManager } from '../../common/application/types';
9+
import { Commands } from '../../common/constants';
10+
import { IConfigurationService, IDisposableRegistry } from '../../common/types';
11+
import { Diagnostics } from '../../common/utils/localize';
12+
import { ISourceMapSupportService } from './types';
13+
14+
@injectable()
15+
export class SourceMapSupportService implements ISourceMapSupportService {
16+
constructor(@inject(ICommandManager) private readonly commandManager: ICommandManager,
17+
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
18+
@inject(IConfigurationService) private readonly configurationService: IConfigurationService,
19+
@inject(IApplicationShell) private readonly shell: IApplicationShell) {
20+
21+
}
22+
public register(): void {
23+
this.disposables.push(this.commandManager.registerCommand(Commands.Enable_SourceMap_Support, this.onEnable, this));
24+
}
25+
public async enable(): Promise<void> {
26+
await this.configurationService.updateSetting('diagnostics.sourceMapsEnabled', true, undefined, ConfigurationTarget.Global);
27+
await this.commandManager.executeCommand('workbench.action.reloadWindow');
28+
}
29+
protected async onEnable(): Promise<void> {
30+
const enableSourceMapsAndReloadVSC = Diagnostics.enableSourceMapsAndReloadVSC();
31+
const selection = await this.shell.showWarningMessage(Diagnostics.warnBeforeEnablingSourceMaps(), enableSourceMapsAndReloadVSC);
32+
if (selection === enableSourceMapsAndReloadVSC) {
33+
await this.enable();
34+
}
35+
}
36+
}

src/client/application/diagnostics/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,8 @@ export const IInvalidPythonPathInDebuggerService = Symbol('IInvalidPythonPathInD
5252
export interface IInvalidPythonPathInDebuggerService extends IDiagnosticsService {
5353
validatePythonPath(pythonPath?: string, resource?: Uri): Promise<boolean>;
5454
}
55+
export const ISourceMapSupportService = Symbol('ISourceMapSupportService');
56+
export interface ISourceMapSupportService {
57+
register(): void;
58+
enable(): Promise<void>;
59+
}

src/client/application/serviceRegistry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
import { IServiceManager } from '../ioc/types';
77
import { ApplicationDiagnostics } from './diagnostics/applicationDiagnostics';
88
import { registerTypes as diagnosticsRegisterTypes } from './diagnostics/serviceRegistry';
9+
import { SourceMapSupportService } from './diagnostics/surceMapSupportService';
10+
import { ISourceMapSupportService } from './diagnostics/types';
911
import { IApplicationDiagnostics } from './types';
1012

1113
export function registerTypes(serviceManager: IServiceManager) {
1214
serviceManager.addSingleton<IApplicationDiagnostics>(IApplicationDiagnostics, ApplicationDiagnostics);
15+
serviceManager.addSingleton<ISourceMapSupportService>(ISourceMapSupportService, SourceMapSupportService);
1316
diagnosticsRegisterTypes(serviceManager);
1417
}

src/client/application/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export interface IApplicationDiagnostics {
1313
* @memberof IApplicationDiagnostics
1414
*/
1515
performPreStartupHealthCheck(): Promise<void>;
16+
register(): void;
1617
}

src/client/common/configuration/service.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ export class ConfigurationService implements IConfigurationService {
1313
}
1414

1515
public async updateSectionSetting(section: string, setting: string, value?: {}, resource?: Uri, configTarget?: ConfigurationTarget): Promise<void> {
16-
const settingsInfo = section === 'python' ?
17-
PythonSettings.getSettingsUriAndTarget(resource) :
18-
{
19-
uri: resource,
20-
target: configTarget ? configTarget : ConfigurationTarget.WorkspaceFolder
21-
};
16+
const defaultSetting = {
17+
uri: resource,
18+
target: configTarget || ConfigurationTarget.WorkspaceFolder
19+
};
20+
const settingsInfo = section === 'python' && configTarget !== ConfigurationTarget.Global ? PythonSettings.getSettingsUriAndTarget(resource) : defaultSetting;
2221

2322
const configSection = workspace.getConfiguration(section, settingsInfo.uri);
2423
const currentValue = configSection.inspect(setting);

src/client/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export namespace Commands {
3737
export const Set_Linter = 'python.setLinter';
3838
export const Enable_Linter = 'python.enableLinting';
3939
export const Run_Linter = 'python.runLinting';
40+
export const Enable_SourceMap_Support = 'python.enableSourceMapSupport';
4041
}
4142
export namespace Octicons {
4243
export const Test_Pass = '$(check)';

0 commit comments

Comments
 (0)