mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-07 02:48:27 +08:00
Dont create entries when selecting
This commit is contained in:
+19
-7
@@ -1,18 +1,30 @@
|
||||
package yqlib
|
||||
|
||||
import "container/list"
|
||||
import (
|
||||
"container/list"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
MatchingNodes *list.List
|
||||
Variables map[string]*list.List
|
||||
MatchingNodes *list.List
|
||||
Variables map[string]*list.List
|
||||
DontAutoCreate bool
|
||||
}
|
||||
|
||||
func (n *Context) SingleChildContext(candidate *CandidateNode) Context {
|
||||
elMap := list.New()
|
||||
elMap.PushBack(candidate)
|
||||
return Context{MatchingNodes: elMap, Variables: n.Variables}
|
||||
list := list.New()
|
||||
list.PushBack(candidate)
|
||||
return n.ChildContext(list)
|
||||
}
|
||||
|
||||
func (n *Context) ChildContext(results *list.List) Context {
|
||||
return Context{MatchingNodes: results, Variables: n.Variables}
|
||||
clone := Context{}
|
||||
err := copier.Copy(&clone, n)
|
||||
if err != nil {
|
||||
log.Error("Error cloning context :(")
|
||||
panic(err)
|
||||
}
|
||||
clone.MatchingNodes = results
|
||||
return clone
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user