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

Method Equals

common/ast/ast.go:507–535  ·  view source on GitHub ↗

Equals returns whether two references are identical to each other.

(other *ReferenceInfo)

Source from the content-addressed store, hash-verified

505
506// Equals returns whether two references are identical to each other.
507func (r *ReferenceInfo) Equals(other *ReferenceInfo) bool {
508 if r.Name != other.Name {
509 return false
510 }
511 if len(r.OverloadIDs) != len(other.OverloadIDs) {
512 return false
513 }
514 if len(r.OverloadIDs) != 0 {
515 overloadMap := make(map[string]struct{}, len(r.OverloadIDs))
516 for _, id := range r.OverloadIDs {
517 overloadMap[id] = struct{}{}
518 }
519 for _, id := range other.OverloadIDs {
520 _, found := overloadMap[id]
521 if !found {
522 return false
523 }
524 }
525 }
526 if r.Value == nil && other.Value == nil {
527 return true
528 }
529 if r.Value == nil && other.Value != nil ||
530 r.Value != nil && other.Value == nil ||
531 r.Value.Equal(other.Value) != types.True {
532 return false
533 }
534 return true
535}
536
537// NewExtension creates an Extension to be recorded on the SourceInfo.
538func NewExtension(id string, version ExtensionVersion, components ...ExtensionComponent) Extension {

Callers 5

setReferenceMethod · 0.80
TestReferenceInfoEqualsFunction · 0.80
TestConvertASTFunction · 0.80

Calls 1

EqualMethod · 0.65

Tested by 4

TestReferenceInfoEqualsFunction · 0.64
TestConvertASTFunction · 0.64