-
-
Notifications
You must be signed in to change notification settings - Fork 550
/
operator_filter.go
32 lines (28 loc) · 913 Bytes
/
operator_filter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package yqlib
import (
"container/list"
)
func filterOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debugf("filterOperation")
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
children := context.SingleChildContext(candidate)
splatted, err := splat(children, traversePreferences{})
if err != nil {
return Context{}, err
}
filtered, err := selectOperator(d, splatted, expressionNode)
if err != nil {
return Context{}, err
}
selfExpression := &ExpressionNode{Operation: &Operation{OperationType: selfReferenceOpType}}
collected, err := collectTogether(d, filtered, selfExpression)
if err != nil {
return Context{}, err
}
collected.Style = candidate.Style
results.PushBack(collected)
}
return context.ChildContext(results), nil
}