MCPcopy
hub / github.com/dgraph-io/dgraph / collectVars

Method collectVars

dql/parser.go:791–822  ·  view source on GitHub ↗
(v *Vars)

Source from the content-addressed store, hash-verified

789}
790
791func (gq *GraphQuery) collectVars(v *Vars) {
792 if gq.Var != "" {
793 v.Defines = append(v.Defines, gq.Var)
794 }
795 if gq.FacetVar != nil {
796 for _, va := range gq.FacetVar {
797 v.Defines = append(v.Defines, va)
798 }
799 }
800 for _, va := range gq.NeedsVar {
801 v.Needs = append(v.Needs, va.Name)
802 }
803
804 for _, ch := range gq.Children {
805 ch.collectVars(v)
806 }
807 if gq.Filter != nil {
808 gq.Filter.collectVars(v)
809 }
810 if gq.MathExp != nil {
811 gq.MathExp.collectVars(v)
812 }
813
814 shortestPathFrom := gq.ShortestPathArgs.From
815 if shortestPathFrom != nil && len(shortestPathFrom.NeedsVar) > 0 {
816 v.Needs = append(v.Needs, shortestPathFrom.NeedsVar[0].Name)
817 }
818 shortestPathTo := gq.ShortestPathArgs.To
819 if shortestPathTo != nil && len(shortestPathTo.NeedsVar) > 0 {
820 v.Needs = append(v.Needs, shortestPathTo.NeedsVar[0].Name)
821 }
822}
823
824func (f *MathTree) collectVars(v *Vars) {
825 if f == nil {

Callers 1

ParseWithNeedVarsFunction · 0.95

Calls 1

collectVarsMethod · 0.45

Tested by

no test coverage detected