MCPcopy Create free account
hub / github.com/goadesign/goa / inheritRecursive

Method inheritRecursive

expr/attribute.go:784–816  ·  view source on GitHub ↗
(parent *AttributeExpr, seen map[*AttributeExpr]struct{})

Source from the content-addressed store, hash-verified

782}
783
784func (a *AttributeExpr) inheritRecursive(parent *AttributeExpr, seen map[*AttributeExpr]struct{}) {
785 if !a.shouldInherit(parent) {
786 return
787 }
788 for _, nat := range *AsObject(a.Type) {
789 if patt := AsObject(parent.Type).Attribute(nat.Name); patt != nil {
790 att := nat.Attribute
791 if att.Description == "" {
792 att.Description = patt.Description
793 }
794 att.inheritValidations(patt)
795 if att.DefaultValue == nil {
796 att.DefaultValue = patt.DefaultValue
797 }
798 if att.Type == nil {
799 att.Type = patt.Type
800 } else if att.shouldInherit(patt) {
801 if _, ok := seen[att]; ok {
802 continue
803 }
804 seen[att] = struct{}{}
805 for _, nat := range *AsObject(att.Type) {
806 child := nat.Attribute
807 parent := AsObject(patt.Type).Attribute(nat.Name)
808 if parent != nil {
809 child.inheritValidations(parent)
810 child.inheritRecursive(parent, seen)
811 }
812 }
813 }
814 }
815 }
816}
817
818func (a *AttributeExpr) inheritValidations(parent *AttributeExpr) {
819 if parent.Validation == nil {

Callers 1

InheritMethod · 0.95

Calls 4

shouldInheritMethod · 0.95
AsObjectFunction · 0.85
inheritValidationsMethod · 0.80
AttributeMethod · 0.65

Tested by

no test coverage detected