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

Function projectCollection

expr/result_type.go:329–363  ·  view source on GitHub ↗
(rt *ResultTypeExpr, view string, seen map[string]*AttributeExpr)

Source from the content-addressed store, hash-verified

327}
328
329func projectCollection(rt *ResultTypeExpr, view string, seen map[string]*AttributeExpr) (*ResultTypeExpr, error) {
330 // Project the collection element result type
331 e := rt.Type.(*Array).ElemType.Type.(*ResultTypeExpr) // validation checked this cast would work
332 pe, err2 := project(e, view, seen)
333 if err2 != nil {
334 return nil, fmt.Errorf("collection element: %w", err2)
335 }
336
337 // Build the projected collection with the results
338 id := rt.projectIdentifier(view)
339 proj := &ResultTypeExpr{
340 Identifier: id,
341 UserTypeExpr: &UserTypeExpr{
342 AttributeExpr: &AttributeExpr{
343 Description: rt.TypeName + " is the result type for an array of " + e.TypeName + " (" + view + " view)",
344 Type: &Array{ElemType: &AttributeExpr{Type: pe}},
345 UserExamples: rt.UserExamples,
346 },
347 TypeName: pe.TypeName + "Collection",
348 UID: id,
349 },
350 Views: []*ViewExpr{{
351 AttributeExpr: DupAtt(pe.View(DefaultView).AttributeExpr),
352 Name: DefaultView,
353 Parent: pe,
354 }},
355 }
356
357 // Run the DSL that was created by the CollectionOf function
358 if !eval.Execute(proj.DSL(), proj) {
359 return nil, eval.Context.Errors
360 }
361
362 return proj, nil
363}
364
365func projectRecursive(at *AttributeExpr, vat *NamedAttributeExpr, view string, seen map[string]*AttributeExpr) (*AttributeExpr, error) {
366 if att, ok := seen[hashAttrAndView(at, view)]; ok {

Callers 1

projectFunction · 0.85

Calls 6

ExecuteFunction · 0.92
projectFunction · 0.85
DupAttFunction · 0.85
projectIdentifierMethod · 0.80
ViewMethod · 0.80
DSLMethod · 0.65

Tested by

no test coverage detected