mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-06 05:02:02 +08:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
"use strict";
|
|
|
|
import NoteSet from "../note_set.js";
|
|
import SearchContext from "../search_context.js";
|
|
import Expression from "./expression.js";
|
|
import TrueExp from "./true.js";
|
|
|
|
class AndExp extends Expression {
|
|
subExpressions: Expression[];
|
|
|
|
static of(_subExpressions: (Expression | null | undefined)[]) {
|
|
const subExpressions = _subExpressions.filter((exp) => !!exp) as Expression[];
|
|
|
|
if (subExpressions.length === 1) {
|
|
return subExpressions[0];
|
|
} else if (subExpressions.length > 0) {
|
|
return new AndExp(subExpressions);
|
|
} else {
|
|
return new TrueExp();
|
|
}
|
|
}
|
|
|
|
constructor(subExpressions: Expression[]) {
|
|
super();
|
|
this.subExpressions = subExpressions;
|
|
}
|
|
|
|
execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext) {
|
|
for (const subExpression of this.subExpressions) {
|
|
inputNoteSet = subExpression.execute(inputNoteSet, executionContext, searchContext);
|
|
}
|
|
|
|
return inputNoteSet;
|
|
}
|
|
}
|
|
|
|
export default AndExp;
|