提交 1d143981 编写于 作者: B Benjamin Pasero

Merge fileServices in /node and /electron-browser (fixes #38776)

上级 db84fe9c
......@@ -140,11 +140,6 @@ export interface IFileService {
*/
unwatchFileChanges(resource: URI): void;
/**
* Configures the file service with the provided options.
*/
updateOptions(options: object): void;
/**
* Returns the preferred encoding to use for a given resource.
*/
......
......@@ -23,12 +23,12 @@ import { Emitter } from 'vs/base/common/event';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { TestTextResourceConfigurationService, TestContextService, TestLifecycleService, TestEnvironmentService, TestNotificationService } from 'vs/workbench/test/workbenchTestServices';
import { TestTextResourceConfigurationService, TestContextService, TestLifecycleService, TestEnvironmentService, TestNotificationService, TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import URI from 'vs/base/common/uri';
import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { IFileService } from 'vs/platform/files/common/files';
import { FileService } from 'vs/workbench/services/files/node/fileService';
import { FileService } from 'vs/workbench/services/files/electron-browser/fileService';
import * as extfs from 'vs/base/node/extfs';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { IPager } from 'vs/base/common/paging';
......@@ -265,7 +265,7 @@ suite('ExtensionsTipsService Test', () => {
const myWorkspace = testWorkspace(URI.from({ scheme: 'file', path: folderDir }));
workspaceService = new TestContextService(myWorkspace);
instantiationService.stub(IWorkspaceContextService, workspaceService);
instantiationService.stub(IFileService, new FileService(workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), { disableWatcher: true }));
instantiationService.stub(IFileService, new FileService(workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }));
});
}
......
......@@ -26,6 +26,7 @@ interface IConfiguration extends IWindowsConfiguration {
telemetry: { enableCrashReporter: boolean };
keyboard: { touchbar: { enabled: boolean } };
workbench: { tree: { horizontalScrolling: boolean } };
files: { useExperimentalFileWatcher: boolean };
}
export class SettingsChangeRelauncher implements IWorkbenchContribution {
......@@ -40,6 +41,7 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
private touchbarEnabled: boolean;
private treeHorizontalScrolling: boolean;
private windowsSmoothScrollingWorkaround: boolean;
private experimentalFileWatcher: boolean;
private firstFolderResource: URI;
private extensionHostRestarter: RunOnceScheduler;
......@@ -103,6 +105,12 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
changed = true;
}
// Experimental File Watcher
if (config.files && typeof config.files.useExperimentalFileWatcher === 'boolean' && config.files.useExperimentalFileWatcher !== this.experimentalFileWatcher) {
this.experimentalFileWatcher = config.files.useExperimentalFileWatcher;
changed = true;
}
// macOS: Touchbar config
if (isMacintosh && config.keyboard && config.keyboard.touchbar && typeof config.keyboard.touchbar.enabled === 'boolean' && config.keyboard.touchbar.enabled !== this.touchbarEnabled) {
this.touchbarEnabled = config.keyboard.touchbar.enabled;
......
......@@ -14,9 +14,9 @@ import * as path from 'path';
import * as pfs from 'vs/base/node/pfs';
import Uri from 'vs/base/common/uri';
import { BackupFileService, BackupFilesModel } from 'vs/workbench/services/backup/node/backupFileService';
import { FileService } from 'vs/workbench/services/files/node/fileService';
import { FileService } from 'vs/workbench/services/files/electron-browser/fileService';
import { TextModel, createTextBufferFactory } from 'vs/editor/common/model/textModel';
import { TestContextService, TestTextResourceConfigurationService, getRandomTestPath, TestLifecycleService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
import { TestContextService, TestTextResourceConfigurationService, getRandomTestPath, TestLifecycleService, TestEnvironmentService, TestNotificationService, TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { Workspace, toWorkspaceFolders } from 'vs/platform/workspace/common/workspace';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { DefaultEndOfLine } from 'vs/editor/common/model';
......@@ -38,7 +38,7 @@ const untitledBackupPath = path.join(workspaceBackupPath, 'untitled', crypto.cre
class TestBackupFileService extends BackupFileService {
constructor(workspace: Uri, backupHome: string, workspacesJsonPath: string) {
const fileService = new FileService(new TestContextService(new Workspace(workspace.fsPath, workspace.fsPath, toWorkspaceFolders([{ path: workspace.fsPath }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), { disableWatcher: true });
const fileService = new FileService(new TestContextService(new Workspace(workspace.fsPath, workspace.fsPath, toWorkspaceFolders([{ path: workspace.fsPath }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true });
super(workspaceBackupPath, fileService);
}
......
......@@ -18,11 +18,11 @@ import { parseArgs } from 'vs/platform/environment/node/argv';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import * as extfs from 'vs/base/node/extfs';
import { TestTextFileService, TestTextResourceConfigurationService, workbenchInstantiationService, TestLifecycleService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
import { TestTextFileService, TestTextResourceConfigurationService, workbenchInstantiationService, TestLifecycleService, TestEnvironmentService, TestStorageService, TestNotificationService } from 'vs/workbench/test/workbenchTestServices';
import * as uuid from 'vs/base/common/uuid';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService';
import { FileService } from 'vs/workbench/services/files/node/fileService';
import { FileService } from 'vs/workbench/services/files/electron-browser/fileService';
import { ConfigurationEditingService, ConfigurationEditingError, ConfigurationEditingErrorCode } from 'vs/workbench/services/configuration/node/configurationEditingService';
import { IFileService } from 'vs/platform/files/common/files';
import { WORKSPACE_STANDALONE_CONFIGURATIONS } from 'vs/workbench/services/configuration/common/configuration';
......@@ -104,7 +104,7 @@ suite('ConfigurationEditingService', () => {
instantiationService.stub(IWorkspaceContextService, workspaceService);
return workspaceService.initialize(noWorkspace ? {} as IWindowConfiguration : workspaceDir).then(() => {
instantiationService.stub(IConfigurationService, workspaceService);
instantiationService.stub(IFileService, new FileService(workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), { disableWatcher: true }));
instantiationService.stub(IFileService, new FileService(workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }));
instantiationService.stub(ITextFileService, instantiationService.createInstance(TestTextFileService));
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
instantiationService.stub(ICommandService, CommandService);
......
......@@ -24,8 +24,8 @@ import { ConfigurationEditingErrorCode } from 'vs/workbench/services/configurati
import { FileChangeType, FileChangesEvent, IFileService } from 'vs/platform/files/common/files';
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFoldersChangeEvent } from 'vs/platform/workspace/common/workspace';
import { ConfigurationTarget, IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
import { workbenchInstantiationService, TestTextResourceConfigurationService, TestTextFileService, TestLifecycleService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
import { FileService } from 'vs/workbench/services/files/node/fileService';
import { workbenchInstantiationService, TestTextResourceConfigurationService, TestTextFileService, TestLifecycleService, TestEnvironmentService, TestStorageService, TestNotificationService } from 'vs/workbench/test/workbenchTestServices';
import { FileService } from 'vs/workbench/services/files/electron-browser/fileService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
......@@ -151,7 +151,7 @@ suite('WorkspaceContextService - Workspace', () => {
return workspaceService.initialize({ id: configPath, configPath }).then(() => {
instantiationService.stub(IFileService, new FileService(<IWorkspaceContextService>workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), workspaceService, new TestLifecycleService(), { disableWatcher: true }));
instantiationService.stub(IFileService, new FileService(<IWorkspaceContextService>workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), workspaceService, new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }));
instantiationService.stub(ITextFileService, instantiationService.createInstance(TestTextFileService));
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
workspaceService.setInstantiationService(instantiationService);
......@@ -409,7 +409,7 @@ suite('WorkspaceService - Initialization', () => {
instantiationService.stub(IEnvironmentService, environmentService);
return workspaceService.initialize(<IWindowConfiguration>{}).then(() => {
instantiationService.stub(IFileService, new FileService(<IWorkspaceContextService>workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), workspaceService, new TestLifecycleService(), { disableWatcher: true }));
instantiationService.stub(IFileService, new FileService(<IWorkspaceContextService>workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), workspaceService, new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }));
instantiationService.stub(ITextFileService, instantiationService.createInstance(TestTextFileService));
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
workspaceService.setInstantiationService(instantiationService);
......@@ -667,7 +667,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
instantiationService.stub(IEnvironmentService, environmentService);
return workspaceService.initialize(folderDir).then(() => {
instantiationService.stub(IFileService, new FileService(<IWorkspaceContextService>workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), workspaceService, new TestLifecycleService(), { disableWatcher: true }));
instantiationService.stub(IFileService, new FileService(<IWorkspaceContextService>workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), workspaceService, new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }));
instantiationService.stub(ITextFileService, instantiationService.createInstance(TestTextFileService));
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
workspaceService.setInstantiationService(instantiationService);
......@@ -980,7 +980,7 @@ suite('WorkspaceConfigurationService - Multiroot', () => {
return workspaceService.initialize({ id: configPath, configPath }).then(() => {
instantiationService.stub(IFileService, new FileService(<IWorkspaceContextService>workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), workspaceService, new TestLifecycleService(), { disableWatcher: true }));
instantiationService.stub(IFileService, new FileService(<IWorkspaceContextService>workspaceService, TestEnvironmentService, new TestTextResourceConfigurationService(), workspaceService, new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true }));
instantiationService.stub(ITextFileService, instantiationService.createInstance(TestTextFileService));
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
workspaceService.setInstantiationService(instantiationService);
......
......@@ -84,13 +84,13 @@ export class RemoteFileService extends FileService {
@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
) {
super(
configurationService,
contextService,
environmentService,
textResourceConfigurationService,
configurationService,
lifecycleService,
notificationService,
_storageService,
textResourceConfigurationService,
notificationService
);
this._supportedSchemes = JSON.parse(this._storageService.get('remote_schemes', undefined, '[]'));
......
......@@ -11,14 +11,14 @@ import * as os from 'os';
import * as assert from 'assert';
import { TPromise } from 'vs/base/common/winjs.base';
import { FileService, IEncodingOverride } from 'vs/workbench/services/files/node/fileService';
import { FileService, IEncodingOverride } from 'vs/workbench/services/files/electron-browser/fileService';
import { FileOperation, FileOperationEvent, FileChangesEvent, FileOperationResult, FileOperationError } from 'vs/platform/files/common/files';
import uri from 'vs/base/common/uri';
import * as uuid from 'vs/base/common/uuid';
import * as pfs from 'vs/base/node/pfs';
import * as encodingLib from 'vs/base/node/encoding';
import * as utils from 'vs/workbench/services/files/test/node/utils';
import { TestEnvironmentService, TestContextService, TestTextResourceConfigurationService, getRandomTestPath, TestLifecycleService } from 'vs/workbench/test/workbenchTestServices';
import * as utils from 'vs/workbench/services/files/test/electron-browser/utils';
import { TestEnvironmentService, TestContextService, TestTextResourceConfigurationService, getRandomTestPath, TestLifecycleService, TestNotificationService, TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { Workspace, toWorkspaceFolders } from 'vs/platform/workspace/common/workspace';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { TextModel } from 'vs/editor/common/model/textModel';
......@@ -34,7 +34,7 @@ suite('FileService', () => {
const sourceDir = require.toUrl('./fixtures/service');
return pfs.copy(sourceDir, testDir).then(() => {
service = new FileService(new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), { disableWatcher: true });
service = new FileService(new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true });
});
});
......@@ -892,10 +892,18 @@ suite('FileService', () => {
const textResourceConfigurationService = new TestTextResourceConfigurationService(configurationService);
const _service = new FileService(new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))), TestEnvironmentService, textResourceConfigurationService, configurationService, new TestLifecycleService(), {
encodingOverride,
disableWatcher: true
});
const _service = new FileService(
new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))),
TestEnvironmentService,
textResourceConfigurationService,
configurationService,
new TestLifecycleService(),
new TestStorageService(),
new TestNotificationService(),
{
encodingOverride,
disableWatcher: true
});
return _service.resolveContent(uri.file(path.join(testDir, 'index.html'))).then(c => {
assert.equal(c.encoding, 'windows1252');
......@@ -929,10 +937,18 @@ suite('FileService', () => {
const textResourceConfigurationService = new TestTextResourceConfigurationService(configurationService);
const _service = new FileService(new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))), TestEnvironmentService, textResourceConfigurationService, configurationService, new TestLifecycleService(), {
encodingOverride,
disableWatcher: true
});
const _service = new FileService(
new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))),
TestEnvironmentService,
textResourceConfigurationService,
configurationService,
new TestLifecycleService(),
new TestStorageService(),
new TestNotificationService(),
{
encodingOverride,
disableWatcher: true
});
return _service.resolveContent(uri.file(path.join(testDir, 'index.html'))).then(c => {
assert.equal(c.encoding, 'windows1252');
......@@ -955,9 +971,17 @@ suite('FileService', () => {
const _sourceDir = require.toUrl('./fixtures/service');
const resource = uri.file(path.join(testDir, 'index.html'));
const _service = new FileService(new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), {
disableWatcher: true
});
const _service = new FileService(
new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))),
TestEnvironmentService,
new TestTextResourceConfigurationService(),
new TestConfigurationService(),
new TestLifecycleService(),
new TestStorageService(),
new TestNotificationService(),
{
disableWatcher: true
});
return pfs.copy(_sourceDir, _testDir).then(() => {
return pfs.readFile(resource.fsPath).then(data => {
......
......@@ -9,10 +9,10 @@ import * as fs from 'fs';
import * as path from 'path';
import * as assert from 'assert';
import { StatResolver } from 'vs/workbench/services/files/node/fileService';
import { StatResolver } from 'vs/workbench/services/files/electron-browser/fileService';
import uri from 'vs/base/common/uri';
import { isLinux } from 'vs/base/common/platform';
import * as utils from 'vs/workbench/services/files/test/node/utils';
import * as utils from 'vs/workbench/services/files/test/electron-browser/utils';
function create(relativePath: string): StatResolver {
let basePath = require.toUrl('./fixtures/resolver');
......
......@@ -16,11 +16,11 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { KeyCode, SimpleKeybinding, ChordKeybinding } from 'vs/base/common/keyCodes';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import * as extfs from 'vs/base/node/extfs';
import { TestTextFileService, TestEditorGroupService, TestLifecycleService, TestBackupFileService, TestContextService, TestTextResourceConfigurationService, TestHashService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
import { TestTextFileService, TestEditorGroupService, TestLifecycleService, TestBackupFileService, TestContextService, TestTextResourceConfigurationService, TestHashService, TestEnvironmentService, TestStorageService, TestNotificationService } from 'vs/workbench/test/workbenchTestServices';
import { IWorkspaceContextService, Workspace, toWorkspaceFolders } from 'vs/platform/workspace/common/workspace';
import * as uuid from 'vs/base/common/uuid';
import { ConfigurationService } from 'vs/platform/configuration/node/configurationService';
import { FileService } from 'vs/workbench/services/files/node/fileService';
import { FileService } from 'vs/workbench/services/files/electron-browser/fileService';
import { IFileService } from 'vs/platform/files/common/files';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
......@@ -80,7 +80,16 @@ suite('Keybindings Editing', () => {
instantiationService.stub(ITelemetryService, NullTelemetryService);
instantiationService.stub(IModeService, ModeServiceImpl);
instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
instantiationService.stub(IFileService, new FileService(new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), lifecycleService, { disableWatcher: true }));
instantiationService.stub(IFileService, new FileService(
new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))),
TestEnvironmentService,
new TestTextResourceConfigurationService(),
new TestConfigurationService(),
lifecycleService,
new TestStorageService(),
new TestNotificationService(),
{ disableWatcher: true })
);
instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
instantiationService.stub(ITextFileService, instantiationService.createInstance(TestTextFileService));
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
......
......@@ -815,9 +815,6 @@ export class TestFileService implements IFileService {
unwatchFileChanges(resource: URI): void {
}
updateOptions(options: any): void {
}
getEncoding(resource: URI): string {
return 'utf8';
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册