yq/pkg/yqlib/operator_parent.go
2024-01-11 13:17:34 +11:00

20 lines
438 B
Go

package yqlib
import "container/list"
func getParentOperator(_ *dataTreeNavigator, context Context, _ *ExpressionNode) (Context, error) {
log.Debugf("-- getParentOperator")
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
if candidate.Parent != nil {
results.PushBack(candidate.Parent)
}
}
return context.ChildContext(results), nil
}