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

Function isBindable

cel/inlining.go:220–235  ·  view source on GitHub ↗

isBindable indicates whether the inlined type can be used within a cel.bind() if the expression being replaced occurs within a presence test. Value types with a size() method or field selection support can be bound. In future iterations, support may also be added for indexer types which can be rewr

(matches []ast.NavigableExpr, inlined ast.Expr, inlinedType *Type)

Source from the content-addressed store, hash-verified

218// expression; however, this would imply a rewrite of the inlined expression that may not be necessary
219// in most cases.
220func isBindable(matches []ast.NavigableExpr, inlined ast.Expr, inlinedType *Type) bool {
221 if inlinedType.IsAssignableType(NullType) ||
222 inlinedType.HasTrait(traits.SizerType) {
223 return true
224 }
225 for _, m := range matches {
226 if m.Kind() != ast.SelectKind {
227 continue
228 }
229 sel := m.AsSelect()
230 if sel.IsTestOnly() {
231 return false
232 }
233 }
234 return true
235}
236
237// matchVariable matches simple identifiers, select expressions, and presence test expressions
238// which match the (potentially) qualified variable name provided as input.

Callers 1

OptimizeMethod · 0.85

Calls 5

IsAssignableTypeMethod · 0.80
HasTraitMethod · 0.65
KindMethod · 0.65
AsSelectMethod · 0.65
IsTestOnlyMethod · 0.65

Tested by

no test coverage detected