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

Function buildViews

codegen/service/service_data.go:1960–1976  ·  view source on GitHub ↗

buildViews builds the view data for all the views in the given result type.

(rt *expr.ResultTypeExpr, viewScope *codegen.NameScope)

Source from the content-addressed store, hash-verified

1958
1959// buildViews builds the view data for all the views in the given result type.
1960func buildViews(rt *expr.ResultTypeExpr, viewScope *codegen.NameScope) []*ViewData {
1961 views := make([]*ViewData, len(rt.Views))
1962 for i, view := range rt.Views {
1963 vatt := expr.AsObject(view.Type)
1964 attrs := make([]string, len(*vatt))
1965 for j, nat := range *vatt {
1966 attrs[j] = nat.Name
1967 }
1968 views[i] = &ViewData{
1969 Name: view.Name,
1970 Description: view.Description,
1971 Attributes: attrs,
1972 TypeVarName: viewScope.GoTypeName(&expr.AttributeExpr{Type: rt}),
1973 }
1974 }
1975 return views
1976}
1977
1978// buildViewedResultType builds a viewed result type from the given result type
1979// and projected type.

Callers 2

buildProjectedTypeFunction · 0.85
buildViewedResultTypeFunction · 0.85

Calls 2

AsObjectFunction · 0.92
GoTypeNameMethod · 0.80

Tested by

no test coverage detected