diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 5afbb0f9f24700f9c6dafd4231602410333b4c61..eb7ca5f8b3bafb4f58d6adfcf89d1554d00e6bf1 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -14,7 +14,7 @@ import { domContentLoaded, addDisposableListener, EventType, scheduleAtNextAnima import { onUnexpectedError } from 'vs/base/common/errors'; import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform'; import { URI } from 'vs/base/common/uri'; -import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService'; +import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { stat } from 'vs/base/node/pfs'; @@ -53,6 +53,7 @@ import { DefaultConfigurationExportHelper } from 'vs/workbench/services/configur import { HashService } from 'vs/workbench/services/hash/node/hashService'; import { IHashService } from 'vs/workbench/services/hash/common/hashService'; import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache'; +import { ConfigurationFileService } from 'vs/workbench/services/configuration/node/configurationFileService'; class CodeRendererMain extends Disposable { @@ -302,7 +303,7 @@ class CodeRendererMain extends Disposable { } private createWorkspaceService(payload: IWorkspaceInitializationPayload, environmentService: IEnvironmentService, hashService: IHashService, remoteAgentService: IRemoteAgentService, logService: ILogService): Promise { - const workspaceService = new WorkspaceService({ userSettingsPath: environmentService.appSettingsPath, remoteAuthority: this.configuration.remoteAuthority, configurationCache: new ConfigurationCache(environmentService) }, hashService, remoteAgentService); + const workspaceService = new WorkspaceService({ userSettingsResource: URI.file(environmentService.appSettingsPath), remoteAuthority: this.configuration.remoteAuthority, configurationCache: new ConfigurationCache(environmentService) }, new ConfigurationFileService(), hashService, remoteAgentService); return workspaceService.initialize(payload).then(() => workspaceService, error => { onUnexpectedError(error); diff --git a/src/vs/workbench/services/configuration/node/configuration.ts b/src/vs/workbench/services/configuration/browser/configuration.ts similarity index 91% rename from src/vs/workbench/services/configuration/node/configuration.ts rename to src/vs/workbench/services/configuration/browser/configuration.ts index 1a76c930b5a887e27b97a314194e6d5b0658a1ee..f55e4c579ca6498adb17cb614769cbeb42979ca3 100644 --- a/src/vs/workbench/services/configuration/node/configuration.ts +++ b/src/vs/workbench/services/configuration/browser/configuration.ts @@ -6,15 +6,14 @@ import { URI } from 'vs/base/common/uri'; import * as resources from 'vs/base/common/resources'; import { Event, Emitter } from 'vs/base/common/event'; -import * as pfs from 'vs/base/node/pfs'; import * as errors from 'vs/base/common/errors'; import { Disposable, IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle'; import { RunOnceScheduler } from 'vs/base/common/async'; import { FileChangeType, FileChangesEvent, IFileService } from 'vs/platform/files/common/files'; import { ConfigurationModel, ConfigurationModelParser } from 'vs/platform/configuration/common/configurationModels'; import { WorkspaceConfigurationModelParser, FolderSettingsModelParser, StandaloneConfigurationModelParser } from 'vs/workbench/services/configuration/common/configurationModels'; -import { FOLDER_SETTINGS_PATH, TASKS_CONFIGURATION_KEY, FOLDER_SETTINGS_NAME, LAUNCH_CONFIGURATION_KEY, IConfigurationCache, ConfigurationKey } from 'vs/workbench/services/configuration/common/configuration'; -import { IStoredWorkspaceFolder } from 'vs/platform/workspaces/common/workspaces'; +import { FOLDER_SETTINGS_PATH, TASKS_CONFIGURATION_KEY, FOLDER_SETTINGS_NAME, LAUNCH_CONFIGURATION_KEY, IConfigurationCache, ConfigurationKey, IConfigurationFileService } from 'vs/workbench/services/configuration/common/configuration'; +import { IStoredWorkspaceFolder, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { JSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditingService'; import { WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; @@ -22,7 +21,6 @@ import { extname, join } from 'vs/base/common/path'; import { equals } from 'vs/base/common/objects'; import { Schemas } from 'vs/base/common/network'; import { IConfigurationModel, compare } from 'vs/platform/configuration/common/configuration'; -import { NodeBasedUserConfiguration } from 'vs/platform/configuration/node/configuration'; import { IHashService } from 'vs/workbench/services/hash/common/hashService'; export class LocalUserConfiguration extends Disposable { @@ -35,11 +33,12 @@ export class LocalUserConfiguration extends Disposable { public readonly onDidChangeConfiguration: Event = this._onDidChangeConfiguration.event; constructor( - userSettingsPath: string + userConfigurationResource: URI, + configurationFileService: IConfigurationFileService ) { super(); - this.userConfigurationResource = URI.file(userSettingsPath); - this.userConfiguration = this._register(new NodeBasedUserConfiguration(userSettingsPath)); + this.userConfigurationResource = userConfigurationResource; + this.userConfiguration = this._register(new NodeBasedUserConfiguration(this.userConfigurationResource, configurationFileService)); } initialize(): Promise { @@ -122,6 +121,50 @@ export class RemoteUserConfiguration extends Disposable { } } +class NodeBasedUserConfiguration extends Disposable { + + private configuraitonModel: ConfigurationModel = new ConfigurationModel(); + + constructor( + private readonly userConfigurationResource: URI, + private readonly configurationFileService: IConfigurationFileService + ) { + super(); + } + + initialize(): Promise { + return this._load(); + } + + reload(): Promise { + return this._load(); + } + + getConfigurationModel(): ConfigurationModel { + return this.configuraitonModel; + } + + async _load(): Promise { + const exists = await this.configurationFileService.exists(this.userConfigurationResource); + if (exists) { + try { + const content = await this.configurationFileService.resolveContent(this.userConfigurationResource); + const parser = new ConfigurationModelParser(this.userConfigurationResource.toString()); + parser.parse(content); + this.configuraitonModel = parser.configurationModel; + } catch (e) { + // ignore error + errors.onUnexpectedError(e); + this.configuraitonModel = new ConfigurationModel(); + } + } else { + this.configuraitonModel = new ConfigurationModel(); + } + return this.configuraitonModel; + } + +} + export class FileServiceBasedUserConfiguration extends Disposable { private readonly reloadConfigurationScheduler: RunOnceScheduler; @@ -259,14 +302,10 @@ class CachedUserConfiguration extends Disposable { } } -export interface IWorkspaceIdentifier { - id: string; - configPath: URI; -} - export class WorkspaceConfiguration extends Disposable { private readonly _cachedConfiguration: CachedWorkspaceConfiguration; + private readonly _configurationFileService: IConfigurationFileService; private _workspaceConfiguration: IWorkspaceConfiguration; private _workspaceIdentifier: IWorkspaceIdentifier | null = null; private _fileService: IFileService | null = null; @@ -275,10 +314,12 @@ export class WorkspaceConfiguration extends Disposable { public readonly onDidUpdateConfiguration: Event = this._onDidUpdateConfiguration.event; constructor( - configurationCache: IConfigurationCache + configurationCache: IConfigurationCache, + configurationFileService: IConfigurationFileService ) { super(); this._cachedConfiguration = new CachedWorkspaceConfiguration(configurationCache); + this._configurationFileService = configurationFileService; this._workspaceConfiguration = this._cachedConfiguration; } @@ -345,7 +386,7 @@ export class WorkspaceConfiguration extends Disposable { if (this._workspaceIdentifier.configPath.scheme === Schemas.file) { if (!(this._workspaceConfiguration instanceof NodeBasedWorkspaceConfiguration)) { dispose(this._workspaceConfiguration); - this._workspaceConfiguration = new NodeBasedWorkspaceConfiguration(); + this._workspaceConfiguration = new NodeBasedWorkspaceConfiguration(this._configurationFileService); return true; } return false; @@ -440,16 +481,16 @@ abstract class AbstractWorkspaceConfiguration extends Disposable implements IWor class NodeBasedWorkspaceConfiguration extends AbstractWorkspaceConfiguration { + constructor(private readonly configurationFileService: IConfigurationFileService) { + super(); + } + protected async loadWorkspaceConfigurationContents(workspaceConfigurationResource: URI): Promise { - try { - const contents = await pfs.readFile(workspaceConfigurationResource.fsPath); - return contents.toString(); - } catch (e) { - if (e.code === 'ENOENT') { - return undefined; - } - throw e; + const exists = await this.configurationFileService.exists(workspaceConfigurationResource); + if (exists) { + return this.configurationFileService.resolveContent(workspaceConfigurationResource); } + return undefined; } } @@ -658,16 +699,16 @@ export abstract class AbstractFolderConfiguration extends Disposable implements export class NodeBasedFolderConfiguration extends AbstractFolderConfiguration { + constructor(private readonly configurationFileService: IConfigurationFileService, configurationFolder: URI, workbenchState: WorkbenchState) { + super(configurationFolder, workbenchState); + } + protected async loadConfigurationResourceContents(configurationResource: URI): Promise { - try { - const contents = await pfs.readFile(configurationResource.fsPath); - return contents.toString(); - } catch (e) { - if (e.code === 'ENOENT') { - return undefined; - } - throw e; + const exists = await this.configurationFileService.exists(configurationResource); + if (exists) { + return this.configurationFileService.resolveContent(configurationResource); } + return undefined; } } @@ -801,6 +842,7 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat configFolderRelativePath: string, private readonly workbenchState: WorkbenchState, hashService: IHashService, + configurationFileService: IConfigurationFileService, configurationCache: IConfigurationCache, fileService?: IFileService ) { @@ -812,7 +854,7 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat if (fileService) { this.folderConfiguration = new FileServiceBasedFolderConfiguration(this.configurationFolder, this.workbenchState, fileService); } else if (workspaceFolder.uri.scheme === Schemas.file) { - this.folderConfiguration = new NodeBasedFolderConfiguration(this.configurationFolder, this.workbenchState); + this.folderConfiguration = new NodeBasedFolderConfiguration(configurationFileService, this.configurationFolder, this.workbenchState); } this._register(this.folderConfiguration.onDidChange(e => this.onDidFolderConfigurationChange())); } diff --git a/src/vs/workbench/services/configuration/node/configurationService.ts b/src/vs/workbench/services/configuration/browser/configurationService.ts similarity index 98% rename from src/vs/workbench/services/configuration/node/configurationService.ts rename to src/vs/workbench/services/configuration/browser/configurationService.ts index 818ee45f4cc418ae419fd51f3108373da86f9323..da1c25b9c49fba376353b6cd229af8f3a715dd41 100644 --- a/src/vs/workbench/services/configuration/node/configurationService.ts +++ b/src/vs/workbench/services/configuration/browser/configurationService.ts @@ -17,13 +17,13 @@ import { IFileService } from 'vs/platform/files/common/files'; import { ConfigurationChangeEvent, ConfigurationModel, DefaultConfigurationModel } from 'vs/platform/configuration/common/configurationModels'; import { IConfigurationChangeEvent, ConfigurationTarget, IConfigurationOverrides, keyFromOverrideIdentifier, isConfigurationOverrides, IConfigurationData, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { Configuration, WorkspaceConfigurationChangeEvent, AllKeysConfigurationChangeEvent } from 'vs/workbench/services/configuration/common/configurationModels'; -import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache } from 'vs/workbench/services/configuration/common/configuration'; +import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache, IConfigurationFileService } from 'vs/workbench/services/configuration/common/configuration'; import { Registry } from 'vs/platform/registry/common/platform'; import { IConfigurationRegistry, Extensions, allSettings, windowSettings, resourceSettings, applicationSettings } from 'vs/platform/configuration/common/configurationRegistry'; import { IWorkspaceIdentifier, isWorkspaceIdentifier, IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, isSingleFolderWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, IEmptyWorkspaceInitializationPayload, useSlashForPath, getStoredWorkspaceFolder } from 'vs/platform/workspaces/common/workspaces'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ConfigurationEditingService } from 'vs/workbench/services/configuration/common/configurationEditingService'; -import { WorkspaceConfiguration, FolderConfiguration, RemoteUserConfiguration, LocalUserConfiguration } from 'vs/workbench/services/configuration/node/configuration'; +import { WorkspaceConfiguration, FolderConfiguration, RemoteUserConfiguration, LocalUserConfiguration } from 'vs/workbench/services/configuration/browser/configuration'; import { JSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditingService'; import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema'; import { localize } from 'vs/nls'; @@ -66,7 +66,8 @@ export class WorkspaceService extends Disposable implements IConfigurationServic private jsonEditingService: JSONEditingService; constructor( - { userSettingsPath, remoteAuthority, configurationCache }: { userSettingsPath?: string, remoteAuthority?: string, configurationCache: IConfigurationCache }, + { userSettingsResource, remoteAuthority, configurationCache }: { userSettingsResource?: URI, remoteAuthority?: string, configurationCache: IConfigurationCache }, + private readonly configurationFileService: IConfigurationFileService, private readonly hashService: IHashService, private readonly remoteAgentService: IRemoteAgentService, ) { @@ -75,15 +76,15 @@ export class WorkspaceService extends Disposable implements IConfigurationServic this.completeWorkspaceBarrier = new Barrier(); this.defaultConfiguration = new DefaultConfigurationModel(); this.configurationCache = configurationCache; - if (userSettingsPath) { - this.localUserConfiguration = this._register(new LocalUserConfiguration(userSettingsPath)); + if (userSettingsResource) { + this.localUserConfiguration = this._register(new LocalUserConfiguration(userSettingsResource, configurationFileService)); this._register(this.localUserConfiguration.onDidChangeConfiguration(userConfiguration => this.onLocalUserConfigurationChanged(userConfiguration))); } if (remoteAuthority) { this.remoteUserConfiguration = this._register(new RemoteUserConfiguration(remoteAuthority, configurationCache)); this._register(this.remoteUserConfiguration.onDidChangeConfiguration(userConfiguration => this.onRemoteUserConfigurationChanged(userConfiguration))); } - this.workspaceConfiguration = this._register(new WorkspaceConfiguration(configurationCache)); + this.workspaceConfiguration = this._register(new WorkspaceConfiguration(configurationCache, this.configurationFileService)); this._register(this.workspaceConfiguration.onDidUpdateConfiguration(() => this.onWorkspaceConfigurationChanged())); this._register(Registry.as(Extensions.Configuration).onDidSchemaChange(e => this.registerConfigurationSchemas())); @@ -630,7 +631,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic return Promise.all([...folders.map(folder => { let folderConfiguration = this.cachedFolderConfigs.get(folder.uri); if (!folderConfiguration) { - folderConfiguration = new FolderConfiguration(folder, FOLDER_CONFIG_FOLDER_NAME, this.getWorkbenchState(), this.hashService, this.configurationCache, this.fileService); + folderConfiguration = new FolderConfiguration(folder, FOLDER_CONFIG_FOLDER_NAME, this.getWorkbenchState(), this.hashService, this.configurationFileService, this.configurationCache, this.fileService); this._register(folderConfiguration.onDidChange(() => this.onWorkspaceFolderConfigurationChanged(folder))); this.cachedFolderConfigs.set(folder.uri, this._register(folderConfiguration)); } diff --git a/src/vs/workbench/services/configuration/common/configuration.ts b/src/vs/workbench/services/configuration/common/configuration.ts index 8fcb72881e1f54f388cfff91c5e12b96dc7e7d00..8fdbde5b904216e6d8f673a79645cbe1f9156b6d 100644 --- a/src/vs/workbench/services/configuration/common/configuration.ts +++ b/src/vs/workbench/services/configuration/common/configuration.ts @@ -3,6 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { URI } from 'vs/base/common/uri'; + export const FOLDER_CONFIG_FOLDER_NAME = '.vscode'; export const FOLDER_SETTINGS_NAME = 'settings'; export const FOLDER_SETTINGS_PATH = `${FOLDER_CONFIG_FOLDER_NAME}/${FOLDER_SETTINGS_NAME}.json`; @@ -30,3 +32,8 @@ export interface IConfigurationCache { remove(key: ConfigurationKey): Promise; } + +export interface IConfigurationFileService { + exists(resource: URI): Promise; + resolveContent(resource: URI): Promise; +} diff --git a/src/vs/workbench/services/configuration/node/configurationFileService.ts b/src/vs/workbench/services/configuration/node/configurationFileService.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef6d1b6ea35fc5492351654a0f2482fc258d05a8 --- /dev/null +++ b/src/vs/workbench/services/configuration/node/configurationFileService.ts @@ -0,0 +1,21 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as pfs from 'vs/base/node/pfs'; +import { IConfigurationFileService } from 'vs/workbench/services/configuration/common/configuration'; +import { URI } from 'vs/base/common/uri'; + +export class ConfigurationFileService implements IConfigurationFileService { + + exists(resource: URI): Promise { + return pfs.exists(resource.fsPath); + } + + async resolveContent(resource: URI): Promise { + const contents = await pfs.readFile(resource.fsPath); + return contents.toString(); + } + +} diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts index 8c23058f244d6ad14b53ef34f75bf9254347a0a0..c2eec1121c5457656918194601b05acfc5bcd11e 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts @@ -17,7 +17,7 @@ import { EnvironmentService } from 'vs/platform/environment/node/environmentServ import { TestTextFileService, TestTextResourceConfigurationService, workbenchInstantiationService, TestEnvironmentService } 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 { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService'; import { LegacyFileService } from 'vs/workbench/services/files/node/fileService'; import { ConfigurationEditingService, ConfigurationEditingError, ConfigurationEditingErrorCode } from 'vs/workbench/services/configuration/common/configurationEditingService'; import { WORKSPACE_STANDALONE_CONFIGURATIONS } from 'vs/workbench/services/configuration/common/configuration'; @@ -41,6 +41,7 @@ import { DiskFileSystemProvider } from 'vs/workbench/services/files2/node/diskFi import { IFileService } from 'vs/platform/files/common/files'; import { HashService } from 'vs/workbench/services/hash/node/hashService'; import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache'; +import { ConfigurationFileService } from 'vs/workbench/services/configuration/node/configurationFileService'; class SettingsTestEnvironmentService extends EnvironmentService { @@ -106,7 +107,7 @@ suite('ConfigurationEditingService', () => { instantiationService.stub(IEnvironmentService, environmentService); const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {}); instantiationService.stub(IRemoteAgentService, remoteAgentService); - const workspaceService = new WorkspaceService({ userSettingsPath: environmentService.appSettingsPath, configurationCache: new ConfigurationCache(environmentService) }, new HashService(), remoteAgentService); + const workspaceService = new WorkspaceService({ userSettingsResource: URI.file(environmentService.appSettingsPath), configurationCache: new ConfigurationCache(environmentService) }, new ConfigurationFileService(), new HashService(), remoteAgentService); instantiationService.stub(IWorkspaceContextService, workspaceService); return workspaceService.initialize(noWorkspace ? { id: '' } : { folder: URI.file(workspaceDir), id: createHash('md5').update(URI.file(workspaceDir).toString()).digest('hex') }).then(() => { instantiationService.stub(IConfigurationService, workspaceService); diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts index 6dd483936a49eeaace149e30b2970bb303b002da..b20255f42d62e2d25b6f8e4004305c24ec837183 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts @@ -16,8 +16,8 @@ import { parseArgs } from 'vs/platform/environment/node/argv'; import * as pfs from 'vs/base/node/pfs'; import * as uuid from 'vs/base/common/uuid'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; -import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService'; -import { ISingleFolderWorkspaceInitializationPayload } from 'vs/platform/workspaces/common/workspaces'; +import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService'; +import { ISingleFolderWorkspaceInitializationPayload, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { ConfigurationEditingErrorCode } from 'vs/workbench/services/configuration/common/configurationEditingService'; import { IFileService } from 'vs/platform/files/common/files'; import { IWorkspaceContextService, WorkbenchState, IWorkspaceFoldersChangeEvent } from 'vs/platform/workspace/common/workspace'; @@ -34,7 +34,6 @@ import { createHash } from 'crypto'; import { Schemas } from 'vs/base/common/network'; import { originalFSPath } from 'vs/base/common/resources'; import { isLinux } from 'vs/base/common/platform'; -import { IWorkspaceIdentifier } from 'vs/workbench/services/configuration/node/configuration'; import { IWindowConfiguration } from 'vs/platform/windows/common/windows'; import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl'; import { RemoteAuthorityResolverService } from 'vs/platform/remote/electron-browser/remoteAuthorityResolverService'; @@ -44,6 +43,7 @@ import { NullLogService } from 'vs/platform/log/common/log'; import { DiskFileSystemProvider } from 'vs/workbench/services/files2/node/diskFileSystemProvider'; import { HashService } from 'vs/workbench/services/hash/node/hashService'; import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache'; +import { ConfigurationFileService } from 'vs/workbench/services/configuration/node/configurationFileService'; class SettingsTestEnvironmentService extends EnvironmentService { @@ -102,7 +102,7 @@ suite('WorkspaceContextService - Folder', () => { workspaceResource = folderDir; const globalSettingsFile = path.join(parentDir, 'settings.json'); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); - workspaceContextService = new WorkspaceService({ userSettingsPath: environmentService.appSettingsPath, configurationCache: new ConfigurationCache(environmentService) }, new HashService(), new RemoteAgentService({}, environmentService, new RemoteAuthorityResolverService())); + workspaceContextService = new WorkspaceService({ userSettingsResource: URI.file(environmentService.appSettingsPath), configurationCache: new ConfigurationCache(environmentService) }, new ConfigurationFileService(), new HashService(), new RemoteAgentService({}, environmentService, new RemoteAuthorityResolverService())); return (workspaceContextService).initialize(convertToWorkspacePayload(URI.file(folderDir))); }); }); @@ -164,7 +164,7 @@ suite('WorkspaceContextService - Workspace', () => { const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json')); const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {}); instantiationService.stub(IRemoteAgentService, remoteAgentService); - const workspaceService = new WorkspaceService({ userSettingsPath: environmentService.appSettingsPath, configurationCache: new ConfigurationCache(environmentService) }, new HashService(), remoteAgentService); + const workspaceService = new WorkspaceService({ userSettingsResource: URI.file(environmentService.appSettingsPath), configurationCache: new ConfigurationCache(environmentService) }, new ConfigurationFileService(), new HashService(), remoteAgentService); instantiationService.stub(IWorkspaceContextService, workspaceService); instantiationService.stub(IConfigurationService, workspaceService); @@ -220,7 +220,7 @@ suite('WorkspaceContextService - Workspace Editing', () => { const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json')); const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {}); instantiationService.stub(IRemoteAgentService, remoteAgentService); - const workspaceService = new WorkspaceService({ userSettingsPath: environmentService.appSettingsPath, configurationCache: new ConfigurationCache(environmentService) }, new HashService(), remoteAgentService); + const workspaceService = new WorkspaceService({ userSettingsResource: URI.file(environmentService.appSettingsPath), configurationCache: new ConfigurationCache(environmentService) }, new ConfigurationFileService(), new HashService(), remoteAgentService); instantiationService.stub(IWorkspaceContextService, workspaceService); instantiationService.stub(IConfigurationService, workspaceService); @@ -486,7 +486,7 @@ suite('WorkspaceService - Initialization', () => { const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {}); instantiationService.stub(IRemoteAgentService, remoteAgentService); - const workspaceService = new WorkspaceService({ userSettingsPath: environmentService.appSettingsPath, configurationCache: new ConfigurationCache(environmentService) }, new HashService(), remoteAgentService); + const workspaceService = new WorkspaceService({ userSettingsResource: URI.file(environmentService.appSettingsPath), configurationCache: new ConfigurationCache(environmentService) }, new ConfigurationFileService(), new HashService(), remoteAgentService); instantiationService.stub(IWorkspaceContextService, workspaceService); instantiationService.stub(IConfigurationService, workspaceService); instantiationService.stub(IEnvironmentService, environmentService); @@ -750,7 +750,7 @@ suite('WorkspaceConfigurationService - Folder', () => { const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {}); instantiationService.stub(IRemoteAgentService, remoteAgentService); - const workspaceService = new WorkspaceService({ userSettingsPath: environmentService.appSettingsPath, configurationCache: new ConfigurationCache(environmentService) }, new HashService(), remoteAgentService); + const workspaceService = new WorkspaceService({ userSettingsResource: URI.file(environmentService.appSettingsPath), configurationCache: new ConfigurationCache(environmentService) }, new ConfigurationFileService(), new HashService(), remoteAgentService); instantiationService.stub(IWorkspaceContextService, workspaceService); instantiationService.stub(IConfigurationService, workspaceService); instantiationService.stub(IEnvironmentService, environmentService); @@ -1047,7 +1047,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => { environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json')); const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {}); instantiationService.stub(IRemoteAgentService, remoteAgentService); - const workspaceService = new WorkspaceService({ userSettingsPath: environmentService.appSettingsPath, configurationCache: new ConfigurationCache(environmentService) }, new HashService(), remoteAgentService); + const workspaceService = new WorkspaceService({ userSettingsResource: URI.file(environmentService.appSettingsPath), configurationCache: new ConfigurationCache(environmentService) }, new ConfigurationFileService(), new HashService(), remoteAgentService); instantiationService.stub(IWorkspaceContextService, workspaceService); instantiationService.stub(IConfigurationService, workspaceService); diff --git a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts b/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts similarity index 99% rename from src/vs/workbench/services/workspace/node/workspaceEditingService.ts rename to src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts index 33a388b14f164ec4dc305e83695345aaf0c2f972..e9745ea3398a4728c4ae1619751f1a60697257ed 100644 --- a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts +++ b/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts @@ -10,7 +10,7 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/ import { IWindowService, MessageBoxOptions, IWindowsService } from 'vs/platform/windows/common/windows'; import { IJSONEditingService, JSONEditingError, JSONEditingErrorCode } from 'vs/workbench/services/configuration/common/jsonEditing'; import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspacesService, rewriteWorkspaceFileForNewLocation, WORKSPACE_FILTER } from 'vs/platform/workspaces/common/workspaces'; -import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService'; +import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { StorageService } from 'vs/platform/storage/node/storageService'; import { ConfigurationScope, IConfigurationRegistry, Extensions as ConfigurationExtensions, IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry'; diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadConfiguration.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadConfiguration.test.ts index 8db57b2d13460c495d7f108081066c66a0628b13..c1132e647138b1546e2da021d39130a90cb26cce 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadConfiguration.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadConfiguration.test.ts @@ -13,7 +13,7 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/ import { MainThreadConfiguration } from 'vs/workbench/api/browser/mainThreadConfiguration'; import { SingleProxyRPCProtocol } from './testRPCProtocol'; import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration'; -import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService'; +import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; suite('MainThreadConfiguration', function () { diff --git a/src/vs/workbench/workbench.main.ts b/src/vs/workbench/workbench.main.ts index 6804d9c7ca7ca9f6bb7d469d5f1af7b52dc7dfd3..e8fa196bc864b10ab23edcbdb8fa5985fab90a21 100644 --- a/src/vs/workbench/workbench.main.ts +++ b/src/vs/workbench/workbench.main.ts @@ -96,7 +96,7 @@ import 'vs/workbench/services/integrity/node/integrityService'; import 'vs/workbench/services/keybinding/common/keybindingEditing'; import 'vs/workbench/services/textMate/electron-browser/textMateService'; import 'vs/workbench/services/configurationResolver/browser/configurationResolverService'; -import 'vs/workbench/services/workspace/node/workspaceEditingService'; +import 'vs/workbench/services/workspace/electron-browser/workspaceEditingService'; import 'vs/workbench/services/extensions/common/inactiveExtensionUrlHandler'; import 'vs/workbench/services/decorations/browser/decorationsService'; import 'vs/workbench/services/search/node/searchService'; diff --git a/src/vs/workbench/workbench.nodeless.main.ts b/src/vs/workbench/workbench.nodeless.main.ts index 239a91f3648be6f886832968c02370786d7696c0..e37ecfd6fb4d0b50a40676ae7d7024a905b5f57c 100644 --- a/src/vs/workbench/workbench.nodeless.main.ts +++ b/src/vs/workbench/workbench.nodeless.main.ts @@ -106,7 +106,7 @@ import 'vs/workbench/services/keybinding/common/keybindingEditing'; import 'vs/workbench/services/hash/common/hashService'; // import 'vs/workbench/services/textMate/electron-browser/textMateService'; import 'vs/workbench/services/configurationResolver/browser/configurationResolverService'; -// import 'vs/workbench/services/workspace/node/workspaceEditingService'; +// import 'vs/workbench/services/workspace/electron-browser/workspaceEditingService'; // import 'vs/workbench/services/extensions/electron-browser/inactiveExtensionUrlHandler'; import 'vs/workbench/services/decorations/browser/decorationsService'; // import 'vs/workbench/services/search/node/searchService';