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

Function walkAttribute

expr/attribute.go:199–223  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

197// Note: keep this function private as it does not walk through all types.
198// External packages should use the codegen.Walk function instead.
199func 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.
226func (a *AttributeExpr) EvalName() string {

Callers 3

validateErrorsMethod · 0.85
ValidateMethod · 0.85
FinalizeMethod · 0.85

Calls 1

AttributeMethod · 0.65

Tested by

no test coverage detected