MCPcopy Create free account
hub / github.com/Wscats/vscode-explore / ContextKeyNotEqualsExpr

Class ContextKeyNotEqualsExpr

contextKeyExpr/src/contextkey.ts:442–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440}
441
442export 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected