| 783 | } |
| 784 | |
| 785 | export class ContextKeyNotExpr implements IContextKeyExpression { |
| 786 | |
| 787 | public static create(key: string): ContextKeyExpression { |
| 788 | const staticValue = STATIC_VALUES.get(key); |
| 789 | if (typeof staticValue === 'boolean') { |
| 790 | return (staticValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE); |
| 791 | } |
| 792 | return new ContextKeyNotExpr(key); |
| 793 | } |
| 794 | |
| 795 | public readonly type = ContextKeyExprType.Not; |
| 796 | |
| 797 | private constructor(private readonly key: string) { |
| 798 | } |
| 799 | |
| 800 | public cmp(other: ContextKeyExpression): number { |
| 801 | if (other.type !== this.type) { |
| 802 | return this.type - other.type; |
| 803 | } |
| 804 | if (this.key < other.key) { |
| 805 | return -1; |
| 806 | } |
| 807 | if (this.key > other.key) { |
| 808 | return 1; |
| 809 | } |
| 810 | return 0; |
| 811 | } |
| 812 | |
| 813 | public equals(other: ContextKeyExpression): boolean { |
| 814 | if (other.type === this.type) { |
| 815 | return (this.key === other.key); |
| 816 | } |
| 817 | return false; |
| 818 | } |
| 819 | |
| 820 | public evaluate(context: IContext): boolean { |
| 821 | return (!context.getValue(this.key)); |
| 822 | } |
| 823 | |
| 824 | public serialize(): string { |
| 825 | return '!' + this.key; |
| 826 | } |
| 827 | |
| 828 | public keys(): string[] { |
| 829 | return [this.key]; |
| 830 | } |
| 831 | |
| 832 | public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression { |
| 833 | return mapFnc.mapNot(this.key); |
| 834 | } |
| 835 | |
| 836 | public negate(): ContextKeyExpression { |
| 837 | return ContextKeyDefinedExpr.create(this.key); |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | export class ContextKeyRegexExpr implements IContextKeyExpression { |
| 842 |
nothing calls this directly
no outgoing calls
no test coverage detected