Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -128,7 +128,7 @@ function storeServiceDependency(id: Function, target: Function, index: number, o
export function createDecorator<T>(serviceId: string): { (...args: any[]): void; type: T; } {
if (_util.serviceIds.has(serviceId)) {
return _util.serviceIds.get(serviceId);
return _util.serviceIds.get(serviceId)!;
}
const id = <any>function (target: Function, key: string, index: number): any {

View File

@@ -37,7 +37,7 @@ export class InstantiationService implements IInstantiationService {
let _trace = Trace.traceInvocation(fn);
let _done = false;
try {
let accessor = {
const accessor: ServicesAccessor = {
get: <T>(id: ServiceIdentifier<T>, isOptional?: typeof optional) => {
if (_done) {
@@ -51,7 +51,7 @@ export class InstantiationService implements IInstantiationService {
return result;
}
};
return fn.apply(undefined, [accessor].concat(args));
return fn.apply(undefined, [accessor, ...args]);
} finally {
_done = true;
_trace.stop();
@@ -186,7 +186,7 @@ export class InstantiationService implements IInstantiationService {
for (let { data } of roots) {
// create instance and overwrite the service collections
const instance = this._createServiceInstanceWithOwner(data.id, data.desc.ctor, data.desc.staticArguments, false, data._trace);
const instance = this._createServiceInstanceWithOwner(data.id, data.desc.ctor, data.desc.staticArguments, data.desc.supportsDelayedInstantiation, data._trace);
this._setServiceInstance(data.id, instance);
graph.removeNode(data);
}
@@ -205,7 +205,7 @@ export class InstantiationService implements IInstantiationService {
}
}
protected _createServiceInstance<T>(ctor: any, args: any[] = [], supportsDelayedInstantiation: boolean, _trace: Trace): T {
protected _createServiceInstance<T>(ctor: any, args: any[] = [], _supportsDelayedInstantiation: boolean, _trace: Trace): T {
return this._createInstance(ctor, args, _trace);
}
}

View File

@@ -6,7 +6,7 @@ import * as assert from 'assert';
import { Graph } from 'vs/platform/instantiation/common/graph';
suite('Graph', () => {
var graph: Graph<string>;
let graph: Graph<string>;
setup(() => {
graph = new Graph<string>(s => s);
@@ -34,7 +34,7 @@ suite('Graph', () => {
test('root', () => {
graph.insertEdge('1', '2');
var roots = graph.roots();
let roots = graph.roots();
assert.equal(roots.length, 1);
assert.equal(roots[0].data, '2');
@@ -48,7 +48,7 @@ suite('Graph', () => {
graph.insertEdge('1', '3');
graph.insertEdge('3', '4');
var roots = graph.roots();
let roots = graph.roots();
assert.equal(roots.length, 2);
assert(['2', '4'].every(n => roots.some(node => node.data === n)));
});

View File

@@ -94,7 +94,7 @@ class TargetOptional {
constructor(@IService1 service1: IService1, @optional(IService2) service2: IService2) {
assert.ok(service1);
assert.equal(service1.c, 1);
assert.ok(service2 === void 0);
assert.ok(service2 === undefined);
}
}
@@ -137,7 +137,7 @@ suite('Instantiation Service', () => {
test('service collection, cannot overwrite', function () {
let collection = new ServiceCollection();
let result = collection.set(IService1, null);
let result = collection.set(IService1, null!);
assert.equal(result, undefined);
result = collection.set(IService1, new Service1());
assert.equal(result, null);
@@ -145,10 +145,10 @@ suite('Instantiation Service', () => {
test('service collection, add/has', function () {
let collection = new ServiceCollection();
collection.set(IService1, null);
collection.set(IService1, null!);
assert.ok(collection.has(IService1));
collection.set(IService2, null);
collection.set(IService2, null!);
assert.ok(collection.has(IService1));
assert.ok(collection.has(IService2));
});

View File

@@ -4,11 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import * as sinon from 'sinon';
import * as types from 'vs/base/common/types';
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { TPromise } from 'vs/base/common/winjs.base';
interface IServiceMock<T> {
id: ServiceIdentifier<T>;
@@ -37,13 +35,13 @@ export class TestInstantiationService extends InstantiationService {
return <T>this._create(service, { mock: true });
}
public stub<T>(service?: ServiceIdentifier<T>, ctor?: any): T;
public stub<T>(service?: ServiceIdentifier<T>, obj?: any): T;
public stub<T>(service?: ServiceIdentifier<T>, ctor?: any, property?: string, value?: any): sinon.SinonStub;
public stub<T>(service?: ServiceIdentifier<T>, obj?: any, property?: string, value?: any): sinon.SinonStub;
public stub<T>(service?: ServiceIdentifier<T>, property?: string, value?: any): sinon.SinonStub;
public stub<T>(serviceIdentifier?: ServiceIdentifier<T>, arg2?: any, arg3?: string, arg4?: any): sinon.SinonStub {
let service = typeof arg2 !== 'string' ? arg2 : void 0;
public stub<T>(service: ServiceIdentifier<T>, ctor?: any): T;
public stub<T>(service: ServiceIdentifier<T>, obj?: any): T;
public stub<T>(service: ServiceIdentifier<T>, ctor?: any, property?: string, value?: any): sinon.SinonStub;
public stub<T>(service: ServiceIdentifier<T>, obj?: any, property?: string, value?: any): sinon.SinonStub;
public stub<T>(service: ServiceIdentifier<T>, property?: string, value?: any): sinon.SinonStub;
public stub<T>(serviceIdentifier: ServiceIdentifier<T>, arg2?: any, arg3?: string, arg4?: any): sinon.SinonStub {
let service = typeof arg2 !== 'string' ? arg2 : undefined;
let serviceMock: IServiceMock<any> = { id: serviceIdentifier, service: service };
let property = typeof arg2 === 'string' ? arg2 : arg3;
let value = typeof arg2 === 'string' ? arg3 : arg4;
@@ -72,8 +70,8 @@ export class TestInstantiationService extends InstantiationService {
public stubPromise<T>(service?: ServiceIdentifier<T>, ctor?: any, fnProperty?: string, value?: any): sinon.SinonStub;
public stubPromise<T>(service?: ServiceIdentifier<T>, obj?: any, fnProperty?: string, value?: any): sinon.SinonStub;
public stubPromise(arg1?: any, arg2?: any, arg3?: any, arg4?: any): sinon.SinonStub {
arg3 = typeof arg2 === 'string' ? TPromise.as(arg3) : arg3;
arg4 = typeof arg2 !== 'string' && typeof arg3 === 'string' ? TPromise.as(arg4) : arg4;
arg3 = typeof arg2 === 'string' ? Promise.resolve(arg3) : arg3;
arg4 = typeof arg2 !== 'string' && typeof arg3 === 'string' ? Promise.resolve(arg4) : arg4;
return this.stub(arg1, arg2, arg3, arg4);
}
@@ -123,13 +121,6 @@ export class TestInstantiationService extends InstantiationService {
}
}
export function stubFunction<T>(ctor: any, fnProperty: string, value: any): T | sinon.SinonStub {
let stub = sinon.createStubInstance(ctor);
stub[fnProperty].restore();
sinon.stub(stub, fnProperty, types.isFunction(value) ? value : () => { return value; });
return stub;
}
interface SinonOptions {
mock?: boolean;
stub?: boolean;