MCPcopy Create free account
hub / github.com/cel-expr/cel-go / hasComprehensionVar

Function hasComprehensionVar

cel/folding.go:689–708  ·  view source on GitHub ↗
(e ast.NavigableExpr)

Source from the content-addressed store, hash-verified

687}
688
689func hasComprehensionVar(e ast.NavigableExpr) bool {
690 idents := ast.MatchDescendants(e, ast.KindMatcher(ast.IdentKind))
691 for _, identNode := range idents {
692 identName := identNode.AsIdent()
693 curr := identNode
694 parent, found := curr.Parent()
695 for found {
696 if parent.Kind() == ast.ComprehensionKind {
697 compre := parent.AsComprehension()
698 if (compre.AccuVar() == identName || compre.IterVar() == identName || compre.IterVar2() == identName) &&
699 curr.ID() != compre.IterRange().ID() && curr.ID() != compre.AccuInit().ID() {
700 return true
701 }
702 }
703 curr = parent
704 parent, found = parent.Parent()
705 }
706 }
707 return false
708}
709
710func isNestedComprehension(e ast.NavigableExpr) bool {
711 parent, found := e.Parent()

Callers 2

constantExprMatcherMethod · 0.85
constantCallMatcherFunction · 0.85

Calls 12

MatchDescendantsFunction · 0.92
KindMatcherFunction · 0.92
AsIdentMethod · 0.65
ParentMethod · 0.65
KindMethod · 0.65
AsComprehensionMethod · 0.65
AccuVarMethod · 0.65
IterVarMethod · 0.65
IterVar2Method · 0.65
IDMethod · 0.65
IterRangeMethod · 0.65
AccuInitMethod · 0.65

Tested by

no test coverage detected