MCPcopy Index your code
hub / github.com/bytebase/bytebase / dotPathToPathAST

Function dotPathToPathAST

backend/plugin/parser/mongodb/query_span.go:46–59  ·  view source on GitHub ↗

dotPathToPathAST converts a dot-delimited field path (e.g. "contact.phone") into a PathAST with ItemSelector nodes.

(dotPath string)

Source from the content-addressed store, hash-verified

44// dotPathToPathAST converts a dot-delimited field path (e.g. "contact.phone")
45// into a PathAST with ItemSelector nodes.
46func 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}

Callers 1

GetQuerySpanFunction · 0.85

Calls 4

NewItemSelectorFunction · 0.92
SelectorNodeInterface · 0.92
NewPathASTFunction · 0.92
SetNextMethod · 0.65

Tested by

no test coverage detected