Debian Codegraph @

checker/options.go

raw symbols SCIP
1 // Copyright 2022 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package checker
16
17 type options struct {
18 crossTypeNumericComparisons bool
19 homogeneousAggregateLiterals bool
20 validatedDeclarations *Scopes
21 }
22
23 // Option is a functional option for configuring the type-checker
24 type Option func(*options) error
25
26 // CrossTypeNumericComparisons toggles type-checker support for numeric comparisons across type
27 // See https://github.com/google/cel-spec/wiki/proposal-210 for more details.
28 func CrossTypeNumericComparisons(enabled bool) Option {
29 return func(opts *options) error {
30 opts.crossTypeNumericComparisons = enabled
31 return nil
32 }
33 }
34
35 // ValidatedDeclarations provides a references to validated declarations which will be copied
36 // into new checker instances.
37 func ValidatedDeclarations(env *Env) Option {
38 return func(opts *options) error {
39 opts.validatedDeclarations = env.validatedDeclarations()
40 return nil
41 }
42 }