| 647 | } |
| 648 | |
| 649 | export class ContextKeyLessExpr implements IContextKeyExpression { |
| 650 | |
| 651 | public static create(key: string, value: any): ContextKeyExpression { |
| 652 | if (typeof value === 'boolean') { |
| 653 | return (value ? ContextKeyDefinedExpr.create(key) : ContextKeyNotExpr.create(key)); |
| 654 | } |
| 655 | const staticValue = STATIC_VALUES.get(key); |
| 656 | if (typeof staticValue === 'boolean') { |
| 657 | const trueValue = staticValue ? 'true' : 'false'; |
| 658 | return (value === trueValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE); |
| 659 | } |
| 660 | return new ContextKeyLessExpr(key, value); |
| 661 | } |
| 662 | |
| 663 | public readonly type = ContextKeyExprType.Less; |
| 664 | |
| 665 | private constructor(private readonly key: string, private readonly value: any) { |
| 666 | } |
| 667 | |
| 668 | public cmp(other: ContextKeyExpression): number { |
| 669 | if (other.type !== this.type) { |
| 670 | return this.type - other.type; |
| 671 | } |
| 672 | if (this.key < other.key) { |
| 673 | return -1; |
| 674 | } |
| 675 | if (this.key > other.key) { |
| 676 | return 1; |
| 677 | } |
| 678 | if (this.value < other.value) { |
| 679 | return -1; |
| 680 | } |
| 681 | if (this.value > other.value) { |
| 682 | return 1; |
| 683 | } |
| 684 | return 0; |
| 685 | } |
| 686 | |
| 687 | public equals(other: ContextKeyExpression): boolean { |
| 688 | if (other.type === this.type) { |
| 689 | return (this.key === other.key && this.value === other.value); |
| 690 | } |
| 691 | return false; |
| 692 | } |
| 693 | |
| 694 | public evaluate(context: IContext): boolean { |
| 695 | // Intentional == |
| 696 | // eslint-disable-next-line eqeqeq |
| 697 | return (Number(context.getValue(this.key)) < this.value); |
| 698 | } |
| 699 | |
| 700 | public serialize(): string { |
| 701 | return this.key + ' == \'' + this.value + '\''; |
| 702 | } |
| 703 | |
| 704 | public keys(): string[] { |
| 705 | return [this.key]; |
| 706 | } |
nothing calls this directly
no outgoing calls
no test coverage detected