mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-29 00:00:29 -04:00
Merge from master
This commit is contained in:
39
src/vs/platform/instantiation/node/instantiationService.ts
Normal file
39
src/vs/platform/instantiation/node/instantiationService.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { IdleValue } from 'vs/base/common/async';
|
||||
import { InstantiationService as BaseInstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
// this is in the /node/-layer because it depends on Proxy which isn't available
|
||||
// in IE11 and therefore not in the /common/-layer
|
||||
|
||||
export class InstantiationService extends BaseInstantiationService {
|
||||
|
||||
createChild(services: ServiceCollection): IInstantiationService {
|
||||
return new InstantiationService(services, this._strict, this);
|
||||
}
|
||||
|
||||
protected _createServiceInstance<T>(ctor: any, args: any[] = [], supportsDelayedInstantiation: boolean, _trace): T {
|
||||
if (supportsDelayedInstantiation) {
|
||||
return InstantiationService._newIdleProxyService(() => super._createServiceInstance(ctor, args, supportsDelayedInstantiation, _trace));
|
||||
} else {
|
||||
return super._createServiceInstance(ctor, args, supportsDelayedInstantiation, _trace);
|
||||
}
|
||||
}
|
||||
|
||||
private static _newIdleProxyService<T>(executor: () => T): T {
|
||||
const idle = new IdleValue(executor);
|
||||
return <T>new Proxy(Object.create(null), {
|
||||
get(_target: T, prop: PropertyKey): any {
|
||||
return idle.getValue()[prop];
|
||||
},
|
||||
set(_target: T, p: PropertyKey, value: any): boolean {
|
||||
idle.getValue()[p] = value;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user