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

Method initChecker

cel/env.go:890–926  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

888}
889
890func (e *Env) initChecker() (*checker.Env, error) {
891 e.chkOnce.Do(func() {
892 chkOpts := []checker.Option{}
893 chkOpts = append(chkOpts, e.chkOpts...)
894 chkOpts = append(chkOpts,
895 checker.CrossTypeNumericComparisons(
896 e.HasFeature(featureCrossTypeNumericComparisons)))
897 chkOpts = append(chkOpts,
898 checker.JSONFieldNames(e.HasFeature(featureJSONFieldNames)))
899
900 ce, err := checker.NewEnv(e.Container, e.provider, chkOpts...)
901 if err != nil {
902 e.setCheckerOrError(nil, err)
903 return
904 }
905 // Add the statically configured declarations.
906 err = ce.AddIdents(e.variables...)
907 if err != nil {
908 e.setCheckerOrError(nil, err)
909 return
910 }
911 // Add the function declarations which are derived from the FunctionDecl instances.
912 for _, fn := range e.functions {
913 if fn.IsDeclarationDisabled() {
914 continue
915 }
916 err = ce.AddFunctions(fn)
917 if err != nil {
918 e.setCheckerOrError(nil, err)
919 return
920 }
921 }
922 // Add function declarations here separately.
923 e.setCheckerOrError(ce, nil)
924 })
925 return e.getCheckerOrError()
926}
927
928// setCheckerOrError sets the checker.Env or error state in a concurrency-safe manner
929func (e *Env) setCheckerOrError(chk *checker.Env, chkErr error) {

Callers 2

CheckMethod · 0.95
configureMethod · 0.95

Calls 9

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

Tested by

no test coverage detected