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

Function fieldPathToPathAST

backend/plugin/parser/cosmosdb/query_span.go:97–116  ·  view source on GitHub ↗

fieldPathToPathAST converts an omni analysis.FieldPath to a base.PathAST. The omni analysis represents array access as a separate Selector with Name=indexText and ArrayIndex>=0, following the preceding property selector. The base.PathAST representation merges these: an ArraySelector carries the pro

(fp analysis.FieldPath)

Source from the content-addressed store, hash-verified

95// property name AND the index. So we fold consecutive (ItemSelector, ArraySelector)
96// pairs into a single base.ArraySelector.
97func fieldPathToPathAST(fp analysis.FieldPath) *base.PathAST {
98 if len(fp) == 0 {
99 return nil
100 }
101
102 // Merge omni selectors into base nodes, folding array indices into the
103 // preceding item selector.
104 nodes := mergeSelectors(fp)
105 if len(nodes) == 0 {
106 return nil
107 }
108
109 pathAST := base.NewPathAST(nodes[0])
110 current := pathAST.Root
111 for i := 1; i < len(nodes); i++ {
112 current.SetNext(nodes[i])
113 current = nodes[i]
114 }
115 return pathAST
116}
117
118// mergeSelectors converts omni selectors to base.SelectorNode values,
119// merging an array selector into the preceding item selector when possible.

Callers 1

getQuerySpanImplFunction · 0.85

Calls 3

NewPathASTFunction · 0.92
mergeSelectorsFunction · 0.85
SetNextMethod · 0.65

Tested by

no test coverage detected