dotPathToPathAST converts a dot-delimited field path (e.g. "contact.phone") into a PathAST with ItemSelector nodes.
(dotPath string)
| 44 | // dotPathToPathAST converts a dot-delimited field path (e.g. "contact.phone") |
| 45 | // into a PathAST with ItemSelector nodes. |
| 46 | func dotPathToPathAST(dotPath string) *base.PathAST { |
| 47 | parts := strings.Split(dotPath, ".") |
| 48 | if len(parts) == 0 { |
| 49 | return nil |
| 50 | } |
| 51 | root := base.NewItemSelector(parts[0]) |
| 52 | current := base.SelectorNode(root) |
| 53 | for _, part := range parts[1:] { |
| 54 | next := base.NewItemSelector(part) |
| 55 | current.SetNext(next) |
| 56 | current = next |
| 57 | } |
| 58 | return base.NewPathAST(root) |
| 59 | } |
no test coverage detected