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

Method Equals

common/ast/ast.go:499–527  ·  view source on GitHub ↗

Equals returns whether two references are identical to each other.

(other *ReferenceInfo)

Source from the content-addressed store, hash-verified

497
498// Equals returns whether two references are identical to each other.
499func (r *ReferenceInfo) Equals(other *ReferenceInfo) bool {
500 if r.Name != other.Name {
501 return false
502 }
503 if len(r.OverloadIDs) != len(other.OverloadIDs) {
504 return false
505 }
506 if len(r.OverloadIDs) != 0 {
507 overloadMap := make(map[string]struct{}, len(r.OverloadIDs))
508 for _, id := range r.OverloadIDs {
509 overloadMap[id] = struct{}{}
510 }
511 for _, id := range other.OverloadIDs {
512 _, found := overloadMap[id]
513 if !found {
514 return false
515 }
516 }
517 }
518 if r.Value == nil && other.Value == nil {
519 return true
520 }
521 if r.Value == nil && other.Value != nil ||
522 r.Value != nil && other.Value == nil ||
523 r.Value.Equal(other.Value) != types.True {
524 return false
525 }
526 return true
527}
528
529// NewExtension creates an Extension to be recorded on the SourceInfo.
530func 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