1950
1951
public negate(): ContextKeyExpression {
1953
>
const result: ContextKeyExpression[] = [];
1954
>
for (const expr of this.expr) {
1955
>
result.push(expr.negate());
1956
>
}
1957
>
1958
>
// We don't support parens, so here we distribute the AND over the OR terminals
1959
>
// We always take the first 2 AND pairs and distribute them
1960
>
while (result.length > 1) {
1961
>
const LEFT = result.shift()!;
1962
>
const RIGHT = result.shift()!;
1963
>
1964
>
const all: ContextKeyExpression[] = [];
1965
>
for (const left of getTerminals(LEFT)) {
1966
>
for (const right of getTerminals(RIGHT)) {
1967
>
all.push(ContextKeyAndExpr.create([left, right], null, false)!);
1968
>
}
1969
>
}
1970
>
1971
>
result.unshift(ContextKeyOrExpr.create(all, null, false)!);
1972
>
}
1973
>
1974
>
this.negated = ContextKeyOrExpr.create(result, this, true)!;
1975
>
}
1976
>
return this.negated;
1977
>
}
1978
}
1979