-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsyntax_node_qualifier_union.go
55 lines (44 loc) · 1.19 KB
/
syntax_node_qualifier_union.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package jsonpath
import "reflect"
type syntaxUnionQualifier struct {
*syntaxBasicNode
subscripts []syntaxSubscript
}
func (u *syntaxUnionQualifier) retrieve(
root, current interface{}, container *bufferContainer) errorRuntime {
srcArray, ok := current.([]interface{})
if !ok {
foundType := msgTypeNull
if current != nil {
foundType = reflect.TypeOf(current).String()
}
return ErrorTypeUnmatched{
errorBasicRuntime: u.errorRuntime,
expectedType: msgTypeArray,
foundType: foundType,
}
}
var deepestTextLen int
var deepestError errorRuntime
for _, subscript := range u.subscripts {
for _, index := range subscript.getIndexes(len(srcArray)) {
if err := u.retrieveListNext(root, srcArray, index, container); err != nil {
if len(container.result) == 0 {
deepestTextLen, deepestError = u.addDeepestError(err, deepestTextLen, deepestError)
}
}
}
}
if len(container.result) > 0 {
return nil
}
if deepestError == nil {
return ErrorMemberNotExist{
errorBasicRuntime: u.errorRuntime,
}
}
return deepestError
}
func (u *syntaxUnionQualifier) merge(union *syntaxUnionQualifier) {
u.subscripts = append(u.subscripts, union.subscripts...)
}