(c *Cache, env Nature, node ast.Node)
| 28 | } |
| 29 | |
| 30 | func MethodIndex(c *Cache, env Nature, node ast.Node) (bool, int, string) { |
| 31 | switch n := node.(type) { |
| 32 | case *ast.IdentifierNode: |
| 33 | if env.Kind == reflect.Struct { |
| 34 | if m, ok := env.Get(c, n.Value); ok && m.TypeData != nil { |
| 35 | return m.Method, m.MethodIndex, n.Value |
| 36 | } |
| 37 | } |
| 38 | case *ast.MemberNode: |
| 39 | if name, ok := n.Property.(*ast.StringNode); ok { |
| 40 | base := n.Node.Type() |
| 41 | if base != nil && base.Kind() != reflect.Interface { |
| 42 | if m, ok := base.MethodByName(name.Value); ok { |
| 43 | return true, m.Index, name.Value |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | return false, 0, "" |
| 49 | } |
| 50 | |
| 51 | func TypedFuncIndex(fn reflect.Type, method bool) (int, bool) { |
| 52 | if fn == nil { |
no test coverage detected
searching dependent graphs…