@@ -97,63 +97,12 @@ import {IUntitledEditorService, UntitledEditorService} from 'vs/workbench/servic
9797import { CrashReporter } from 'vs/workbench/electron-browser/crashReporter' ;
9898import { IThemeService , DEFAULT_THEME_ID } from 'vs/workbench/services/themes/common/themeService' ;
9999import { ThemeService } from 'vs/workbench/services/themes/node/themeService' ;
100- import { IServiceCtor , isServiceEvent } from 'vs/base/common/service' ;
100+ import { IServiceCtor , isServiceEvent , getService } from 'vs/base/common/service' ;
101101import { connect , Client } from 'vs/base/node/service.net' ;
102102import { IExtensionsService } from 'vs/workbench/parts/extensions/common/extensions' ;
103103import { ExtensionsService } from 'vs/workbench/parts/extensions/node/extensionsService' ;
104104import { ReloadWindowAction } from 'vs/workbench/electron-browser/actions' ;
105105
106- /**
107- * This ugly code is needed because at the point when we need shared services
108- * in the instantiation service, the connection to the shared process is not yet
109- * completed. This create a delayed service wrapper that waits on that connection
110- * and then relays all requests to the shared services.
111- *
112- * TODO@Joao remove
113- */
114- export function getDelayedService < TService > ( clientPromise : TPromise < Client > , serviceName : string , serviceCtor : IServiceCtor < TService > ) : TService {
115- let _servicePromise : TPromise < TService > ;
116- let servicePromise = ( ) => {
117- if ( ! _servicePromise ) {
118- _servicePromise = clientPromise . then ( client => client . getService ( serviceName , serviceCtor ) ) ;
119- }
120- return _servicePromise ;
121- } ;
122-
123- return Object . keys ( serviceCtor . prototype )
124- . filter ( key => key !== 'constructor' )
125- . reduce ( ( result , key ) => {
126- if ( isServiceEvent ( serviceCtor . prototype [ key ] ) ) {
127- let promise : TPromise < void > ;
128- let disposable : IDisposable ;
129-
130- const emitter = new Emitter < any > ( {
131- onFirstListenerAdd : ( ) => {
132- promise = servicePromise ( ) . then ( service => {
133- disposable = service [ key ] ( e => emitter . fire ( e ) ) ;
134- } ) ;
135- } ,
136- onLastListenerRemove : ( ) => {
137- if ( disposable ) {
138- disposable . dispose ( ) ;
139- disposable = null ;
140- }
141- promise . cancel ( ) ;
142- promise = null ;
143- }
144- } ) ;
145-
146- return objects . assign ( result , { [ key ] : emitter . event } ) ;
147- }
148-
149- return objects . assign ( result , {
150- [ key ] : ( ...args ) => {
151- return servicePromise ( ) . then ( service => service [ key ] ( ...args ) ) ;
152- }
153- } ) ;
154- } , { } as TService ) ;
155- }
156-
157106/**
158107 * The Monaco Workbench Shell contains the Monaco workbench with a rich header containing navigation and the activity bar.
159108 * With the Shell being the top level element in the page, it is also responsible for driving the layouting.
@@ -220,7 +169,7 @@ export class WorkbenchShell {
220169 } ) ;
221170 } , errors . onUnexpectedError ) ;
222171
223- instantiationService . addSingleton ( IExtensionsService , getDelayedService < IExtensionsService > ( sharedProcessClientPromise , 'ExtensionService' , ExtensionsService ) ) ;
172+ instantiationService . addSingleton ( IExtensionsService , getService < IExtensionsService > ( sharedProcessClientPromise , 'ExtensionService' , ExtensionsService ) ) ;
224173
225174 // Workbench
226175 this . workbench = new Workbench ( workbenchContainer . getHTMLElement ( ) , this . workspace , this . configuration , this . options , instantiationService ) ;
0 commit comments