Skip to content

Commit 4f237b4

Browse files
authored
Refactor debug configuration providers (microsoft#3742)
For microsoft#3321 * Created a separate PR to refactor before introducing changes related to 3321 * Easier to review and merge (smaller changes)
1 parent 6682d66 commit 4f237b4

File tree

20 files changed

+1002
-605
lines changed

20 files changed

+1002
-605
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
{
3939
"label": "Run Unit Tests",
4040
"type": "npm",
41-
"script": "test:unittests:cover",
41+
"script": "test:unittests",
4242
"group": {
4343
"kind": "test",
4444
"isDefault": true

build/existingFiles.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@
157157
"src/client/debugger/debugAdapter/serviceRegistry.ts",
158158
"src/client/debugger/debugAdapter/types.ts",
159159
"src/client/debugger/extension/banner.ts",
160-
"src/client/debugger/extension/configProviders/baseProvider.ts",
161-
"src/client/debugger/extension/configProviders/configurationProviderUtils.ts",
162-
"src/client/debugger/extension/configProviders/pythonV2Provider.ts",
163-
"src/client/debugger/extension/configProviders/types.ts",
160+
"src/client/debugger/extension/configuration/baseProvider.ts",
161+
"src/client/debugger/extension/configuration/configurationProviderUtils.ts",
162+
"src/client/debugger/extension/configuration/pythonV2Provider.ts",
163+
"src/client/debugger/extension/configuration/types.ts",
164164
"src/client/debugger/extension/hooks/childProcessAttachHandler.ts",
165165
"src/client/debugger/extension/hooks/childProcessAttachService.ts",
166166
"src/client/debugger/extension/hooks/constants.ts",

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,10 +1860,10 @@
18601860
"compile-webviews-verbose": "npx webpack --config webpack.datascience-ui.config.js",
18611861
"postinstall": "node ./node_modules/vscode/bin/install",
18621862
"test": "node ./out/test/standardTest.js && node ./out/test/multiRootTest.js",
1863-
"test:unittests": "mocha --opts ./build/.mocha.unittests.opts",
1863+
"test:unittests": "mocha --require source-map-support/register --opts ./build/.mocha.unittests.opts",
18641864
"test:unittests:cover": "nyc --nycrc-path ./build/.nycrc npm run test:unittests",
1865-
"test:functional": "mocha --opts ./build/.mocha.functional.opts",
1866-
"test:functional:cover": "nyc--nycrc-path ./build/.nycrc npm run test:functional",
1865+
"test:functional": "mocha --require source-map-support/register --opts ./build/.mocha.functional.opts",
1866+
"test:functional:cover": "nyc --nycrc-path ./build/.nycrc npm run test:functional",
18671867
"testDebugger": "node ./out/test/debuggerTest.js",
18681868
"testSingleWorkspace": "node ./out/test/standardTest.js",
18691869
"testMultiWorkspace": "node ./out/test/multiRootTest.js",

src/client/debugger/extension/configProviders/baseProvider.ts

Lines changed: 0 additions & 133 deletions
This file was deleted.

src/client/debugger/extension/configProviders/pythonV2Provider.ts

Lines changed: 0 additions & 154 deletions
This file was deleted.

src/client/debugger/extension/configProviders/types.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/client/debugger/extension/configProviders/configurationProviderUtils.ts renamed to src/client/debugger/extension/configuration/configurationProviderUtils.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,19 @@ import { inject, injectable } from 'inversify';
77
import * as path from 'path';
88
import { Uri } from 'vscode';
99
import { IApplicationShell } from '../../../common/application/types';
10+
import { traceError } from '../../../common/logger';
1011
import { IFileSystem } from '../../../common/platform/types';
1112
import { IPythonExecutionFactory } from '../../../common/process/types';
12-
import { ILogger } from '../../../common/types';
13-
import { IServiceContainer } from '../../../ioc/types';
13+
import { noop } from '../../../common/utils/misc';
1414
import { IConfigurationProviderUtils } from './types';
1515

1616
const PSERVE_SCRIPT_FILE_NAME = 'pserve.py';
1717

1818
@injectable()
1919
export class ConfigurationProviderUtils implements IConfigurationProviderUtils {
20-
private readonly executionFactory: IPythonExecutionFactory;
21-
private readonly fs: IFileSystem;
22-
private readonly logger: ILogger;
23-
constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer) {
24-
this.executionFactory = this.serviceContainer.get<IPythonExecutionFactory>(IPythonExecutionFactory);
25-
this.fs = this.serviceContainer.get<IFileSystem>(IFileSystem);
26-
this.logger = this.serviceContainer.get<ILogger>(ILogger);
20+
constructor(@inject(IPythonExecutionFactory) private readonly executionFactory: IPythonExecutionFactory,
21+
@inject(IFileSystem) private readonly fs: IFileSystem,
22+
@inject(IApplicationShell) private readonly shell: IApplicationShell) {
2723
}
2824
public async getPyramidStartupScriptFilePath(resource?: Uri): Promise<string | undefined> {
2925
try {
@@ -33,9 +29,8 @@ export class ConfigurationProviderUtils implements IConfigurationProviderUtils {
3329
return await this.fs.fileExists(pserveFilePath) ? pserveFilePath : undefined;
3430
} catch (ex) {
3531
const message = 'Unable to locate \'pserve.py\' required for debugging of Pyramid applications.';
36-
this.logger.logError(message, ex);
37-
const app = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
38-
app.showErrorMessage(message);
32+
traceError(message, ex);
33+
this.shell.showErrorMessage(message).then(noop, noop);
3934
return;
4035
}
4136
}

0 commit comments

Comments
 (0)