MCPcopy Index your code
hub / github.com/expr-lang/expr / FieldIndex

Function FieldIndex

checker/info.go:11–28  ·  view source on GitHub ↗
(c *Cache, env Nature, node ast.Node)

Source from the content-addressed store, hash-verified

9)
10
11func FieldIndex(c *Cache, env Nature, node ast.Node) (bool, []int, string) {
12 switch n := node.(type) {
13 case *ast.IdentifierNode:
14 if idx, ok := env.FieldIndex(c, n.Value); ok {
15 return true, idx, n.Value
16 }
17 case *ast.MemberNode:
18 base := n.Node.Nature().Deref(c)
19 if base.Kind == reflect.Struct {
20 if prop, ok := n.Property.(*ast.StringNode); ok {
21 if idx, ok := base.FieldIndex(c, prop.Value); ok {
22 return true, idx, prop.Value
23 }
24 }
25 }
26 }
27 return false, nil, ""
28}
29
30func MethodIndex(c *Cache, env Nature, node ast.Node) (bool, int, string) {
31 switch n := node.(type) {

Callers 2

IdentifierNodeMethod · 0.92
MemberNodeMethod · 0.92

Calls 3

FieldIndexMethod · 0.80
DerefMethod · 0.80
NatureMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…