From c1a566e5f5eb39e71ef26aea7641e8c57c4693a7 Mon Sep 17 00:00:00 2001 From: Wen Bo Li <50884368+wenovus@users.noreply.github.com> Date: Tue, 9 Jul 2024 21:07:21 -0700 Subject: [PATCH] Clarify comments on how identity children is built up (#236) --- pkg/yang/identity.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/yang/identity.go b/pkg/yang/identity.go index a766859..615bff7 100644 --- a/pkg/yang/identity.go +++ b/pkg/yang/identity.go @@ -151,10 +151,11 @@ func (ms *Modules) resolveIdentities() []error { } } - // Determine which identities have a base statement, and link this to a - // fully resolved identity statement. The intention here is to make sure - // that the Children slice is fully populated with pointers to all identities - // that have a base, so that we can do inheritance of these later. + // Now, we want to create for all identities a view of all of their children. + // A child identity here means an inherited identity. + // + // We start by finding the direct children of all identities using the + // 'base' statement. for _, i := range ms.typeDict.identities.dict { if i.Identity.Base != nil { // This identity inherits from one or more other identities. @@ -174,7 +175,8 @@ func (ms *Modules) resolveIdentities() []error { } } - // Do a final sweep through the identities to build up their children. + // Now, we can find all transitive identities by recursively populating + // the children of each identity. for _, i := range ms.typeDict.identities.dict { newValues := []*Identity{} for _, j := range i.Identity.Values {