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

Function matchInConstantList

ext/sets.go:160–191  ·  view source on GitHub ↗
(a *ast.AST)

Source from the content-addressed store, hash-verified

158}
159
160func matchInConstantList(a *ast.AST) ast.ExprMatcher {
161 return func(e ast.NavigableExpr) bool {
162 if e.Kind() != ast.CallKind {
163 return false
164 }
165 call := e.AsCall()
166 if call.FunctionName() != operators.In {
167 return false
168 }
169 aggregateVal := call.Args()[1]
170 if aggregateVal.Kind() != ast.ListKind {
171 return false
172 }
173 listVal := aggregateVal.AsList()
174 for _, elem := range listVal.Elements() {
175 if r, found := a.ReferenceMap()[elem.ID()]; found {
176 if r.Value != nil {
177 continue
178 }
179 }
180 if elem.Kind() != ast.LiteralKind {
181 return false
182 }
183 lit := elem.AsLiteral()
184 if !(lit.Type() == cel.StringType || lit.Type() == cel.IntType ||
185 lit.Type() == cel.UintType || lit.Type() == cel.BoolType) {
186 return false
187 }
188 }
189 return true
190 }
191}
192
193func setsIntersects(listA, listB ref.Val) ref.Val {
194 lA := listA.(traits.Lister)

Callers 1

OptimizeMethod · 0.85

Calls 10

ReferenceMapMethod · 0.80
KindMethod · 0.65
AsCallMethod · 0.65
FunctionNameMethod · 0.65
ArgsMethod · 0.65
AsListMethod · 0.65
ElementsMethod · 0.65
IDMethod · 0.65
AsLiteralMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected