Skip to content

Commit 66bd1bc

Browse files
author
Benjamin Pasero
committed
debt - get rid of Shell
1 parent 0d50120 commit 66bd1bc

3 files changed

Lines changed: 36 additions & 120 deletions

File tree

src/vs/workbench/electron-browser/main.ts

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import * as nls from 'vs/nls';
77
import * as perf from 'vs/base/common/performance';
8-
import { Shell } from 'vs/workbench/electron-browser/shell';
8+
import { Workbench } from 'vs/workbench/electron-browser/workbench';
9+
import { ElectronWindow } from 'vs/workbench/electron-browser/window';
910
import * as browser from 'vs/base/browser/browser';
1011
import { domContentLoaded } from 'vs/base/browser/dom';
1112
import { onUnexpectedError } from 'vs/base/common/errors';
@@ -47,6 +48,10 @@ import { createHash } from 'crypto';
4748
import { IdleValue } from 'vs/base/common/async';
4849
import { setGlobalLeakWarningThreshold } from 'vs/base/common/event';
4950
import { GlobalStorageDatabaseChannelClient } from 'vs/platform/storage/node/storageIpc';
51+
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
52+
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
53+
import { IStorageService } from 'vs/platform/storage/common/storage';
54+
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
5055

5156
gracefulFs.gracefulify(fs); // enable gracefulFs
5257

@@ -126,20 +131,35 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
126131
const workspaceService = services[0];
127132
const storageService = services[1];
128133

134+
// Core services
135+
const serviceCollection = new ServiceCollection();
136+
serviceCollection.set(IWorkspaceContextService, workspaceService);
137+
serviceCollection.set(IConfigurationService, workspaceService);
138+
serviceCollection.set(IEnvironmentService, environmentService);
139+
serviceCollection.set(ILogService, logService);
140+
serviceCollection.set(IStorageService, storageService);
141+
142+
mainServices.forEach((serviceIdentifier, serviceInstance) => {
143+
serviceCollection.set(serviceIdentifier, serviceInstance);
144+
});
145+
146+
const instantiationService = new InstantiationService(serviceCollection, true);
147+
129148
return domContentLoaded().then(() => {
130149
perf.mark('willStartWorkbench');
131150

132-
// Create Shell
133-
const shell = new Shell(document.body, {
134-
contextService: workspaceService,
135-
configurationService: workspaceService,
136-
environmentService,
137-
logService,
138-
storageService
139-
}, mainServices, mainProcessClient, configuration);
140-
141-
// Open Shell
142-
shell.open();
151+
// Startup Workbench
152+
const workbench = instantiationService.createInstance(
153+
Workbench,
154+
document.body,
155+
configuration,
156+
serviceCollection,
157+
mainProcessClient
158+
);
159+
workbench.startup();
160+
161+
// Window
162+
workbench.getInstantiationService().createInstance(ElectronWindow);
143163

144164
// Inform user about loading issues from the loader
145165
(<any>self).require.config({

src/vs/workbench/electron-browser/shell.ts

Lines changed: 0 additions & 108 deletions
This file was deleted.

src/vs/workbench/electron-browser/workbench.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ export class Workbench extends Disposable implements IPartService {
351351
(configuration.filesToOpen && configuration.filesToOpen.length > 0) ||
352352
(configuration.filesToDiff && configuration.filesToDiff.length > 0);
353353

354+
// TODO@Ben debt
355+
this._register(mainProcessClient);
356+
this._register(logService);
357+
354358
this.registerErrorHandler();
355359
}
356360

0 commit comments

Comments
 (0)