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

Method checkSelect

checker/checker.go:134–162  ·  view source on GitHub ↗
(e ast.Expr)

Source from the content-addressed store, hash-verified

132}
133
134func (c *checker) checkSelect(e ast.Expr) {
135 sel := e.AsSelect()
136 // Before traversing down the tree, try to interpret as qualified name.
137 qualifiers, found := c.computeQualifiers(e)
138 if found {
139 ident := c.env.resolveQualifiedIdent(qualifiers...)
140 if ident != nil {
141 // We don't check for a TestOnly expression here since the `found` result is
142 // always going to be false for TestOnly expressions.
143
144 // Rewrite the node to be a variable reference to the resolved fully-qualified
145 // variable name.
146 name := ident.Name()
147 if ident.requiresDisambiguation {
148 name = "." + name
149 }
150 c.setType(e, ident.Type())
151 c.setReference(e, ast.NewIdentReference(name, ident.Value()))
152 e.SetKindCase(c.NewIdent(e.ID(), name))
153 return
154 }
155 }
156
157 resultType := c.checkSelectField(e, sel.Operand(), sel.FieldName(), false)
158 if sel.IsTestOnly() {
159 resultType = types.BoolType
160 }
161 c.setType(e, substitute(c.mappings, resultType, false))
162}
163
164// computeQualifiers computes the qualified names parts of a select expression.
165func (c *checker) computeQualifiers(e ast.Expr) ([]string, bool) {

Callers 1

checkMethod · 0.95

Calls 15

computeQualifiersMethod · 0.95
setTypeMethod · 0.95
setReferenceMethod · 0.95
checkSelectFieldMethod · 0.95
NewIdentReferenceFunction · 0.92
substituteFunction · 0.85
resolveQualifiedIdentMethod · 0.80
AsSelectMethod · 0.65
NameMethod · 0.65
TypeMethod · 0.65
ValueMethod · 0.65
SetKindCaseMethod · 0.65

Tested by

no test coverage detected