Debian Codegraph @

ext/guards.go

raw symbols SCIP
1 // Copyright 2020 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 extscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/ext`/
16
17 import (
18 "github.com/google/cel-go/common/astscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/ast`/"
19 "github.com/google/cel-go/common/typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/"
20 "github.com/google/cel-go/common/types/refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/"
21 )
22
23 // function invocation guards for common call signatures within extension functions.
24
25 func intOrErrorscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/ext`/intOrError().(i int64, err error) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# {
26 if err != nil {
27 return typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/.NewErrFromStringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/NewErrFromString().(err.Error())
28 }
29 return typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/.Intscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Int#(i)
30 }
31
32 func bytesOrErrorscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/ext`/bytesOrError().(bytes []byte, err error) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# {
33 if err != nil {
34 return typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/.NewErrFromStringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/NewErrFromString().(err.Error())
35 }
36 return typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/.Bytesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Bytes#(bytes)
37 }
38
39 func stringOrErrorscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/ext`/stringOrError().(str string, err error) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# {
40 if err != nil {
41 return typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/.NewErrFromStringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/NewErrFromString().(err.Error())
42 }
43 return typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/.Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/String#(str)
44 }
45
46 func listStringOrErrorscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/ext`/listStringOrError().(strs []string, err error) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# {
47 if err != nil {
48 return typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/.NewErrFromStringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/NewErrFromString().(err.Error())
49 }
50 return typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/.DefaultTypeAdapterscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/DefaultTypeAdapter..NativeToValuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/defaultTypeAdapter#NativeToValue().(strs)
51 }
52
53 func extractIdentscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/ext`/extractIdent().(target astscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/ast`/.Exprscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/ast`/Expr#) (string, bool) {
54 switch target.Kindscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/ast`/Expr#Kind.() {
55 case astscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/ast`/.IdentKindscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/ast`/IdentKind.:
56 return target.AsIdentscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/ast`/Expr#AsIdent.(), true
57 default:
58 return "", false
59 }
60 }
61
62 func macroTargetMatchesNamespacescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/ext`/macroTargetMatchesNamespace().(ns string, target astscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/ast`/.Exprscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/ast`/Expr#) bool {
63 if id, found := extractIdentscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/ext`/extractIdent().(target); found {
64 return id == ns
65 }
66 return false
67 }