mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
"use strict";
|
|
|
|
import Expression = require('./expression');
|
|
import NoteSet = require('../note_set');
|
|
import SearchContext = require('../search_context');
|
|
|
|
class ParentOfExp extends Expression {
|
|
private subExpression: Expression;
|
|
|
|
constructor(subExpression: Expression) {
|
|
super();
|
|
|
|
this.subExpression = subExpression;
|
|
}
|
|
|
|
execute(inputNoteSet: NoteSet, executionContext: {}, searchContext: SearchContext) {
|
|
const subInputNoteSet = new NoteSet();
|
|
|
|
for (const note of inputNoteSet.notes) {
|
|
subInputNoteSet.addAll(note.children);
|
|
}
|
|
|
|
const subResNoteSet = this.subExpression.execute(subInputNoteSet, executionContext, searchContext);
|
|
|
|
const resNoteSet = new NoteSet();
|
|
|
|
for (const childNote of subResNoteSet.notes) {
|
|
for (const parentNote of childNote.parents) {
|
|
if (inputNoteSet.hasNote(parentNote)) {
|
|
resNoteSet.add(parentNote);
|
|
}
|
|
}
|
|
}
|
|
|
|
return resNoteSet;
|
|
}
|
|
}
|
|
|
|
export = ParentOfExp;
|