From 16635b8086ec21e2b52aaa96bfa1f42e850be278 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 8 Mar 2019 12:47:23 +0100 Subject: [PATCH] debt - move out more things from workbench --- .../electron-browser/lifecycleService.ts | 2 - src/vs/workbench/electron-browser/main.ts | 6 ++- .../workbench/electron-browser/workbench.ts | 41 ++++--------------- .../dialogs/electron-browser/dialogService.ts | 9 +++- .../remoteAgentServiceImpl.ts | 19 ++++++++- 5 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts b/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts index 7e74fc62cde..7d55e6eb062 100644 --- a/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts +++ b/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts @@ -52,8 +52,6 @@ export class LifecycleService extends Disposable implements ILifecycleService { this._startupKind = this.resolveStartupKind(); this.registerListeners(); - - this._phase = LifecyclePhase.Ready; } private resolveStartupKind(): StartupKind { diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 258e2733a3f..ece9e42d4cf 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -20,7 +20,8 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle import { stat } from 'vs/base/node/pfs'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; -import { IWindowConfiguration, IWindowsService } from 'vs/platform/windows/common/windows'; +import { IWindowConfiguration, IWindowsService, IWindowService } from 'vs/platform/windows/common/windows'; +import { WindowService } from 'vs/platform/windows/electron-browser/windowService'; import { WindowsChannelClient } from 'vs/platform/windows/node/windowsIpc'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { Client as ElectronIPCClient } from 'vs/base/parts/ipc/electron-browser/ipc.electron-browser'; @@ -170,6 +171,9 @@ class CodeRendererMain extends Disposable { const windowsChannel = electronMainClient.getChannel('windows'); serviceCollection.set(IWindowsService, new WindowsChannelClient(windowsChannel)); + // Window + serviceCollection.set(IWindowService, new SyncDescriptor(WindowService, [this.configuration])); + // Update Service const updateChannel = electronMainClient.getChannel('update'); serviceCollection.set(IUpdateService, new SyncDescriptor(UpdateChannelClient, [updateChannel])); diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 2efbb9edbbf..23463182bfd 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -35,7 +35,6 @@ import { IFileService } from 'vs/platform/files/common/files'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { ITitleService } from 'vs/workbench/services/title/common/titleService'; import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; -import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { LifecyclePhase, StartupKind, ILifecycleService, WillShutdownEvent } from 'vs/platform/lifecycle/common/lifecycle'; import { IWindowService, IWindowConfiguration, IPath, MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows'; @@ -63,16 +62,6 @@ import { Part } from 'vs/workbench/browser/part'; import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar'; import { IActivityBarService } from 'vs/workbench/services/activityBar/browser/activityBarService'; -// import@node -import { DialogChannel } from 'vs/platform/dialogs/node/dialogIpc'; -import { IRemoteAgentService } from 'vs/workbench/services/remote/node/remoteAgentService'; -import { DownloadServiceChannel } from 'vs/platform/download/node/downloadIpc'; -import { LogLevelSetterChannel } from 'vs/platform/log/node/logIpc'; -import { ISharedProcessService } from 'vs/platform/sharedProcess/node/sharedProcessService'; - -// import@electron-browser -import { WindowService } from 'vs/platform/windows/electron-browser/windowService'; - enum Settings { MENUBAR_VISIBLE = 'window.menuBarVisibility', ACTIVITYBAR_VISIBLE = 'workbench.activityBar.visible', @@ -269,37 +258,23 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService { private initServices(serviceCollection: ServiceCollection): void { - // Parts - serviceCollection.set(IWorkbenchLayoutService, this); // TODO@Ben use SyncDescriptor - - // Window - serviceCollection.set(IWindowService, new SyncDescriptor(WindowService, [this.configuration])); + // Layout Service + serviceCollection.set(IWorkbenchLayoutService, this); - // Contributed services + // All Contributed Services const contributedServices = getServices(); for (let contributedService of contributedServices) { serviceCollection.set(contributedService.id, contributedService.descriptor); } - // TODO@Steven this should move somewhere else + // Wrap up this.instantiationService.invokeFunction(accessor => { - const sharedProcessService = accessor.get(ISharedProcessService); - sharedProcessService.registerChannel('dialog', this.instantiationService.createInstance(DialogChannel)); - }); + // Signal to lifecycle that services are set + const lifecycleService = accessor.get(ILifecycleService); + lifecycleService.phase = LifecyclePhase.Ready; - // TODO@Alex TODO@Sandeep this should move somewhere else - this.instantiationService.invokeFunction(accessor => { - const remoteAgentConnection = accessor.get(IRemoteAgentService).getConnection(); - if (remoteAgentConnection) { - remoteAgentConnection.registerChannel('dialog', this.instantiationService.createInstance(DialogChannel)); - remoteAgentConnection.registerChannel('download', new DownloadServiceChannel()); - remoteAgentConnection.registerChannel('loglevel', new LogLevelSetterChannel(this.logService)); - } - }); - - // TODO@Sandeep TODO@Martin debt around cyclic dependencies - this.instantiationService.invokeFunction(accessor => { + // TODO@Sandeep TODO@Martin debt around cyclic dependencies const fileService = accessor.get(IFileService); const instantiationService = accessor.get(IInstantiationService); const configurationService = accessor.get(IConfigurationService) as any; diff --git a/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts b/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts index bf501e161f9..5048e7869dd 100644 --- a/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts +++ b/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts @@ -23,6 +23,8 @@ import { WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces'; import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { ISharedProcessService } from 'vs/platform/sharedProcess/node/sharedProcessService'; +import { DialogChannel } from 'vs/platform/dialogs/node/dialogIpc'; interface IMassagedMessageBoxOptions { @@ -45,8 +47,11 @@ export class DialogService implements IDialogService { constructor( @IWindowService private readonly windowService: IWindowService, - @ILogService private readonly logService: ILogService - ) { } + @ILogService private readonly logService: ILogService, + @ISharedProcessService sharedProcessService: ISharedProcessService + ) { + sharedProcessService.registerChannel('dialog', new DialogChannel(this)); + } confirm(confirmation: IConfirmation): Promise { this.logService.trace('DialogService#confirm', confirmation.message); diff --git a/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts b/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts index 89f51f2ab3a..d2c58a65c2a 100644 --- a/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts +++ b/src/vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl.ts @@ -15,6 +15,12 @@ import { RemoteExtensionEnvironmentChannelClient } from 'vs/workbench/services/r import { IRemoteAgentConnection, IRemoteAgentEnvironment, IRemoteAgentService } from 'vs/workbench/services/remote/node/remoteAgentService'; import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; +import { DialogChannel } from 'vs/platform/dialogs/node/dialogIpc'; +import { DownloadServiceChannel } from 'vs/platform/download/node/downloadIpc'; +import { LogLevelSetterChannel } from 'vs/platform/log/node/logIpc'; +import { ILogService } from 'vs/platform/log/common/log'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; export class RemoteAgentService implements IRemoteAgentService { @@ -26,11 +32,20 @@ export class RemoteAgentService implements IRemoteAgentService { @IWindowService windowService: IWindowService, @INotificationService notificationService: INotificationService, @IEnvironmentService environmentService: IEnvironmentService, - @IRemoteAuthorityResolverService remoteAuthorityResolverService: IRemoteAuthorityResolverService + @IRemoteAuthorityResolverService remoteAuthorityResolverService: IRemoteAuthorityResolverService, + @ILifecycleService lifecycleService: ILifecycleService, + @ILogService logService: ILogService, + @IInstantiationService instantiationService: IInstantiationService ) { const { remoteAuthority } = windowService.getConfiguration(); if (remoteAuthority) { - this._connection = new RemoteAgentConnection(remoteAuthority, notificationService, environmentService, remoteAuthorityResolverService); + const connection = this._connection = new RemoteAgentConnection(remoteAuthority, notificationService, environmentService, remoteAuthorityResolverService); + + lifecycleService.when(LifecyclePhase.Ready).then(() => { + connection.registerChannel('dialog', instantiationService.createInstance(DialogChannel)); + connection.registerChannel('download', new DownloadServiceChannel()); + connection.registerChannel('loglevel', new LogLevelSetterChannel(logService)); + }); } } -- GitLab