diff --git a/src/vs/editor/browser/standalone/standaloneServices.ts b/src/vs/editor/browser/standalone/standaloneServices.ts index 34eb69a8fa7..d641a57f51d 100644 --- a/src/vs/editor/browser/standalone/standaloneServices.ts +++ b/src/vs/editor/browser/standalone/standaloneServices.ts @@ -28,8 +28,7 @@ import {IMessageService} from 'vs/platform/message/common/message'; import {IProgressService} from 'vs/platform/progress/common/progress'; import {IStorageService, NullStorageService} from 'vs/platform/storage/common/storage'; import {ITelemetryService, NullTelemetryService} from 'vs/platform/telemetry/common/telemetry'; -import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspaceContextService'; -import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; +import {IWorkspaceContextService, BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService'; import {EditorWorkerServiceImpl} from 'vs/editor/common/services/editorWorkerServiceImpl'; @@ -244,7 +243,7 @@ export function getOrCreateStaticServices(services?: IEditorOverrideServices): I name: null, uid: null, mtime: null - }, {}); + }); serviceCollection.set(IWorkspaceContextService, contextService); let telemetryService = services.telemetryService || NullTelemetryService; diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 68ac8d73ead..a47d31d6777 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -6,6 +6,7 @@ import URI from 'vs/base/common/uri'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; +import paths = require('vs/base/common/paths'); export const IWorkspaceContextService = createDecorator('contextService'); @@ -18,11 +19,6 @@ export interface IWorkspaceContextService { */ getWorkspace(): IWorkspace; - /** - * Provides access to the options object the platform is running with. - */ - getOptions(): any; - /** * Returns iff the provided resource is inside the workspace or not. */ @@ -70,4 +66,47 @@ export interface IWorkspace { * is just derived from the workspace name. */ uid?: number; +} + +/** + * Simple IWorkspaceContextService implementation to allow sharing of this service implementation + * between different layers of the platform. + */ +export class BaseWorkspaceContextService implements IWorkspaceContextService { + + public _serviceBrand: any; + + private workspace: IWorkspace; + + constructor(workspace: IWorkspace) { + this.workspace = workspace; + } + + public getWorkspace(): IWorkspace { + return this.workspace; + } + + public isInsideWorkspace(resource: URI): boolean { + if (resource && this.workspace) { + return paths.isEqualOrParent(resource.fsPath, this.workspace.resource.fsPath); + } + + return false; + } + + public toWorkspaceRelativePath(resource: URI): string { + if (this.isInsideWorkspace(resource)) { + return paths.normalize(paths.relative(this.workspace.resource.fsPath, resource.fsPath)); + } + + return null; + } + + public toResource(workspaceRelativePath: string): URI { + if (typeof workspaceRelativePath === 'string' && this.workspace) { + return URI.file(paths.join(this.workspace.resource.fsPath, workspaceRelativePath)); + } + + return null; + } } \ No newline at end of file diff --git a/src/vs/platform/workspace/common/workspaceContextService.ts b/src/vs/platform/workspace/common/workspaceContextService.ts deleted file mode 100644 index 3d78bc4cdeb..00000000000 --- a/src/vs/platform/workspace/common/workspaceContextService.ts +++ /dev/null @@ -1,59 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -'use strict'; - -import URI from 'vs/base/common/uri'; -import paths = require('vs/base/common/paths'); -import {IWorkspaceContextService, IWorkspace} from 'vs/platform/workspace/common/workspace'; - -/** - * Simple IWorkspaceContextService implementation to allow sharing of this service implementation - * between different layers of the platform. - */ -export class BaseWorkspaceContextService implements IWorkspaceContextService { - - public _serviceBrand: any; - - protected options: any; - - private workspace: IWorkspace; - - constructor(workspace: IWorkspace, options: any = {}) { - this.workspace = workspace; - this.options = options; - } - - public getWorkspace(): IWorkspace { - return this.workspace; - } - - public getOptions(): any { - return this.options; - } - - public isInsideWorkspace(resource: URI): boolean { - if (resource && this.workspace) { - return paths.isEqualOrParent(resource.fsPath, this.workspace.resource.fsPath); - } - - return false; - } - - public toWorkspaceRelativePath(resource: URI): string { - if (this.isInsideWorkspace(resource)) { - return paths.normalize(paths.relative(this.workspace.resource.fsPath, resource.fsPath)); - } - - return null; - } - - public toResource(workspaceRelativePath: string): URI { - if (typeof workspaceRelativePath === 'string' && this.workspace) { - return URI.file(paths.join(this.workspace.resource.fsPath, workspaceRelativePath)); - } - - return null; - } -} \ No newline at end of file diff --git a/src/vs/workbench/electron-browser/actions.ts b/src/vs/workbench/electron-browser/actions.ts index 8e0feb63e8c..6dfd6c58c81 100644 --- a/src/vs/workbench/electron-browser/actions.ts +++ b/src/vs/workbench/electron-browser/actions.ts @@ -18,7 +18,7 @@ import {DiffEditorInput} from 'vs/workbench/common/editor/diffEditorInput'; import nls = require('vs/nls'); import {IMessageService, Severity} from 'vs/platform/message/common/message'; import {IWindowConfiguration} from 'vs/workbench/electron-browser/window'; -import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; +import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {IEnvironmentService} from 'vs/platform/environment/common/environment'; import {IQuickOpenService, IPickOpenEntry} from 'vs/workbench/services/quickopen/common/quickOpenService'; import {KeyMod} from 'vs/base/common/keyCodes'; diff --git a/src/vs/workbench/node/extensionHostMain.ts b/src/vs/workbench/node/extensionHostMain.ts index beb5815ef9a..dbd76b6305c 100644 --- a/src/vs/workbench/node/extensionHostMain.ts +++ b/src/vs/workbench/node/extensionHostMain.ts @@ -21,9 +21,8 @@ import {IMainProcessExtHostIPC} from 'vs/platform/extensions/common/ipcRemoteCom import {ExtHostExtensionService} from 'vs/workbench/api/node/extHostExtensionService'; import {ExtHostThreadService} from 'vs/workbench/services/thread/common/extHostThreadService'; import {RemoteTelemetryService} from 'vs/workbench/api/node/extHostTelemetry'; -import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspaceContextService'; import {ExtensionScanner, MessagesCollector} from 'vs/workbench/node/extensionPoints'; -import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; +import {IWorkspaceContextService, BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {Client} from 'vs/base/parts/ipc/node/ipc.net'; import {IExtensionManagementChannel, ExtensionManagementChannelClient} from 'vs/platform/extensionManagement/common/extensionManagementIpc'; @@ -73,7 +72,7 @@ export class ExtensionHostMain { this._environment = initData.environment; - this._contextService = new BaseWorkspaceContextService(initData.contextService.workspace, initData.contextService.options); + this._contextService = new BaseWorkspaceContextService(initData.contextService.workspace); const workspaceStoragePath = this._getOrCreateWorkspaceStoragePath(); const threadService = new ExtHostThreadService(remoteCom); diff --git a/src/vs/workbench/services/configuration/node/configurationService.ts b/src/vs/workbench/services/configuration/node/configurationService.ts index 9e46af9df9a..67e4f038863 100644 --- a/src/vs/workbench/services/configuration/node/configurationService.ts +++ b/src/vs/workbench/services/configuration/node/configurationService.ts @@ -28,6 +28,8 @@ export class ConfigurationService extends CommonConfigurationService { public _serviceBrand: any; + protected contextService: IWorkspaceContextService; + private toDispose: IDisposable; constructor( diff --git a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts index 9c4654671ed..862700dc099 100644 --- a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts +++ b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts @@ -21,7 +21,7 @@ import {IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; import {IKeybindingRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {Registry} from 'vs/platform/platform'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; -import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; +import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {EventType, OptionsChangeEvent} from 'vs/workbench/common/events'; import {getNativeLabelProvider, getNativeAriaLabelProvider} from 'vs/workbench/services/keybinding/electron-browser/nativeKeymap'; import {IMessageService} from 'vs/platform/message/common/message'; diff --git a/src/vs/workbench/services/thread/electron-browser/threadService.ts b/src/vs/workbench/services/thread/electron-browser/threadService.ts index 8f67b85c721..3e1aa9bb0a0 100644 --- a/src/vs/workbench/services/thread/electron-browser/threadService.ts +++ b/src/vs/workbench/services/thread/electron-browser/threadService.ts @@ -176,9 +176,8 @@ class ExtensionHostProcessManager { extensionTestsPath: this.environmentService.extensionTestsPath }, contextService: { - workspace: this.contextService.getWorkspace(), - options: this.contextService.getOptions() - }, + workspace: this.contextService.getWorkspace() + } }); this.extensionHostProcessHandle.send(initPayload); diff --git a/src/vs/workbench/services/workspace/common/contextService.ts b/src/vs/workbench/services/workspace/common/contextService.ts index ddf409f3ca3..23665598e6a 100644 --- a/src/vs/workbench/services/workspace/common/contextService.ts +++ b/src/vs/workbench/services/workspace/common/contextService.ts @@ -8,8 +8,7 @@ import {IOptions} from 'vs/workbench/common/options'; import {EventType, OptionsChangeEvent} from 'vs/workbench/common/events'; import {IEventService} from 'vs/platform/event/common/event'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; -import {IWorkspace, IWorkspaceContextService as IBaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; -import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspaceContextService'; +import {IWorkspace, IWorkspaceContextService as IBaseWorkspaceContextService, BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; export const IWorkspaceContextService = createDecorator('contextService'); @@ -28,14 +27,19 @@ export interface IWorkspaceContextService extends IBaseWorkspaceContextService { } export class WorkspaceContextService extends BaseWorkspaceContextService implements IWorkspaceContextService { + public _serviceBrand: any; constructor( private eventService: IEventService, workspace: IWorkspace, - options: any = {} + private options: IOptions ) { - super(workspace, options); + super(workspace); + } + + public getOptions(): IOptions { + return this.options; } public updateOptions(key: string, value: any): void { diff --git a/src/vs/workbench/test/browser/part.test.ts b/src/vs/workbench/test/browser/part.test.ts index 103da74e02b..702a525415c 100644 --- a/src/vs/workbench/test/browser/part.test.ts +++ b/src/vs/workbench/test/browser/part.test.ts @@ -10,8 +10,7 @@ import {Build, Builder} from 'vs/base/browser/builder'; import {Part} from 'vs/workbench/browser/part'; import * as Types from 'vs/base/common/types'; import * as TestUtils from 'vs/test/utils/servicesTestUtils'; -import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspaceContextService'; -import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; +import {IWorkspaceContextService, BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {IStorageService} from 'vs/platform/storage/common/storage'; import {Storage, InMemoryLocalStorage} from 'vs/workbench/common/storage'; @@ -105,7 +104,7 @@ suite('Workbench Part', () => { fixture = document.createElement('div'); fixture.id = fixtureId; document.body.appendChild(fixture); - context = new BaseWorkspaceContextService(TestUtils.TestWorkspace, null); + context = new BaseWorkspaceContextService(TestUtils.TestWorkspace); storage = new Storage(new InMemoryLocalStorage(), null, context); }); diff --git a/src/vs/workbench/test/browser/parts/quickOpen/quickopen.perf.test.ts b/src/vs/workbench/test/browser/parts/quickOpen/quickopen.perf.test.ts index ef668672ad1..9843a9c0476 100644 --- a/src/vs/workbench/test/browser/parts/quickOpen/quickopen.perf.test.ts +++ b/src/vs/workbench/test/browser/parts/quickOpen/quickopen.perf.test.ts @@ -7,7 +7,7 @@ import 'vs/workbench/parts/search/browser/search.contribution'; // load contributions import * as assert from 'assert'; -import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspaceContextService'; +import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {createSyncDescriptor} from 'vs/platform/instantiation/common/descriptors'; import {ensureStaticPlatformServices, IEditorOverrideServices} from 'vs/editor/browser/standalone/standaloneServices'; import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService'; diff --git a/src/vs/workbench/test/common/memento.test.ts b/src/vs/workbench/test/common/memento.test.ts index dc32b740851..26f480e0880 100644 --- a/src/vs/workbench/test/common/memento.test.ts +++ b/src/vs/workbench/test/common/memento.test.ts @@ -6,7 +6,7 @@ 'use strict'; import * as assert from 'assert'; -import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspaceContextService'; +import {BaseWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {StorageScope} from 'vs/platform/storage/common/storage'; import * as TestUtils from 'vs/test/utils/servicesTestUtils'; import {Memento, Scope} from 'vs/workbench/common/memento'; @@ -17,7 +17,7 @@ suite('Workbench Memento', () => { let storage; setup(() => { - context = new BaseWorkspaceContextService(TestUtils.TestWorkspace, null); + context = new BaseWorkspaceContextService(TestUtils.TestWorkspace); storage = new Storage(new InMemoryLocalStorage(), null, context); });