walkAttribute iterates over the given attribute, its bases and references (if any). It calls the given function giving each attribute as it iterates. It stops if the given attribute is not an object type or there is no more attribute to iterate over or if the iterator function returned an error. It
(att *AttributeExpr, it func(name string, a *AttributeExpr) error)
| 197 | // Note: keep this function private as it does not walk through all types. |
| 198 | // External packages should use the codegen.Walk function instead. |
| 199 | func walkAttribute(att *AttributeExpr, it func(name string, a *AttributeExpr) error) error { |
| 200 | switch dt := att.Type.(type) { |
| 201 | case UserType: |
| 202 | if err := walkAttribute(dt.Attribute(), it); err != nil { |
| 203 | return err |
| 204 | } |
| 205 | case *Object: |
| 206 | for _, nat := range *dt { |
| 207 | if err := it(nat.Name, nat.Attribute); err != nil { |
| 208 | return err |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | for _, b := range att.Bases { |
| 213 | if err := walkAttribute(&AttributeExpr{Type: b}, it); err != nil { |
| 214 | return err |
| 215 | } |
| 216 | } |
| 217 | for _, r := range att.References { |
| 218 | if err := walkAttribute(&AttributeExpr{Type: r}, it); err != nil { |
| 219 | return err |
| 220 | } |
| 221 | } |
| 222 | return nil |
| 223 | } |
| 224 | |
| 225 | // EvalName returns the name used by the DSL evaluation. |
| 226 | func (a *AttributeExpr) EvalName() string { |
no test coverage detected