@@ -53,6 +53,7 @@ export interface IContextKeyExprMapper {
53
53
mapSmallerEquals ( key : string , value : any ) : ContextKeyExpression ;
54
54
mapRegex ( key : string , regexp : RegExp | null ) : ContextKeyRegexExpr ;
55
55
mapIn ( key : string , valueKey : string ) : ContextKeyInExpr ;
56
+ mapNotIn ( key : string , valueKey : string ) : ContextKeyNotInExpr ;
56
57
}
57
58
58
59
export interface IContextKeyExpression {
@@ -98,6 +99,9 @@ export abstract class ContextKeyExpr {
98
99
public static in ( key : string , value : string ) : ContextKeyExpression {
99
100
return ContextKeyInExpr . create ( key , value ) ;
100
101
}
102
+ public static notIn ( key : string , value : string ) : ContextKeyExpression {
103
+ return ContextKeyNotInExpr . create ( key , value ) ;
104
+ }
101
105
public static not ( key : string ) : ContextKeyExpression {
102
106
return ContextKeyNotExpr . create ( key ) ;
103
107
}
@@ -156,6 +160,11 @@ export abstract class ContextKeyExpr {
156
160
return ContextKeyRegexExpr . create ( pieces [ 0 ] . trim ( ) , this . _deserializeRegexValue ( pieces [ 1 ] , strict ) ) ;
157
161
}
158
162
163
+ if ( serializedOne . indexOf ( ' not in ' ) >= 0 ) {
164
+ const pieces = serializedOne . split ( ' not in ' ) ;
165
+ return ContextKeyNotInExpr . create ( pieces [ 0 ] . trim ( ) , pieces [ 1 ] . trim ( ) ) ;
166
+ }
167
+
159
168
if ( serializedOne . indexOf ( ' in ' ) >= 0 ) {
160
169
const pieces = serializedOne . split ( ' in ' ) ;
161
170
return ContextKeyInExpr . create ( pieces [ 0 ] . trim ( ) , pieces [ 1 ] . trim ( ) ) ;
@@ -539,34 +548,39 @@ export class ContextKeyInExpr implements IContextKeyExpression {
539
548
540
549
public negate ( ) : ContextKeyExpression {
541
550
if ( ! this . negated ) {
542
- this . negated = ContextKeyNotInExpr . create ( this ) ;
551
+ this . negated = ContextKeyNotInExpr . create ( this . key , this . valueKey ) ;
543
552
}
544
553
return this . negated ;
545
554
}
546
555
}
547
556
548
557
export class ContextKeyNotInExpr implements IContextKeyExpression {
549
558
550
- public static create ( actual : ContextKeyInExpr ) : ContextKeyNotInExpr {
551
- return new ContextKeyNotInExpr ( actual ) ;
559
+ public static create ( key : string , valueKey : string ) : ContextKeyNotInExpr {
560
+ return new ContextKeyNotInExpr ( key , valueKey ) ;
552
561
}
553
562
554
563
public readonly type = ContextKeyExprType . NotIn ;
555
564
556
- private constructor ( private readonly _actual : ContextKeyInExpr ) {
557
- //
565
+ private readonly _negated : ContextKeyInExpr ;
566
+
567
+ private constructor (
568
+ private readonly key : string ,
569
+ private readonly valueKey : string ,
570
+ ) {
571
+ this . _negated = ContextKeyInExpr . create ( key , valueKey ) ;
558
572
}
559
573
560
574
public cmp ( other : ContextKeyExpression ) : number {
561
575
if ( other . type !== this . type ) {
562
576
return this . type - other . type ;
563
577
}
564
- return this . _actual . cmp ( other . _actual ) ;
578
+ return this . _negated . cmp ( other . _negated ) ;
565
579
}
566
580
567
581
public equals ( other : ContextKeyExpression ) : boolean {
568
582
if ( other . type === this . type ) {
569
- return this . _actual . equals ( other . _actual ) ;
583
+ return this . _negated . equals ( other . _negated ) ;
570
584
}
571
585
return false ;
572
586
}
@@ -576,23 +590,23 @@ export class ContextKeyNotInExpr implements IContextKeyExpression {
576
590
}
577
591
578
592
public evaluate ( context : IContext ) : boolean {
579
- return ! this . _actual . evaluate ( context ) ;
593
+ return ! this . _negated . evaluate ( context ) ;
580
594
}
581
595
582
596
public serialize ( ) : string {
583
- throw new Error ( 'Method not implemented.' ) ;
597
+ return ` ${ this . key } not in ' ${ this . valueKey } '` ;
584
598
}
585
599
586
600
public keys ( ) : string [ ] {
587
- return this . _actual . keys ( ) ;
601
+ return this . _negated . keys ( ) ;
588
602
}
589
603
590
604
public map ( mapFnc : IContextKeyExprMapper ) : ContextKeyExpression {
591
- return new ContextKeyNotInExpr ( this . _actual . map ( mapFnc ) ) ;
605
+ return mapFnc . mapNotIn ( this . key , this . valueKey ) ;
592
606
}
593
607
594
608
public negate ( ) : ContextKeyExpression {
595
- return this . _actual ;
609
+ return this . _negated ;
596
610
}
597
611
}
598
612
0 commit comments