(c *Cache, env Nature, node ast.Node)
| 9 | ) |
| 10 | |
| 11 | func 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 | |
| 30 | func MethodIndex(c *Cache, env Nature, node ast.Node) (bool, int, string) { |
| 31 | switch n := node.(type) { |
no test coverage detected
searching dependent graphs…