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

Method GetMetadata

checker/printer.go:30–66  ·  view source on GitHub ↗
(elem any)

Source from the content-addressed store, hash-verified

28var _ debug.Adorner = &semanticAdorner{}
29
30func (a *semanticAdorner) GetMetadata(elem any) string {
31 result := ""
32 e, isExpr := elem.(ast.Expr)
33 if !isExpr {
34 return result
35 }
36 t := a.checked.TypeMap()[e.ID()]
37 if t != nil {
38 result += "~"
39 result += FormatCELType(t)
40 }
41
42 switch e.Kind() {
43 case ast.IdentKind,
44 ast.CallKind,
45 ast.ListKind,
46 ast.StructKind,
47 ast.SelectKind:
48 if ref, found := a.checked.ReferenceMap()[e.ID()]; found {
49 if len(ref.OverloadIDs) == 0 {
50 result += "^" + ref.Name
51 } else {
52 sort.Strings(ref.OverloadIDs)
53 for i, overload := range ref.OverloadIDs {
54 if i == 0 {
55 result += "^"
56 } else {
57 result += "|"
58 }
59 result += overload
60 }
61 }
62 }
63 }
64
65 return result
66}
67
68// Print returns a string representation of the Expr message,
69// annotated with types from the CheckedExpr. The Expr must

Callers

nothing calls this directly

Calls 5

TypeMapMethod · 0.80
ReferenceMapMethod · 0.80
FormatCELTypeFunction · 0.70
IDMethod · 0.65
KindMethod · 0.65

Tested by

no test coverage detected