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

Function hasComprehensionVar

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

Source from the content-addressed store, hash-verified

779}
780
781func hasComprehensionVar(e ast.NavigableExpr) bool {
782 idents := ast.MatchDescendants(e, ast.KindMatcher(ast.IdentKind))
783 for _, identNode := range idents {
784 identName := identNode.AsIdent()
785 curr := identNode
786 parent, found := curr.Parent()
787 for found {
788 if parent.Kind() == ast.ComprehensionKind {
789 compre := parent.AsComprehension()
790 if (compre.AccuVar() == identName || compre.IterVar() == identName || compre.IterVar2() == identName) &&
791 curr.ID() != compre.IterRange().ID() && curr.ID() != compre.AccuInit().ID() {
792 return true
793 }
794 }
795 curr = parent
796 parent, found = parent.Parent()
797 }
798 }
799 return false
800}
801
802func isNestedComprehension(e ast.NavigableExpr) bool {
803 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