Skip to content

Commit 27548b5

Browse files
committed
Replace IPathUtils in launchers
1 parent cf857b0 commit 27548b5

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

src/client/debugger/extension/configuration/providers/djangoLaunch.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { inject, injectable } from 'inversify';
77
import * as path from 'path';
88
import { Uri, WorkspaceFolder } from 'vscode';
99
import { IWorkspaceService } from '../../../../common/application/types';
10-
import { IFileSystem } from '../../../../common/platform/types';
11-
import { IPathUtils } from '../../../../common/types';
10+
import { IFileSystem, IFileSystemPathUtils } from '../../../../common/platform/types';
1211
import { DebugConfigStrings } from '../../../../common/utils/localize';
1312
import { MultiStepInput } from '../../../../common/utils/multiStepInput';
1413
import { SystemVariables } from '../../../../common/variables/systemVariables';
@@ -25,12 +24,12 @@ export class DjangoLaunchDebugConfigurationProvider implements IDebugConfigurati
2524
constructor(
2625
@inject(IFileSystem) private fs: IFileSystem,
2726
@inject(IWorkspaceService) private readonly workspace: IWorkspaceService,
28-
@inject(IPathUtils) private pathUtils: IPathUtils,
27+
@inject(IFileSystemPathUtils) private pathUtils: IFileSystemPathUtils,
2928
) {}
3029
public async buildConfiguration(input: MultiStepInput<DebugConfigurationState>, state: DebugConfigurationState) {
3130
const program = await this.getManagePyPath(state.folder);
3231
let manuallyEnteredAValue: boolean | undefined;
33-
const defaultProgram = `${workspaceFolderToken}${this.pathUtils.separator}manage.py`;
32+
const defaultProgram = `${workspaceFolderToken}${this.pathUtils.paths.sep}manage.py`;
3433
const config: Partial<LaunchRequestArguments> = {
3534
name: DebugConfigStrings.django.snippet.name,
3635
type: DebuggerTypeName,
@@ -89,7 +88,7 @@ export class DjangoLaunchDebugConfigurationProvider implements IDebugConfigurati
8988
}
9089
const defaultLocationOfManagePy = path.join(folder.uri.fsPath, 'manage.py');
9190
if (await this.fs.fileExists(defaultLocationOfManagePy)) {
92-
return `${workspaceFolderToken}${this.pathUtils.separator}manage.py`;
91+
return `${workspaceFolderToken}${this.pathUtils.paths.sep}manage.py`;
9392
}
9493
}
9594
}

src/client/debugger/extension/configuration/providers/pyramidLaunch.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { inject, injectable } from 'inversify';
77
import * as path from 'path';
88
import { Uri, WorkspaceFolder } from 'vscode';
99
import { IWorkspaceService } from '../../../../common/application/types';
10-
import { IFileSystem } from '../../../../common/platform/types';
11-
import { IPathUtils } from '../../../../common/types';
10+
import { IFileSystem, IFileSystemPathUtils } from '../../../../common/platform/types';
1211
import { DebugConfigStrings } from '../../../../common/utils/localize';
1312
import { MultiStepInput } from '../../../../common/utils/multiStepInput';
1413
import { SystemVariables } from '../../../../common/variables/systemVariables';
@@ -28,11 +27,11 @@ export class PyramidLaunchDebugConfigurationProvider implements IDebugConfigurat
2827
constructor(
2928
@inject(IFileSystem) private fs: IFileSystem,
3029
@inject(IWorkspaceService) private readonly workspace: IWorkspaceService,
31-
@inject(IPathUtils) private pathUtils: IPathUtils,
30+
@inject(IFileSystemPathUtils) private pathUtils: IFileSystemPathUtils,
3231
) {}
3332
public async buildConfiguration(input: MultiStepInput<DebugConfigurationState>, state: DebugConfigurationState) {
3433
const iniPath = await this.getDevelopmentIniPath(state.folder);
35-
const defaultIni = `${workspaceFolderToken}${this.pathUtils.separator}development.ini`;
34+
const defaultIni = `${workspaceFolderToken}${this.pathUtils.paths.sep}development.ini`;
3635
let manuallyEnteredAValue: boolean | undefined;
3736

3837
const config: Partial<LaunchRequestArguments> = {
@@ -101,7 +100,7 @@ export class PyramidLaunchDebugConfigurationProvider implements IDebugConfigurat
101100
}
102101
const defaultLocationOfManagePy = path.join(folder.uri.fsPath, 'development.ini');
103102
if (await this.fs.fileExists(defaultLocationOfManagePy)) {
104-
return `${workspaceFolderToken}${this.pathUtils.separator}development.ini`;
103+
return `${workspaceFolderToken}${this.pathUtils.paths.sep}development.ini`;
105104
}
106105
}
107106
}

