mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-28 15:50:29 -04:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -4,12 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { illegalArgument, illegalState, canceled } from 'vs/base/common/errors';
|
||||
import { illegalState } from 'vs/base/common/errors';
|
||||
import { create } from 'vs/base/common/types';
|
||||
import * as assert from 'vs/base/common/assert';
|
||||
import { Graph } from 'vs/base/common/graph';
|
||||
import { SyncDescriptor, AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { ServiceIdentifier, IInstantiationService, ServicesAccessor, _util, optional } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
|
||||
@@ -65,11 +64,7 @@ export class InstantiationService implements IInstantiationService {
|
||||
|
||||
createInstance<T>(param: any, ...rest: any[]): any {
|
||||
|
||||
if (param instanceof AsyncDescriptor) {
|
||||
// async
|
||||
return this._createInstanceAsync(param, rest);
|
||||
|
||||
} else if (param instanceof SyncDescriptor) {
|
||||
if (param instanceof SyncDescriptor) {
|
||||
// sync
|
||||
return this._createInstance(param, rest);
|
||||
|
||||
@@ -79,43 +74,6 @@ export class InstantiationService implements IInstantiationService {
|
||||
}
|
||||
}
|
||||
|
||||
private _createInstanceAsync<T>(descriptor: AsyncDescriptor<T>, args: any[]): TPromise<T> {
|
||||
|
||||
let canceledError: Error;
|
||||
|
||||
return new TPromise((c, e, p) => {
|
||||
require([descriptor.moduleName], (_module?: any) => {
|
||||
if (canceledError) {
|
||||
e(canceledError);
|
||||
}
|
||||
|
||||
if (!_module) {
|
||||
return e(illegalArgument('module not found: ' + descriptor.moduleName));
|
||||
}
|
||||
|
||||
let ctor: Function;
|
||||
if (!descriptor.ctorName) {
|
||||
ctor = _module;
|
||||
} else {
|
||||
ctor = _module[descriptor.ctorName];
|
||||
}
|
||||
|
||||
if (typeof ctor !== 'function') {
|
||||
return e(illegalArgument('not a function: ' + descriptor.ctorName || descriptor.moduleName));
|
||||
}
|
||||
|
||||
try {
|
||||
args.unshift.apply(args, descriptor.staticArguments()); // instead of spread in ctor call
|
||||
c(this._createInstance(new SyncDescriptor<T>(ctor), args));
|
||||
} catch (error) {
|
||||
return e(error);
|
||||
}
|
||||
}, e);
|
||||
}, () => {
|
||||
canceledError = canceled();
|
||||
});
|
||||
}
|
||||
|
||||
private _createInstance<T>(desc: SyncDescriptor<T>, args: any[]): T {
|
||||
|
||||
// arguments given by createInstance-call and/or the descriptor
|
||||
|
||||
Reference in New Issue
Block a user