(parent *AttributeExpr, seen map[*AttributeExpr]struct{})
| 782 | } |
| 783 | |
| 784 | func (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 | |
| 818 | func (a *AttributeExpr) inheritValidations(parent *AttributeExpr) { |
| 819 | if parent.Validation == nil { |
no test coverage detected