src/test/debugger/extension/configuration/providers/djangoLaunch.unit.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import { Uri, WorkspaceFolder } from 'vscode';
1010
import { IWorkspaceService } from '../../../../../client/common/application/types';
1111
import { WorkspaceService } from '../../../../../client/common/application/workspace';
1212
import { FileSystem } from '../../../../../client/common/platform/fileSystem';
13-
import { PathUtils } from '../../../../../client/common/platform/pathUtils';
14-
import { IFileSystem } from '../../../../../client/common/platform/types';
15-
import { IPathUtils } from '../../../../../client/common/types';
13+
import { FileSystemPathUtils } from '../../../../../client/common/platform/fs-paths';
14+
import { IFileSystem, IFileSystemPathUtils } from '../../../../../client/common/platform/types';
1615
import { DebugConfigStrings } from '../../../../../client/common/utils/localize';
1716
import { MultiStepInput } from '../../../../../client/common/utils/multiStepInput';
1817
import { DebuggerTypeName } from '../../../../../client/debugger/constants';
@@ -22,7 +21,7 @@ import { DebugConfigurationState } from '../../../../../client/debugger/extensio
2221
suite('Debugging - Configuration Provider Django', () => {
2322
let fs: IFileSystem;
2423
let workspaceService: IWorkspaceService;
25-
let pathUtils: IPathUtils;
24+
let pathUtils: IFileSystemPathUtils;
2625
let provider: TestDjangoLaunchDebugConfigurationProvider;
2726
let input: MultiStepInput<DebugConfigurationState>;
2827
class TestDjangoLaunchDebugConfigurationProvider extends DjangoLaunchDebugConfigurationProvider {
@@ -37,7 +36,7 @@ suite('Debugging - Configuration Provider Django', () => {
3736
setup(() => {
3837
fs = mock(FileSystem);
3938
workspaceService = mock(WorkspaceService);
40-
pathUtils = mock(PathUtils);
39+
pathUtils = mock(FileSystemPathUtils);
4140
input = mock<MultiStepInput<DebugConfigurationState>>(MultiStepInput);
4241
provider = new TestDjangoLaunchDebugConfigurationProvider(
4342
instance(fs),
@@ -58,7 +57,7 @@ suite('Debugging - Configuration Provider Django', () => {
5857
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
5958
const managePyPath = path.join(folder.uri.fsPath, 'manage.py');
6059

61-
when(pathUtils.separator).thenReturn('-');
60+
when(pathUtils.paths.sep).thenReturn('-');
6261
when(fs.fileExists(managePyPath)).thenResolve(true);
6362

6463
const file = await provider.getManagePyPath(folder);
@@ -126,7 +125,7 @@ suite('Debugging - Configuration Provider Django', () => {
126125
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
127126
const state = { config: {}, folder };
128127
provider.getManagePyPath = () => Promise.resolve('xyz.py');
129-
when(pathUtils.separator).thenReturn('-');
128+
when(pathUtils.paths.sep).thenReturn('-');
130129

131130
await provider.buildConfiguration(instance(input), state);
132131

@@ -146,7 +145,7 @@ suite('Debugging - Configuration Provider Django', () => {
146145
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
147146
const state = { config: {}, folder };
148147
provider.getManagePyPath = () => Promise.resolve(undefined);
149-
when(pathUtils.separator).thenReturn('-');
148+
when(pathUtils.paths.sep).thenReturn('-');
150149
when(input.showInputBox(anything())).thenResolve('hello');
151150

152151
await provider.buildConfiguration(instance(input), state);
@@ -170,7 +169,7 @@ suite('Debugging - Configuration Provider Django', () => {
170169
const workspaceFolderToken = '${workspaceFolder}';
171170
const defaultProgram = `${workspaceFolderToken}-manage.py`;
172171

173-
when(pathUtils.separator).thenReturn('-');
172+
when(pathUtils.paths.sep).thenReturn('-');
174173
when(input.showInputBox(anything())).thenResolve();
175174

176175
await provider.buildConfiguration(instance(input), state);

src/test/debugger/extension/configuration/providers/pyramidLaunch.unit.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import { Uri, WorkspaceFolder } from 'vscode';
1010
import { IWorkspaceService } from '../../../../../client/common/application/types';
1111
import { WorkspaceService } from '../../../../../client/common/application/workspace';
1212
import { FileSystem } from '../../../../../client/common/platform/fileSystem';
13-
import { PathUtils } from '../../../../../client/common/platform/pathUtils';
14-
import { IFileSystem } from '../../../../../client/common/platform/types';
15-
import { IPathUtils } from '../../../../../client/common/types';
13+
import { FileSystemPathUtils } from '../../../../../client/common/platform/fs-paths';
14+
import { IFileSystem, IFileSystemPathUtils } from '../../../../../client/common/platform/types';
1615
import { DebugConfigStrings } from '../../../../../client/common/utils/localize';
1716
import { MultiStepInput } from '../../../../../client/common/utils/multiStepInput';
1817
import { DebuggerTypeName } from '../../../../../client/debugger/constants';
@@ -22,7 +21,7 @@ import { DebugConfigurationState } from '../../../../../client/debugger/extensio
2221
suite('Debugging - Configuration Provider Pyramid', () => {
2322
let fs: IFileSystem;
2423
let workspaceService: IWorkspaceService;
25-
let pathUtils: IPathUtils;
24+
let pathUtils: IFileSystemPathUtils;
2625
let provider: TestPyramidLaunchDebugConfigurationProvider;
2726
let input: MultiStepInput<DebugConfigurationState>;
2827
class TestPyramidLaunchDebugConfigurationProvider extends PyramidLaunchDebugConfigurationProvider {
@@ -37,7 +36,7 @@ suite('Debugging - Configuration Provider Pyramid', () => {
3736
setup(() => {
3837
fs = mock(FileSystem);
3938
workspaceService = mock(WorkspaceService);
40-
pathUtils = mock(PathUtils);
39+
pathUtils = mock(FileSystemPathUtils);
4140
input = mock<MultiStepInput<DebugConfigurationState>>(MultiStepInput);
4241
provider = new TestPyramidLaunchDebugConfigurationProvider(
4342
instance(fs),
@@ -58,7 +57,7 @@ suite('Debugging - Configuration Provider Pyramid', () => {
5857
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
5958
const managePyPath = path.join(folder.uri.fsPath, 'development.ini');
6059

61-
when(pathUtils.separator).thenReturn('-');
60+
when(pathUtils.paths.sep).thenReturn('-');
6261
when(fs.fileExists(managePyPath)).thenResolve(true);
6362

6463
const file = await provider.getDevelopmentIniPath(folder);
@@ -126,7 +125,7 @@ suite('Debugging - Configuration Provider Pyramid', () => {
126125
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
127126
const state = { config: {}, folder };
128127
provider.getDevelopmentIniPath = () => Promise.resolve('xyz.ini');
129-
when(pathUtils.separator).thenReturn('-');
128+
when(pathUtils.paths.sep).thenReturn('-');
130129

131130
await provider.buildConfiguration(instance(input), state);
132131

@@ -147,7 +146,7 @@ suite('Debugging - Configuration Provider Pyramid', () => {
147146
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
148147
const state = { config: {}, folder };
149148
provider.getDevelopmentIniPath = () => Promise.resolve(undefined);
150-
when(pathUtils.separator).thenReturn('-');
149+
when(pathUtils.paths.sep).thenReturn('-');
151150
when(input.showInputBox(anything())).thenResolve('hello');
152151

153152
await provider.buildConfiguration(instance(input), state);
@@ -172,7 +171,7 @@ suite('Debugging - Configuration Provider Pyramid', () => {
172171
const workspaceFolderToken = '${workspaceFolder}';
173172
const defaultIni = `${workspaceFolderToken}-development.ini`;
174173

175-
when(pathUtils.separator).thenReturn('-');
174+
when(pathUtils.paths.sep).thenReturn('-');
176175
when(input.showInputBox(anything())).thenResolve();
177176

178177
await provider.buildConfiguration(instance(input), state);

0 commit comments

Comments
 (0)