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

Method Finalize

expr/attribute.go:340–384  ·  view source on GitHub ↗

Finalize merges base and reference type attributes and finalizes the Type attribute.

()

Source from the content-addressed store, hash-verified

338// Finalize merges base and reference type attributes and finalizes the Type
339// attribute.
340func (a *AttributeExpr) Finalize() {
341 if a.finalized {
342 return // Avoid infinite recursion.
343 }
344 a.finalized = true
345 if ut, ok := a.Type.(UserType); ok {
346 ut.Finalize()
347 }
348 switch {
349 case IsObject(a.Type):
350 for _, ref := range a.References {
351 ru, ok := ref.(UserType)
352 if !ok {
353 continue
354 }
355 a.Inherit(ru.Attribute())
356 }
357 for _, base := range a.Bases {
358 ru, ok := base.(UserType)
359 if !ok {
360 continue
361 }
362 a.Merge(ru.Attribute())
363 }
364
365 // Now that we've merged the bases, we can clear them. This
366 // avoids issues where the bases are dupped and modifications
367 // made to the originals are not reflected in the dups.
368 a.Bases = nil
369
370 for _, nat := range *AsObject(a.Type) {
371 nat.Attribute.Finalize()
372 }
373 case IsUnion(a.Type):
374 for _, nat := range AsUnion(a.Type).Values {
375 nat.Attribute.Finalize()
376 }
377 case IsArray(a.Type):
378 AsArray(a.Type).ElemType.Finalize()
379 case IsMap(a.Type):
380 m := AsMap(a.Type)
381 m.ElemType.Finalize()
382 m.KeyType.Finalize()
383 }
384}
385
386// Merge merges other's attributes into a overriding attributes of a with
387// attributes of other with identical names.

Callers

nothing calls this directly

Calls 12

InheritMethod · 0.95
MergeMethod · 0.95
IsObjectFunction · 0.85
AsObjectFunction · 0.85
IsUnionFunction · 0.85
AsUnionFunction · 0.85
IsArrayFunction · 0.85
AsArrayFunction · 0.85
IsMapFunction · 0.85
AsMapFunction · 0.85
FinalizeMethod · 0.65
AttributeMethod · 0.65

Tested by

no test coverage detected