Skip to content

Commit f2f9c23

Browse files
author
Eric Snow
authored
Drop PlatformService as a dependency of FileSystem. (microsoft#9784)
(for microsoft#8995) The dependency is unnecessary and adds complication to various places that FileSystem is used. Dropping it simplifies things going forward.
1 parent 0a9a7b7 commit f2f9c23

18 files changed

Lines changed: 29 additions & 50 deletions

src/client/common/platform/fileSystem.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { createHash } from 'crypto';
66
import * as fs from 'fs-extra';
77
import * as glob from 'glob';
8-
import { inject, injectable } from 'inversify';
8+
import { injectable } from 'inversify';
99
import { promisify } from 'util';
1010
import * as vscode from 'vscode';
1111
import { createDeferred } from '../utils/async';
@@ -16,7 +16,7 @@ import { TemporaryFileSystem } from './fs-temp';
1616
// prettier-ignore
1717
import {
1818
FileStat, FileType,
19-
IFileSystem, IFileSystemPaths, IPlatformService, IRawFileSystem,
19+
IFileSystem, IFileSystemPaths, IRawFileSystem,
2020
ReadStream, TemporaryFile, WriteStream
2121
} from './types';
2222

@@ -282,14 +282,8 @@ export class FileSystem implements IFileSystem {
282282
private readonly paths: IFileSystemPaths;
283283
private readonly pathUtils: FileSystemPathUtils;
284284
private readonly tmp: TemporaryFileSystem;
285-
// prettier-ignore
286-
constructor(
287-
@inject(IPlatformService) platformService: IPlatformService
288-
) {
289-
// prettier-ignore
290-
this.paths = FileSystemPaths.withDefaults(
291-
platformService.isWindows
292-
);
285+
constructor() {
286+
this.paths = FileSystemPaths.withDefaults();
293287
this.pathUtils = FileSystemPathUtils.withDefaults(this.paths);
294288
this.tmp = TemporaryFileSystem.withDefaults();
295289
this.raw = RawFileSystem.withDefaults(this.paths);

src/client/common/utils/localize.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import * as path from 'path';
77
import { EXTENSION_ROOT_DIR } from '../../constants';
88
import { FileSystem } from '../platform/fileSystem';
9-
import { PlatformService } from '../platform/platformService';
109

1110
// External callers of localize use these tables to retrieve localized values.
1211
export namespace Diagnostics {
@@ -688,7 +687,7 @@ function getString(key: string, defValue?: string) {
688687
}
689688

690689
function load() {
691-
const fs = new FileSystem(new PlatformService());
690+
const fs = new FileSystem();
692691

693692
// Figure out our current locale.
694693
loadedLocale = parseLocale();

src/client/sourceMapSupport.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { WorkspaceConfiguration } from 'vscode';
88
import './common/extensions';
99
import { traceError } from './common/logger';
1010
import { FileSystem } from './common/platform/fileSystem';
11-
import { PlatformService } from './common/platform/platformService';
1211
import { EXTENSION_ROOT_DIR } from './constants';
1312

1413
type VSCode = typeof import('vscode');
@@ -59,7 +58,7 @@ export class SourceMapSupport {
5958
}
6059
}
6160
protected async rename(sourceFile: string, targetFile: string) {
62-
const fs = new FileSystem(new PlatformService());
61+
const fs = new FileSystem();
6362
if (await fs.fileExists(targetFile)) {
6463
return;
6564
}

src/test/common/crypto.unit.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import { assert, expect } from 'chai';
77
import * as path from 'path';
88
import { CryptoUtils } from '../../client/common/crypto';
99
import { FileSystem } from '../../client/common/platform/fileSystem';
10-
import { PlatformService } from '../../client/common/platform/platformService';
1110
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../constants';
1211

1312
// tslint:disable-next-line: max-func-body-length
1413
suite('Crypto Utils', async () => {
1514
let crypto: CryptoUtils;
16-
const fs = new FileSystem(new PlatformService());
15+
const fs = new FileSystem();
1716
const file = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'test', 'common', 'randomWords.txt');
1817
setup(() => {
1918
crypto = new CryptoUtils();

src/test/common/net/fileDownloader.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ suite('File Downloader', () => {
9393
httpClient = mock(HttpClient);
9494
appShell = mock(ApplicationShell);
9595
when(httpClient.downloadFile(anything())).thenCall(request);
96-
fs = new FileSystem(new PlatformService());
96+
fs = new FileSystem();
9797
});
9898
teardown(() => {
9999
rewiremock.disable();

src/test/common/platform/filesystem.functional.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as fs from 'fs-extra';
88
import * as path from 'path';
99
import { convertStat, FileSystem, RawFileSystem } from '../../../client/common/platform/fileSystem';
1010
import { FileSystemPaths, FileSystemPathUtils } from '../../../client/common/platform/fs-paths';
11-
import { PlatformService } from '../../../client/common/platform/platformService';
1211
import { FileType } from '../../../client/common/platform/types';
1312
import { sleep } from '../../../client/common/utils/async';
1413
// prettier-ignore
@@ -796,9 +795,7 @@ suite('FileSystem', () => {
796795
let fix: FSFixture;
797796
setup(async () => {
798797
// prettier-ignore
799-
fileSystem = new FileSystem(
800-
new PlatformService()
801-
);
798+
fileSystem = new FileSystem();
802799
fix = new FSFixture();
803800

804801
await assertDoesNotExist(DOES_NOT_EXIST);

src/test/common/platform/filesystem.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as fsextra from 'fs-extra';
1010
import {
1111
convertStat, FileSystem, RawFileSystem
1212
} from '../../../client/common/platform/fileSystem';
13-
import { PlatformService } from '../../../client/common/platform/platformService';
1413
// prettier-ignore
1514
import {
1615
FileType, IFileSystem, IRawFileSystem
@@ -99,10 +98,7 @@ suite('FileSystem', () => {
9998
let filesystem: IFileSystem;
10099
let fix: FSFixture;
101100
setup(async () => {
102-
// prettier-ignore
103-
filesystem = new FileSystem(
104-
new PlatformService()
105-
);
101+
filesystem = new FileSystem();
106102
fix = new FSFixture();
107103

108104
await assertDoesNotExist(DOES_NOT_EXIST);

src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as fs from 'fs-extra';
88
import * as path from 'path';
99
import * as vscode from 'vscode';
1010
import { FileSystem } from '../../../../client/common/platform/fileSystem';
11-
import { PlatformService } from '../../../../client/common/platform/platformService';
1211
import { PYTHON_VIRTUAL_ENVS_LOCATION } from '../../../ciConstants';
1312
import { PYTHON_PATH, restorePythonPathInWorkspaceRoot, setPythonPathInWorkspaceRoot, updateSetting, waitForCondition } from '../../../common';
1413
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants';
@@ -20,7 +19,7 @@ suite('Activation of Environments in Terminal', () => {
2019
const file = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'smokeTests', 'testExecInTerminal.py');
2120
let outputFile = '';
2221
let outputFileCounter = 0;
23-
const fileSystem = new FileSystem(new PlatformService());
22+
const fileSystem = new FileSystem();
2423
const outputFilesCreated: string[] = [];
2524
const envsLocation =
2625
PYTHON_VIRTUAL_ENVS_LOCATION !== undefined

src/test/common/variables/envVarsService.functional.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { expect, use } from 'chai';
99
import * as chaiAsPromised from 'chai-as-promised';
1010
import { FileSystem } from '../../../client/common/platform/fileSystem';
1111
import { PathUtils } from '../../../client/common/platform/pathUtils';
12-
import { PlatformService } from '../../../client/common/platform/platformService';
1312
import { IPathUtils } from '../../../client/common/types';
1413
import { OSType } from '../../../client/common/utils/platform';
1514
import { EnvironmentVariablesService } from '../../../client/common/variables/environment';
@@ -26,7 +25,7 @@ suite('Environment Variables Service', () => {
2625
let variablesService: IEnvironmentVariablesService;
2726
setup(() => {
2827
pathUtils = new PathUtils(getOSType() === OSType.Windows);
29-
const fs = new FileSystem(new PlatformService());
28+
const fs = new FileSystem();
3029
variablesService = new EnvironmentVariablesService(pathUtils, fs);
3130
});
3231

src/test/common/variables/envVarsService.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as chaiAsPromised from 'chai-as-promised';
1010
import * as path from 'path';
1111
import { FileSystem } from '../../../client/common/platform/fileSystem';
1212
import { PathUtils } from '../../../client/common/platform/pathUtils';
13-
import { PlatformService } from '../../../client/common/platform/platformService';
1413
import { IPathUtils } from '../../../client/common/types';
1514
import { OSType } from '../../../client/common/utils/platform';
1615
import { EnvironmentVariablesService } from '../../../client/common/variables/environment';
@@ -29,7 +28,7 @@ suite('Environment Variables Service', () => {
2928
let variablesService: IEnvironmentVariablesService;
3029
setup(() => {
3130
pathUtils = new PathUtils(getOSType() === OSType.Windows);
32-
const fs = new FileSystem(new PlatformService());
31+
const fs = new FileSystem();
3332
variablesService = new EnvironmentVariablesService(pathUtils, fs);
3433
});
3534

0 commit comments

Comments
 (0)