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

Function hasComprehensionVar

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

Source from the content-addressed store, hash-verified

712}
713
714func hasComprehensionVar(e ast.NavigableExpr) bool {
715 idents := ast.MatchDescendants(e, ast.KindMatcher(ast.IdentKind))
716 for _, identNode := range idents {
717 identName := identNode.AsIdent()
718 curr := identNode
719 parent, found := curr.Parent()
720 for found {
721 if parent.Kind() == ast.ComprehensionKind {
722 compre := parent.AsComprehension()
723 if (compre.AccuVar() == identName || compre.IterVar() == identName || compre.IterVar2() == identName) &&
724 curr.ID() != compre.IterRange().ID() && curr.ID() != compre.AccuInit().ID() {
725 return true
726 }
727 }
728 curr = parent
729 parent, found = parent.Parent()
730 }
731 }
732 return false
733}
734
735func isNestedComprehension(e ast.NavigableExpr) bool {
736 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