• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AsaiYusuke / jsonpath / 16410926563

21 Jul 2025 07:14AM UTC coverage: 17.851% (-79.5%) from 97.363%
16410926563

Pull #46

github

AsaiYusuke
refactor: move syntax and tests to internal directory

Separate directory structure from public API by relocating syntax
and test files under internal/ directory structure.
Pull Request #46: Move syntax to the internal directory and reorganize tests

181 of 406 new or added lines in 17 files covered. (44.58%)

3 existing lines in 1 file now uncovered.

676 of 3787 relevant lines covered (17.85%)

17.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

14.12
/internal/syntax/syntax_basic_node.go
1
package syntax
2

3
import "github.com/AsaiYusuke/jsonpath/errors"
4

5
type syntaxBasicNode struct {
6
        text          string
7
        connectedText string
8
        valueGroup    bool
9
        next          syntaxNode
10
        accessorMode  bool
11
        errorRuntime  *errorBasicRuntime
12
}
13

14
func (i *syntaxBasicNode) setText(text string) {
×
15
        i.text = text
×
16
}
×
17

18
func (i *syntaxBasicNode) getText() string {
1✔
19
        return i.text
1✔
20
}
1✔
21

22
func (i *syntaxBasicNode) setValueGroup() {
×
23
        i.valueGroup = true
×
24
}
×
25

26
func (i *syntaxBasicNode) isValueGroup() bool {
1✔
27
        return i.valueGroup
1✔
28
}
1✔
29

30
func (i *syntaxBasicNode) setConnectedText(text string) {
1✔
31
        i.connectedText = text
1✔
32
}
1✔
33

34
func (i *syntaxBasicNode) getConnectedText() string {
×
35
        return i.connectedText
×
36
}
×
37

38
func (i *syntaxBasicNode) setNext(next syntaxNode) {
×
39
        if i.next != nil {
×
40
                i.next.setNext(next)
×
41
        } else {
×
42
                i.next = next
×
43
        }
×
44
}
45

46
func (i *syntaxBasicNode) getNext() syntaxNode {
3✔
47
        return i.next
3✔
48
}
3✔
49

50
func (i *syntaxBasicNode) retrieveAnyValueNext(
51
        root interface{}, nextSrc interface{}, container *bufferContainer) errorRuntime {
×
52

×
53
        if i.next != nil {
×
54
                return i.next.retrieve(root, nextSrc, container)
×
55
        }
×
56

57
        if i.accessorMode {
×
58
                container.result = append(container.result, Accessor{
×
59
                        Get: func() interface{} { return nextSrc },
×
60
                        Set: nil,
61
                })
62
        } else {
×
63
                container.result = append(container.result, nextSrc)
×
64
        }
×
65

66
        return nil
×
67
}
68

69
func (i *syntaxBasicNode) retrieveMapNext(
70
        root interface{}, currentMap map[string]interface{}, key string, container *bufferContainer) errorRuntime {
×
71

×
72
        nextNode, ok := currentMap[key]
×
73
        if !ok {
×
NEW
74
                return newErrorMemberNotExist(i.errorRuntime.node)
×
75
        }
×
76

77
        if i.next != nil {
×
78
                return i.next.retrieve(root, nextNode, container)
×
79
        }
×
80

81
        if i.accessorMode {
×
82
                container.result = append(container.result, Accessor{
×
83
                        Get: func() interface{} { return currentMap[key] },
×
84
                        Set: func(value interface{}) { currentMap[key] = value },
×
85
                })
86
        } else {
×
87
                container.result = append(container.result, nextNode)
×
88
        }
×
89

90
        return nil
×
91
}
92

93
func (i *syntaxBasicNode) retrieveListNext(
94
        root interface{}, currentList []interface{}, index int, container *bufferContainer) errorRuntime {
×
95

×
96
        if i.next != nil {
×
97
                return i.next.retrieve(root, currentList[index], container)
×
98
        }
×
99

100
        if i.accessorMode {
×
101
                container.result = append(container.result, Accessor{
×
102
                        Get: func() interface{} { return currentList[index] },
×
103
                        Set: func(value interface{}) { currentList[index] = value },
×
104
                })
105
        } else {
×
106
                container.result = append(container.result, currentList[index])
×
107
        }
×
108

109
        return nil
×
110
}
111

112
func (i *syntaxBasicNode) setAccessorMode(mode bool) {
×
113
        i.accessorMode = mode
×
114
}
×
115

116
func (i *syntaxBasicNode) addDeepestError(
117
        err errorRuntime, deepestTextLen int, deepestError errorRuntime) (int, errorRuntime) {
×
118

×
119
        textLength := len(err.getSyntaxNode().getConnectedText())
×
120

×
121
        if deepestTextLen == 0 || deepestTextLen > textLength {
×
122
                return textLength, err
×
123
        }
×
124

125
        if deepestTextLen == textLength {
×
NEW
126
                if adapter, ok := deepestError.(errorRuntimeAdapter); ok {
×
NEW
127
                        if _, isTypeUnmatched := adapter.err.(errors.ErrorTypeUnmatched); isTypeUnmatched {
×
NEW
128
                                return deepestTextLen, err
×
NEW
129
                        }
×
130
                }
131
        }
132

133
        return deepestTextLen, deepestError
×
134
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc