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

Function matchInConstantList

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

Source from the content-addressed store, hash-verified

166}
167
168func matchInConstantList(a *ast.AST) ast.ExprMatcher {
169 return func(e ast.NavigableExpr) bool {
170 if e.Kind() != ast.CallKind {
171 return false
172 }
173 call := e.AsCall()
174 if call.FunctionName() != operators.In {
175 return false
176 }
177 aggregateVal := call.Args()[1]
178 if aggregateVal.Kind() != ast.ListKind {
179 return false
180 }
181 listVal := aggregateVal.AsList()
182 for _, elem := range listVal.Elements() {
183 if r, found := a.ReferenceMap()[elem.ID()]; found {
184 if r.Value != nil {
185 continue
186 }
187 }
188 if elem.Kind() != ast.LiteralKind {
189 return false
190 }
191 lit := elem.AsLiteral()
192 if !(lit.Type() == cel.StringType || lit.Type() == cel.IntType ||
193 lit.Type() == cel.UintType || lit.Type() == cel.BoolType) {
194 return false
195 }
196 }
197 return true
198 }
199}
200
201func setsIntersects(listA, listB ref.Val) ref.Val {
202 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