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:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -44,8 +44,8 @@ export class SyncDescriptor<T> extends AbstractDescriptor<T> {
return this._ctor;
}
protected bind(...moreStaticArguments): SyncDescriptor<T> {
let allArgs = [];
protected bind(...moreStaticArguments: any[]): SyncDescriptor<T> {
let allArgs: any[] = [];
allArgs = allArgs.concat(this.staticArguments());
allArgs = allArgs.concat(moreStaticArguments);
return new SyncDescriptor<T>(this._ctor, ...allArgs);
@@ -175,98 +175,4 @@ export interface SyncDescriptor8<A1, A2, A3, A4, A5, A6, A7, A8, T> {
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): SyncDescriptor2<A7, A8, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): SyncDescriptor1<A8, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): SyncDescriptor0<T>;
}
export class AsyncDescriptor<T> extends AbstractDescriptor<T> implements AsyncDescriptor0<T> {
public static create<T>(moduleName: string, ctorName: string): AsyncDescriptor<T> {
return new AsyncDescriptor<T>(moduleName, ctorName);
}
constructor(private _moduleName: string, private _ctorName?: string, ...staticArguments: any[]) {
super(staticArguments);
if (typeof _moduleName !== 'string') {
throw new Error('Invalid AsyncDescriptor arguments, expected `moduleName` to be a string!');
}
}
public get moduleName(): string {
return this._moduleName;
}
public get ctorName(): string {
return this._ctorName;
}
bind(...moreStaticArguments): AsyncDescriptor<T> {
let allArgs = [];
allArgs = allArgs.concat(this.staticArguments());
allArgs = allArgs.concat(moreStaticArguments);
return new AsyncDescriptor<T>(this.moduleName, this.ctorName, ...allArgs);
}
}
export interface AsyncDescriptor0<T> {
moduleName: string;
bind(): AsyncDescriptor0<T>;
}
export interface AsyncDescriptor1<A1, T> {
moduleName: string;
bind(a1: A1): AsyncDescriptor0<T>;
}
export interface AsyncDescriptor2<A1, A2, T> {
moduleName: string;
bind(a1: A1): AsyncDescriptor1<A2, T>;
bind(a1: A1, a2: A2): AsyncDescriptor0<T>;
}
export interface AsyncDescriptor3<A1, A2, A3, T> {
moduleName: string;
bind(a1: A1): AsyncDescriptor2<A2, A3, T>;
bind(a1: A1, a2: A2): AsyncDescriptor1<A3, T>;
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor0<T>;
}
export interface AsyncDescriptor4<A1, A2, A3, A4, T> {
moduleName: string;
bind(a1: A1): AsyncDescriptor3<A2, A3, A4, T>;
bind(a1: A1, a2: A2): AsyncDescriptor2<A3, A4, T>;
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor1<A4, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor0<T>;
}
export interface AsyncDescriptor5<A1, A2, A3, A4, A5, T> {
moduleName: string;
bind(a1: A1): AsyncDescriptor4<A2, A3, A4, A5, T>;
bind(a1: A1, a2: A2): AsyncDescriptor3<A3, A4, A5, T>;
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor2<A4, A5, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor1<A5, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): AsyncDescriptor0<T>;
}
export interface AsyncDescriptor6<A1, A2, A3, A4, A5, A6, T> {
moduleName: string;
bind(a1: A1): AsyncDescriptor5<A2, A3, A4, A5, A6, T>;
bind(a1: A1, a2: A2): AsyncDescriptor4<A3, A4, A5, A6, T>;
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor3<A4, A5, A6, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor2<A5, A6, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): AsyncDescriptor1<A6, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): AsyncDescriptor0<T>;
}
export interface AsyncDescriptor7<A1, A2, A3, A4, A5, A6, A7, T> {
moduleName: string;
bind(a1: A1): AsyncDescriptor6<A2, A3, A4, A5, A6, A7, T>;
bind(a1: A1, a2: A2): AsyncDescriptor5<A3, A4, A5, A6, A7, T>;
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor4<A4, A5, A6, A7, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor3<A5, A6, A7, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): AsyncDescriptor2<A6, A7, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): AsyncDescriptor1<A7, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): AsyncDescriptor0<T>;
}
export interface AsyncDescriptor8<A1, A2, A3, A4, A5, A6, A7, A8, T> {
moduleName: string;
bind(a1: A1): AsyncDescriptor7<A2, A3, A4, A5, A6, A7, A8, T>;
bind(a1: A1, a2: A2): AsyncDescriptor6<A3, A4, A5, A6, A7, A8, T>;
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor5<A4, A5, A6, A7, A8, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor4<A5, A6, A7, A8, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): AsyncDescriptor3<A6, A7, A8, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): AsyncDescriptor2<A7, A8, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): AsyncDescriptor1<A8, T>;
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): AsyncDescriptor0<T>;
}

View File

@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import { ServiceCollection } from './serviceCollection';
import * as descriptors from './descriptors';
@@ -130,20 +129,6 @@ export interface IInstantiationService {
createInstance<A1, A2, A3, A4, A5, A6, A7, T>(ctor: IConstructorSignature7<A1, A2, A3, A4, A5, A6, A7, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7): T;
createInstance<A1, A2, A3, A4, A5, A6, A7, A8, T>(ctor: IConstructorSignature8<A1, A2, A3, A4, A5, A6, A7, A8, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7, eigth: A8): T;
/**
* Asynchronously creates an instance that is denoted by
* the descriptor
*/
createInstance<T>(descriptor: descriptors.AsyncDescriptor0<T>): TPromise<T>;
createInstance<A1, T>(descriptor: descriptors.AsyncDescriptor1<A1, T>, a1: A1): TPromise<T>;
createInstance<A1, A2, T>(descriptor: descriptors.AsyncDescriptor2<A1, A2, T>, a1: A1, a2: A2): TPromise<T>;
createInstance<A1, A2, A3, T>(descriptor: descriptors.AsyncDescriptor3<A1, A2, A3, T>, a1: A1, a2: A2, a3: A3): TPromise<T>;
createInstance<A1, A2, A3, A4, T>(descriptor: descriptors.AsyncDescriptor4<A1, A2, A3, A4, T>, a1: A1, a2: A2, a3: A3, a4: A4): TPromise<T>;
createInstance<A1, A2, A3, A4, A5, T>(descriptor: descriptors.AsyncDescriptor5<A1, A2, A3, A4, A5, T>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): TPromise<T>;
createInstance<A1, A2, A3, A4, A5, A6, T>(descriptor: descriptors.AsyncDescriptor6<A1, A2, A3, A4, A5, A6, T>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): TPromise<T>;
createInstance<A1, A2, A3, A4, A5, A6, A7, T>(descriptor: descriptors.AsyncDescriptor7<A1, A2, A3, A4, A5, A6, A7, T>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): TPromise<T>;
createInstance<A1, A2, A3, A4, A5, A6, A7, A8, T>(descriptor: descriptors.AsyncDescriptor8<A1, A2, A3, A4, A5, A6, A7, A8, T>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): TPromise<T>;
/**
*
*/

View File

@@ -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

View File

@@ -50,7 +50,7 @@ export class TestInstantiationService extends InstantiationService {
let property = typeof arg2 === 'string' ? arg2 : arg3;
let value = typeof arg2 === 'string' ? arg3 : arg4;
let stubObject = <any>this._create(serviceMock, { stub: true });
let stubObject = <any>this._create(serviceMock, { stub: true }, service && !property);
if (property) {
if (stubObject[property]) {
if (stubObject[property].hasOwnProperty('restore')) {
@@ -85,20 +85,20 @@ export class TestInstantiationService extends InstantiationService {
return spy;
}
private _create<T>(serviceMock: IServiceMock<T>, options: SinonOptions): any
private _create<T>(serviceMock: IServiceMock<T>, options: SinonOptions, reset?: boolean): any
private _create<T>(ctor: any, options: SinonOptions): any
private _create<T>(arg1: any, options: SinonOptions): any {
private _create<T>(arg1: any, options: SinonOptions, reset: boolean = false): any {
if (this.isServiceMock(arg1)) {
let service = this._getOrCreateService(arg1, options);
let service = this._getOrCreateService(arg1, options, reset);
this._serviceCollection.set(arg1.id, service);
return service;
}
return options.mock ? sinon.mock(arg1) : this._createStub(arg1);
}
private _getOrCreateService<T>(serviceMock: IServiceMock<T>, opts: SinonOptions): any {
private _getOrCreateService<T>(serviceMock: IServiceMock<T>, opts: SinonOptions, reset?: boolean): any {
let service: any = this._serviceCollection.get(serviceMock.id);
if (service) {
if (!reset && service) {
if (opts.mock && service['sinonOptions'] && !!service['sinonOptions'].mock) {
return service;
}