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

Method initChecker

cel/env.go:969–1016  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

967}
968
969func (e *Env) initChecker() (*checker.Env, error) {
970 e.chkOnce.Do(func() {
971 chkOpts := []checker.Option{}
972 chkOpts = append(chkOpts, e.chkOpts...)
973 chkOpts = append(chkOpts,
974 checker.CrossTypeNumericComparisons(
975 e.HasFeature(featureCrossTypeNumericComparisons)))
976 chkOpts = append(chkOpts,
977 checker.JSONFieldNames(e.HasFeature(featureJSONFieldNames)))
978
979 if e.parent != nil && e.funcsShared {
980 parentChk, err := e.parent.initChecker()
981 if err != nil {
982 e.setCheckerOrError(nil, err)
983 return
984 }
985 chkOpts = append(chkOpts, checker.ValidatedDeclarations(parentChk))
986 }
987
988 ce, err := checker.NewEnv(e.Container, e.provider, chkOpts...)
989 if err != nil {
990 e.setCheckerOrError(nil, err)
991 return
992 }
993 // Add the statically configured declarations.
994 err = ce.AddIdents(e.variables...)
995 if err != nil {
996 e.setCheckerOrError(nil, err)
997 return
998 }
999 // Add the function declarations which are derived from the FunctionDecl instances.
1000 if e.parent == nil || !e.funcsShared {
1001 for _, fn := range e.functions {
1002 if fn.IsDeclarationDisabled() {
1003 continue
1004 }
1005 err = ce.AddFunctions(fn)
1006 if err != nil {
1007 e.setCheckerOrError(nil, err)
1008 return
1009 }
1010 }
1011 }
1012 // Add function declarations here separately.
1013 e.setCheckerOrError(ce, nil)
1014 })
1015 return e.getCheckerOrError()
1016}
1017
1018// setCheckerOrError sets the checker.Env or error state in a concurrency-safe manner
1019func (e *Env) setCheckerOrError(chk *checker.Env, chkErr error) {

Callers 2

CheckMethod · 0.95
configureMethod · 0.95

Calls 10

HasFeatureMethod · 0.95
setCheckerOrErrorMethod · 0.95
AddIdentsMethod · 0.95
AddFunctionsMethod · 0.95
getCheckerOrErrorMethod · 0.95
JSONFieldNamesFunction · 0.92
ValidatedDeclarationsFunction · 0.92
NewEnvFunction · 0.92
IsDeclarationDisabledMethod · 0.80

Tested by

no test coverage detected