| 440 | } |
| 441 | |
| 442 | export class ContextKeyNotEqualsExpr implements IContextKeyExpression { |
| 443 | |
| 444 | public static create(key: string, value: any): ContextKeyExpression { |
| 445 | if (typeof value === 'boolean') { |
| 446 | if (value) { |
| 447 | return ContextKeyNotExpr.create(key); |
| 448 | } |
| 449 | return ContextKeyDefinedExpr.create(key); |
| 450 | } |
| 451 | const staticValue = STATIC_VALUES.get(key); |
| 452 | if (typeof staticValue === 'boolean') { |
| 453 | const falseValue = staticValue ? 'true' : 'false'; |
| 454 | return (value === falseValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE); |
| 455 | } |
| 456 | return new ContextKeyNotEqualsExpr(key, value); |
| 457 | } |
| 458 | |
| 459 | public readonly type = ContextKeyExprType.NotEquals; |
| 460 | |
| 461 | private constructor(private readonly key: string, private readonly value: any) { |
| 462 | } |
| 463 | |
| 464 | public cmp(other: ContextKeyExpression): number { |
| 465 | if (other.type !== this.type) { |
| 466 | return this.type - other.type; |
| 467 | } |
| 468 | if (this.key < other.key) { |
| 469 | return -1; |
| 470 | } |
| 471 | if (this.key > other.key) { |
| 472 | return 1; |
| 473 | } |
| 474 | if (this.value < other.value) { |
| 475 | return -1; |
| 476 | } |
| 477 | if (this.value > other.value) { |
| 478 | return 1; |
| 479 | } |
| 480 | return 0; |
| 481 | } |
| 482 | |
| 483 | public equals(other: ContextKeyExpression): boolean { |
| 484 | if (other.type === this.type) { |
| 485 | return (this.key === other.key && this.value === other.value); |
| 486 | } |
| 487 | return false; |
| 488 | } |
| 489 | |
| 490 | public evaluate(context: IContext): boolean { |
| 491 | // Intentional != |
| 492 | // eslint-disable-next-line eqeqeq |
| 493 | return (context.getValue(this.key) != this.value); |
| 494 | } |
| 495 | |
| 496 | public serialize(): string { |
| 497 | return this.key + ' != \'' + this.value + '\''; |
| 498 | } |
| 499 |
nothing calls this directly
no outgoing calls
no test coverage detected