@@ -2,6 +2,7 @@ package query
22
33import (
44 "fmt"
5+
56 "github.com/pelletier/go-toml"
67)
78
@@ -44,16 +45,16 @@ func newMatchKeyFn(name string) *matchKeyFn {
4445func (f * matchKeyFn ) call (node interface {}, ctx * queryContext ) {
4546 if array , ok := node .([]* toml.Tree ); ok {
4647 for _ , tree := range array {
47- item := tree .Get ( f .Name )
48+ item := tree .GetPath ([] string { f .Name } )
4849 if item != nil {
49- ctx .lastPosition = tree .GetPosition ( f .Name )
50+ ctx .lastPosition = tree .GetPositionPath ([] string { f .Name } )
5051 f .next .call (item , ctx )
5152 }
5253 }
5354 } else if tree , ok := node .(* toml.Tree ); ok {
54- item := tree .Get ( f .Name )
55+ item := tree .GetPath ([] string { f .Name } )
5556 if item != nil {
56- ctx .lastPosition = tree .GetPosition ( f .Name )
57+ ctx .lastPosition = tree .GetPositionPath ([] string { f .Name } )
5758 f .next .call (item , ctx )
5859 }
5960 }
@@ -129,8 +130,8 @@ func newMatchAnyFn() *matchAnyFn {
129130func (f * matchAnyFn ) call (node interface {}, ctx * queryContext ) {
130131 if tree , ok := node .(* toml.Tree ); ok {
131132 for _ , k := range tree .Keys () {
132- v := tree .Get ( k )
133- ctx .lastPosition = tree .GetPosition ( k )
133+ v := tree .GetPath ([] string { k } )
134+ ctx .lastPosition = tree .GetPositionPath ([] string { k } )
134135 f .next .call (v , ctx )
135136 }
136137 }
@@ -168,8 +169,8 @@ func (f *matchRecursiveFn) call(node interface{}, ctx *queryContext) {
168169 var visit func (tree * toml.Tree )
169170 visit = func (tree * toml.Tree ) {
170171 for _ , k := range tree .Keys () {
171- v := tree .Get ( k )
172- ctx .lastPosition = tree .GetPosition ( k )
172+ v := tree .GetPath ([] string { k } )
173+ ctx .lastPosition = tree .GetPositionPath ([] string { k } )
173174 f .next .call (v , ctx )
174175 switch node := v .(type ) {
175176 case * toml.Tree :
@@ -207,9 +208,9 @@ func (f *matchFilterFn) call(node interface{}, ctx *queryContext) {
207208 switch castNode := node .(type ) {
208209 case * toml.Tree :
209210 for _ , k := range castNode .Keys () {
210- v := castNode .Get ( k )
211+ v := castNode .GetPath ([] string { k } )
211212 if fn (v ) {
212- ctx .lastPosition = castNode .GetPosition ( k )
213+ ctx .lastPosition = castNode .GetPositionPath ([] string { k } )
213214 f .next .call (v , ctx )
214215 }
215216 }
0 commit comments