44 *--------------------------------------------------------------------------------------------*/
55'use strict' ;
66
7- import { illegalArgument } from 'vs/base/common/errors' ;
87import * 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+ }
0 commit comments