mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-09 20:37:13 -05:00
remove more unused code, #38414
This commit is contained in:
@@ -120,10 +120,6 @@ export function assign(destination: any, ...sources: any[]): any {
|
||||
return destination;
|
||||
}
|
||||
|
||||
export function toObject<T>(arr: T[], keyMap: (t: T) => string): { [key: string]: T } {
|
||||
return arr.reduce((o, d) => assign(o, { [keyMap(d)]: d }), Object.create(null));
|
||||
}
|
||||
|
||||
export function equals(one: any, other: any): boolean {
|
||||
if (one === other) {
|
||||
return true;
|
||||
|
||||
@@ -4,51 +4,17 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { illegalArgument } from 'vs/base/common/errors';
|
||||
import * as instantiation from './instantiation';
|
||||
|
||||
export class AbstractDescriptor<T> {
|
||||
|
||||
constructor(private _staticArguments: any[]) {
|
||||
// empty
|
||||
}
|
||||
export class SyncDescriptor<T> {
|
||||
|
||||
public appendStaticArguments(more: any[]): void {
|
||||
this._staticArguments.push.apply(this._staticArguments, more);
|
||||
}
|
||||
readonly ctor: any;
|
||||
readonly staticArguments: any[];
|
||||
|
||||
public staticArguments(): any[];
|
||||
public staticArguments(nth: number): any;
|
||||
public staticArguments(nth?: number): any[] {
|
||||
if (isNaN(nth)) {
|
||||
return this._staticArguments.slice(0);
|
||||
} else {
|
||||
return this._staticArguments[nth];
|
||||
}
|
||||
}
|
||||
|
||||
_validate(type: T): void {
|
||||
if (!type) {
|
||||
throw illegalArgument('can not be falsy');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class SyncDescriptor<T> extends AbstractDescriptor<T> {
|
||||
|
||||
constructor(private _ctor: any, ...staticArguments: any[]) {
|
||||
super(staticArguments);
|
||||
}
|
||||
|
||||
public get ctor(): any {
|
||||
return this._ctor;
|
||||
}
|
||||
|
||||
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);
|
||||
constructor(ctor: new (...args: any[]) => T, ..._staticArguments: any[]) {
|
||||
this.ctor = ctor;
|
||||
this.staticArguments = _staticArguments;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,4 +141,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>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ export class InstantiationService implements IInstantiationService {
|
||||
private _createInstance<T>(desc: SyncDescriptor<T>, args: any[]): T {
|
||||
|
||||
// arguments given by createInstance-call and/or the descriptor
|
||||
let staticArgs = desc.staticArguments().concat(args);
|
||||
let staticArgs = desc.staticArguments.concat(args);
|
||||
|
||||
// arguments defined by service decorators
|
||||
let serviceDependencies = _util.getServiceDependencies(desc.ctor).sort((a, b) => a.index - b.index);
|
||||
@@ -117,9 +117,7 @@ export class InstantiationService implements IInstantiationService {
|
||||
argArray.push(...staticArgs);
|
||||
argArray.push(...serviceArgs);
|
||||
|
||||
const instance = create.apply(null, argArray);
|
||||
desc._validate(instance);
|
||||
return <T>instance;
|
||||
return <T>create.apply(null, argArray);
|
||||
}
|
||||
|
||||
private _getOrCreateServiceInstance<T>(id: ServiceIdentifier<T>): T {
|
||||
|
||||
Reference in New Issue
Block a user