initAttrFromDesign overrides the type of att with the one of patt and initializes other non-initialized fields of att with the one of patt except Meta.
(att, patt *AttributeExpr)
| 1135 | // initializes other non-initialized fields of att with the one of patt except |
| 1136 | // Meta. |
| 1137 | func initAttrFromDesign(att, patt *AttributeExpr) { |
| 1138 | if patt == nil || patt.Type == Empty { |
| 1139 | return |
| 1140 | } |
| 1141 | att.Type = patt.Type |
| 1142 | if att.Description == "" { |
| 1143 | att.Description = patt.Description |
| 1144 | } |
| 1145 | if att.Docs == nil { |
| 1146 | att.Docs = patt.Docs |
| 1147 | } |
| 1148 | if att.Validation == nil { |
| 1149 | att.Validation = patt.Validation |
| 1150 | } |
| 1151 | if att.DefaultValue == nil { |
| 1152 | att.DefaultValue = patt.DefaultValue |
| 1153 | } |
| 1154 | if att.UserExamples == nil { |
| 1155 | att.UserExamples = patt.UserExamples |
| 1156 | } |
| 1157 | if att.Meta == nil { |
| 1158 | att.Meta = patt.Meta |
| 1159 | } |
| 1160 | } |
| 1161 | |
| 1162 | // isEmpty returns true if an attribute is Empty type and it has no bases and |
| 1163 | // references, or if an attribute is an empty object. |