提交 66bd1bce 编写于 作者: B Benjamin Pasero

debt - get rid of Shell

上级 0d50120c
......@@ -5,7 +5,8 @@
import * as nls from 'vs/nls';
import * as perf from 'vs/base/common/performance';
import { Shell } from 'vs/workbench/electron-browser/shell';
import { Workbench } from 'vs/workbench/electron-browser/workbench';
import { ElectronWindow } from 'vs/workbench/electron-browser/window';
import * as browser from 'vs/base/browser/browser';
import { domContentLoaded } from 'vs/base/browser/dom';
import { onUnexpectedError } from 'vs/base/common/errors';
......@@ -47,6 +48,10 @@ import { createHash } from 'crypto';
import { IdleValue } from 'vs/base/common/async';
import { setGlobalLeakWarningThreshold } from 'vs/base/common/event';
import { GlobalStorageDatabaseChannelClient } from 'vs/platform/storage/node/storageIpc';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
gracefulFs.gracefulify(fs); // enable gracefulFs
......@@ -126,20 +131,35 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
const workspaceService = services[0];
const storageService = services[1];
// Core services
const serviceCollection = new ServiceCollection();
serviceCollection.set(IWorkspaceContextService, workspaceService);
serviceCollection.set(IConfigurationService, workspaceService);
serviceCollection.set(IEnvironmentService, environmentService);
serviceCollection.set(ILogService, logService);
serviceCollection.set(IStorageService, storageService);
mainServices.forEach((serviceIdentifier, serviceInstance) => {
serviceCollection.set(serviceIdentifier, serviceInstance);
});
const instantiationService = new InstantiationService(serviceCollection, true);
return domContentLoaded().then(() => {
perf.mark('willStartWorkbench');
// Create Shell
const shell = new Shell(document.body, {
contextService: workspaceService,
configurationService: workspaceService,
environmentService,
logService,
storageService
}, mainServices, mainProcessClient, configuration);
// Open Shell
shell.open();
// Startup Workbench
const workbench = instantiationService.createInstance(
Workbench,
document.body,
configuration,
serviceCollection,
mainProcessClient
);
workbench.startup();
// Window
workbench.getInstantiationService().createInstance(ElectronWindow);
// Inform user about loading issues from the loader
(<any>self).require.config({
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Disposable } from 'vs/base/common/lifecycle';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { ILogService } from 'vs/platform/log/common/log';
import { IStorageService } from 'vs/platform/storage/common/storage';
// import@node
import { InstantiationService } from 'vs/platform/instantiation/node/instantiationService';
import { IPCClient } from 'vs/base/parts/ipc/node/ipc';
// import@electron-browser
import { Workbench } from 'vs/workbench/electron-browser/workbench';
import { ElectronWindow } from 'vs/workbench/electron-browser/window';
/**
* Services that we require for the Shell
*/
export interface ICoreServices {
contextService: IWorkspaceContextService;
configurationService: IConfigurationService;
environmentService: IEnvironmentService;
logService: ILogService;
storageService: IStorageService;
}
/**
* The workbench shell contains the workbench with a rich header containing navigation and the activity bar.
* With the Shell being the top level element in the page, it is also responsible for driving the layouting.
*/
export class Shell extends Disposable {
private storageService: IStorageService;
private environmentService: IEnvironmentService;
private logService: ILogService;
private configurationService: IConfigurationService;
private contextService: IWorkspaceContextService;
private container: HTMLElement;
private mainProcessClient: IPCClient;
private mainProcessServices: ServiceCollection;
private configuration: IWindowConfiguration;
constructor(
container: HTMLElement,
coreServices: ICoreServices,
mainProcessServices: ServiceCollection,
mainProcessClient: IPCClient,
configuration: IWindowConfiguration
) {
super();
this.container = container;
this.mainProcessClient = this._register(mainProcessClient);
this.configuration = configuration;
this.contextService = coreServices.contextService;
this.configurationService = coreServices.configurationService;
this.environmentService = coreServices.environmentService;
this.logService = coreServices.logService;
this.storageService = coreServices.storageService;
this.mainProcessServices = mainProcessServices;
}
open(): void {
// Instantiation service with services
const serviceCollection = this.initServiceCollection();
const instantiationService = new InstantiationService(serviceCollection, true);
// Workbench
const workbench = this._register(instantiationService.createInstance(
Workbench,
this.container,
this.configuration,
serviceCollection,
this.mainProcessClient
));
workbench.startup();
// Window
workbench.getInstantiationService().createInstance(ElectronWindow);
}
private initServiceCollection(): ServiceCollection {
const serviceCollection = new ServiceCollection();
serviceCollection.set(IWorkspaceContextService, this.contextService);
serviceCollection.set(IConfigurationService, this.configurationService);
serviceCollection.set(IEnvironmentService, this.environmentService);
serviceCollection.set(ILogService, this._register(this.logService));
serviceCollection.set(IStorageService, this.storageService);
this.mainProcessServices.forEach((serviceIdentifier, serviceInstance) => {
serviceCollection.set(serviceIdentifier, serviceInstance);
});
return serviceCollection;
}
}
......@@ -351,6 +351,10 @@ export class Workbench extends Disposable implements IPartService {
(configuration.filesToOpen && configuration.filesToOpen.length > 0) ||
(configuration.filesToDiff && configuration.filesToDiff.length > 0);
// TODO@Ben debt
this._register(mainProcessClient);
this._register(logService);
this.registerErrorHandler();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册