()
| 888 | } |
| 889 | |
| 890 | func (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 |
| 929 | func (e *Env) setCheckerOrError(chk *checker.Env, chkErr error) { |
no test coverage detected