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

Method QualifyIfPresent

interpreter/interpretable.go:1647–1661  ·  view source on GitHub ↗

QualifyIfPresent conditionally qualifies the variable and only records a value if one is present.

(vars Activation, obj any, presenceOnly bool)

Source from the content-addressed store, hash-verified

1645
1646// QualifyIfPresent conditionally qualifies the variable and only records a value if one is present.
1647func (e *evalWatchQual) QualifyIfPresent(vars Activation, obj any, presenceOnly bool) (any, bool, error) {
1648 out, present, err := e.Qualifier.QualifyIfPresent(vars, obj, presenceOnly)
1649 var val ref.Val
1650 if err != nil {
1651 val = types.LabelErrNode(e.ID(), types.WrapErr(err))
1652 } else if out != nil {
1653 val = e.adapter.NativeToValue(out)
1654 } else if presenceOnly {
1655 val = types.Bool(present)
1656 }
1657 if present || presenceOnly {
1658 e.observer(vars, e.ID(), e.Qualifier, val)
1659 }
1660 return out, present, err
1661}
1662
1663// evalWatchConst describes a watcher of an instConst Interpretable.
1664type evalWatchConst struct {

Callers

nothing calls this directly

Calls 6

LabelErrNodeFunction · 0.92
WrapErrFunction · 0.92
BoolTypeAlias · 0.92
QualifyIfPresentMethod · 0.65
IDMethod · 0.65
NativeToValueMethod · 0.65

Tested by

no test coverage detected