isEmpty returns true if an attribute is Empty type and it has no bases and references, or if an attribute is an empty object.
(a *AttributeExpr)
| 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. |
| 1164 | func isEmpty(a *AttributeExpr) bool { |
| 1165 | if !IsObject(a.Type) { |
| 1166 | return false |
| 1167 | } |
| 1168 | if obj := AsObject(a.Type); obj != nil && len(*obj) != 0 { |
| 1169 | if a.Type == Empty { |
| 1170 | panic("Empty should have no attribute") // bug |
| 1171 | } |
| 1172 | return false |
| 1173 | } |
| 1174 | if len(a.Bases) != 0 || len(a.References) != 0 { |
| 1175 | return false |
| 1176 | } |
| 1177 | if ut, ok := a.Type.(UserType); ok { |
| 1178 | uatt := ut.Attribute() |
| 1179 | if len(uatt.Bases) != 0 || len(uatt.References) != 0 { |
| 1180 | return false |
| 1181 | } |
| 1182 | } |
| 1183 | return true |
| 1184 | } |
| 1185 | |
| 1186 | // hasJSONRPCIDField returns true if an attribute or any of its nested attributes |
| 1187 | // has the "jsonrpc:id" meta tag, indicating it's designated as the JSON-RPC ID field. |
no test coverage detected