Skip to content

Commit f29abe4

Browse files
committed
remove more unused code, microsoft#38414
1 parent f657b94 commit f29abe4

3 files changed

Lines changed: 9 additions & 49 deletions

File tree

src/vs/base/common/objects.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ export function assign(destination: any, ...sources: any[]): any {
120120
return destination;
121121
}
122122

123-
export function toObject<T>(arr: T[], keyMap: (t: T) => string): { [key: string]: T } {
124-
return arr.reduce((o, d) => assign(o, { [keyMap(d)]: d }), Object.create(null));
125-
}
126-
127123
export function equals(one: any, other: any): boolean {
128124
if (one === other) {
129125
return true;

src/vs/platform/instantiation/common/descriptors.ts

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,17 @@
44
*--------------------------------------------------------------------------------------------*/
55
'use strict';
66

7-
import { illegalArgument } from 'vs/base/common/errors';
87
import * as instantiation from './instantiation';
98

10-
export class AbstractDescriptor<T> {
119

12-
constructor(private _staticArguments: any[]) {
13-
// empty
14-
}
15-
16-
public appendStaticArguments(more: any[]): void {
17-
this._staticArguments.push.apply(this._staticArguments, more);
18-
}
10+
export class SyncDescriptor<T> {
1911

20-
public staticArguments(): any[];
21-
public staticArguments(nth: number): any;
22-
public staticArguments(nth?: number): any[] {
23-
if (isNaN(nth)) {
24-
return this._staticArguments.slice(0);
25-
} else {
26-
return this._staticArguments[nth];
27-
}
28-
}
12+
readonly ctor: any;
13+
readonly staticArguments: any[];
2914

30-
_validate(type: T): void {
31-
if (!type) {
32-
throw illegalArgument('can not be falsy');
33-
}
34-
}
35-
}
36-
37-
export class SyncDescriptor<T> extends AbstractDescriptor<T> {
38-
39-
constructor(private _ctor: any, ...staticArguments: any[]) {
40-
super(staticArguments);
41-
}
42-
43-
public get ctor(): any {
44-
return this._ctor;
45-
}
46-
47-
protected bind(...moreStaticArguments: any[]): SyncDescriptor<T> {
48-
let allArgs: any[] = [];
49-
allArgs = allArgs.concat(this.staticArguments());
50-
allArgs = allArgs.concat(moreStaticArguments);
51-
return new SyncDescriptor<T>(this._ctor, ...allArgs);
15+
constructor(ctor: new (...args: any[]) => T, ..._staticArguments: any[]) {
16+
this.ctor = ctor;
17+
this.staticArguments = _staticArguments;
5218
}
5319
}
5420

@@ -175,4 +141,4 @@ export interface SyncDescriptor8<A1, A2, A3, A4, A5, A6, A7, A8, T> {
175141
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): SyncDescriptor2<A7, A8, T>;
176142
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): SyncDescriptor1<A8, T>;
177143
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): SyncDescriptor0<T>;
178-
}
144+
}

src/vs/platform/instantiation/common/instantiationService.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class InstantiationService implements IInstantiationService {
7777
private _createInstance<T>(desc: SyncDescriptor<T>, args: any[]): T {
7878

7979
// arguments given by createInstance-call and/or the descriptor
80-
let staticArgs = desc.staticArguments().concat(args);
80+
let staticArgs = desc.staticArguments.concat(args);
8181

8282
// arguments defined by service decorators
8383
let serviceDependencies = _util.getServiceDependencies(desc.ctor).sort((a, b) => a.index - b.index);
@@ -117,9 +117,7 @@ export class InstantiationService implements IInstantiationService {
117117
argArray.push(...staticArgs);
118118
argArray.push(...serviceArgs);
119119

120-
const instance = create.apply(null, argArray);
121-
desc._validate(instance);
122-
return <T>instance;
120+
return <T>create.apply(null, argArray);
123121
}
124122

125123
private _getOrCreateServiceInstance<T>(id: ServiceIdentifier<T>): T {

0 commit comments

Comments
 (0)