diff --git a/src/vs/platform/test/common/nullThreadService.ts b/src/vs/platform/test/common/nullThreadService.ts index fa6fc9415f5..b3f6fcb2a03 100644 --- a/src/vs/platform/test/common/nullThreadService.ts +++ b/src/vs/platform/test/common/nullThreadService.ts @@ -6,7 +6,8 @@ import winjs = require('vs/base/common/winjs.base'); import abstractThreadService = require('vs/platform/thread/common/abstractThreadService'); -import instantiationService = require('vs/platform/instantiation/common/instantiationService'); +import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService'; +import ServiceCollection from 'vs/platform/instantiation/common/serviceCollection'; import {SyncDescriptor0} from 'vs/platform/instantiation/common/descriptors'; import {IThreadService, IThreadServiceStatusListener, IThreadSynchronizableObject, ThreadAffinity} from 'vs/platform/thread/common/thread'; @@ -15,9 +16,7 @@ export class NullThreadService extends abstractThreadService.AbstractThreadServi constructor() { super(true); - this.setInstantiationService(instantiationService.createInstantiationService({ - threadService: this - })); + this.setInstantiationService(new InstantiationService(new ServiceCollection([IThreadService, this]))); } protected _doCreateInstance(params: any[]): any { diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 7f9076f90d5..ecb613917b7 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -67,8 +67,8 @@ import {MainThreadLanguageFeatures} from 'vs/workbench/api/node/extHostLanguageF import {IOptions} from 'vs/workbench/common/options'; import {IStorageService} from 'vs/platform/storage/common/storage'; import {MainThreadStorage} from 'vs/platform/storage/common/remotable.storage'; -import {IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import {createInstantiationService as createInstantiationService } from 'vs/platform/instantiation/common/instantiationService'; +import ServiceCollection from 'vs/platform/instantiation/common/serviceCollection'; +import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService'; import {IContextViewService, IContextMenuService} from 'vs/platform/contextview/browser/contextView'; import {IEventService} from 'vs/platform/event/common/event'; import {IFileService} from 'vs/platform/files/common/files'; @@ -159,7 +159,8 @@ export class WorkbenchShell { let workbenchContainer = $(parent).div(); // Instantiation service with services - let instantiationService = this.initInstantiationService(); + let serviceCollection = this.initServiceCollection(); + let instantiationService = new InstantiationService(serviceCollection); //crash reporting if (!!this.configuration.env.crashReporter) { @@ -177,7 +178,7 @@ export class WorkbenchShell { }); }, errors.onUnexpectedError); - instantiationService.addSingleton(IExtensionsService, getService(sharedProcessClientPromise, 'ExtensionService', ExtensionsService)); + serviceCollection.set(IExtensionsService, getService(sharedProcessClientPromise, 'ExtensionService', ExtensionsService)); // Workbench this.workbench = new Workbench(workbenchContainer.getHTMLElement(), this.workspace, this.configuration, this.options, instantiationService); @@ -235,7 +236,7 @@ export class WorkbenchShell { } } - private initInstantiationService(): IInstantiationService { + private initServiceCollection(): ServiceCollection { this.windowService = new WindowService(); let disableWorkspaceStorage = this.configuration.env.extensionTestsPath || (!this.workspace && !this.configuration.env.extensionDevelopmentPath); // without workspace or in any extension test, we use inMemory storage unless we develop an extension where we want to preserve state @@ -295,32 +296,31 @@ export class WorkbenchShell { let untitledEditorService = new UntitledEditorService(); this.themeService = new ThemeService(extensionService, this.windowService, this.storageService); - let result = createInstantiationService(); - result.addSingleton(ITelemetryService, this.telemetryService); - result.addSingleton(IEventService, this.eventService); - result.addSingleton(IRequestService, requestService); - result.addSingleton(IWorkspaceContextService, this.contextService); - result.addSingleton(IContextViewService, this.contextViewService); - result.addSingleton(IContextMenuService, new ContextMenuService(this.messageService, this.telemetryService, this.keybindingService)); - result.addSingleton(IMessageService, this.messageService); - result.addSingleton(IStorageService, this.storageService); - result.addSingleton(ILifecycleService, lifecycleService); - result.addSingleton(IThreadService, this.threadService); - result.addSingleton(IExtensionService, extensionService); - result.addSingleton(IModeService, modeService); - result.addSingleton(IFileService, fileService); - result.addSingleton(IUntitledEditorService, untitledEditorService); - result.addSingleton(ISearchService, new SearchService(modelService, untitledEditorService, this.contextService, this.configurationService)); - result.addSingleton(IWindowService, this.windowService); - result.addSingleton(IConfigurationService, this.configurationService); - result.addSingleton(IKeybindingService, this.keybindingService); - result.addSingleton(IMarkerService, markerService); - result.addSingleton(IModelService, modelService); - result.addSingleton(ICodeEditorService, new CodeEditorServiceImpl()); - result.addSingleton(IEditorWorkerService, editorWorkerService); - result.addSingleton(IThemeService, this.themeService); - result.addSingleton(IActionsService, new ActionsService(extensionService, this.keybindingService)); - + let result = new ServiceCollection(); + result.set(ITelemetryService, this.telemetryService); + result.set(IEventService, this.eventService); + result.set(IRequestService, requestService); + result.set(IWorkspaceContextService, this.contextService); + result.set(IContextViewService, this.contextViewService); + result.set(IContextMenuService, new ContextMenuService(this.messageService, this.telemetryService, this.keybindingService)); + result.set(IMessageService, this.messageService); + result.set(IStorageService, this.storageService); + result.set(ILifecycleService, lifecycleService); + result.set(IThreadService, this.threadService); + result.set(IExtensionService, extensionService); + result.set(IModeService, modeService); + result.set(IFileService, fileService); + result.set(IUntitledEditorService, untitledEditorService); + result.set(ISearchService, new SearchService(modelService, untitledEditorService, this.contextService, this.configurationService)); + result.set(IWindowService, this.windowService); + result.set(IConfigurationService, this.configurationService); + result.set(IKeybindingService, this.keybindingService); + result.set(IMarkerService, markerService); + result.set(IModelService, modelService); + result.set(ICodeEditorService, new CodeEditorServiceImpl()); + result.set(IEditorWorkerService, editorWorkerService); + result.set(IThemeService, this.themeService); + result.set(IActionsService, new ActionsService(extensionService, this.keybindingService)); return result; } diff --git a/src/vs/workbench/node/extensionHostMain.ts b/src/vs/workbench/node/extensionHostMain.ts index c0f3cf7a4dd..25bab90c0ff 100644 --- a/src/vs/workbench/node/extensionHostMain.ts +++ b/src/vs/workbench/node/extensionHostMain.ts @@ -18,8 +18,8 @@ import {ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegist import {ExtHostAPIImplementation} from 'vs/workbench/api/node/extHost.api.impl'; import {IMainProcessExtHostIPC} from 'vs/platform/extensions/common/ipcRemoteCom'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; -import {IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import InstantiationService = require('vs/platform/instantiation/common/instantiationService'); +import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; +import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService'; import ServiceCollection from 'vs/platform/instantiation/common/serviceCollection'; import {ExtHostExtensionService} from 'vs/platform/extensions/common/nativeExtensionService'; import {IThreadService} from 'vs/platform/thread/common/thread'; @@ -58,7 +58,7 @@ export function createServices(remoteCom: IMainProcessExtHostIPC, initData: IIni let contextService = new BaseWorkspaceContextService(initData.contextService.workspace, initData.contextService.configuration, initData.contextService.options); let threadService = new ExtHostThreadService(remoteCom); - threadService.setInstantiationService(InstantiationService.createInstantiationService(new ServiceCollection([IThreadService, threadService]))); + threadService.setInstantiationService(new InstantiationService(new ServiceCollection([IThreadService, threadService]))); let telemetryService = new RemoteTelemetryService('pluginHostTelemetry', threadService); let services = new ServiceCollection(); @@ -68,7 +68,7 @@ export function createServices(remoteCom: IMainProcessExtHostIPC, initData: IIni services.set(IExtensionService, new ExtHostExtensionService(threadService, telemetryService)); services.set(IExtensionsService, sharedProcessClient.getService('ExtensionService', ExtensionsService)); // Connect to shared process services - let instantiationService = InstantiationService.createInstantiationService(services); + let instantiationService = new InstantiationService(services); threadService.setInstantiationService(instantiationService); // Create the monaco API