Skip to content

Commit

Permalink
debt - move out more things from workbench
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Mar 8, 2019
1 parent 3a93418 commit 16635b8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ export class LifecycleService extends Disposable implements ILifecycleService {
this._startupKind = this.resolveStartupKind();

this.registerListeners();

this._phase = LifecyclePhase.Ready;
}

private resolveStartupKind(): StartupKind {
Expand Down
6 changes: 5 additions & 1 deletion src/vs/workbench/electron-browser/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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]));
Expand Down
41 changes: 8 additions & 33 deletions src/vs/workbench/electron-browser/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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<IConfirmationResult> {
this.logService.trace('DialogService#confirm', confirmation.message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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));
});
}
}

Expand Down

0 comments on commit 16635b8

Please sign in to comment.