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

Function resultContext

grpc/codegen/service_data.go:1422–1432  ·  view source on GitHub ↗

resultContext returns the method result attribute and the result context for the given endpoint.

(e *expr.GRPCEndpointExpr, sd *ServiceData)

Source from the content-addressed store, hash-verified

1420// resultContext returns the method result attribute and the result context for the given
1421// endpoint.
1422func resultContext(e *expr.GRPCEndpointExpr, sd *ServiceData) (*expr.AttributeExpr, *codegen.AttributeContext) {
1423 svc := sd.Service
1424 md := svc.Method(e.Name())
1425 if md.ViewedResult != nil {
1426 vresAtt := expr.AsObject(md.ViewedResult.Type).Attribute("projected")
1427 // return projected type context
1428 return vresAtt, codegen.NewAttributeContext(true, false, true, svc.ViewsPkg, svc.ViewScope)
1429 }
1430 pkg := pkgWithDefault(md.ResultLoc, svc.PkgName)
1431 return e.MethodExpr.Result, serviceTypeContext(pkg, svc.Scope)
1432}
1433
1434// pkgWithDefault returns the package name of the given location if not nil, def otherwise.
1435func pkgWithDefault(loc *codegen.Location, def string) string {

Callers 2

analyzeMethod · 0.85
buildStreamDataMethod · 0.85

Calls 7

AsObjectFunction · 0.92
NewAttributeContextFunction · 0.92
serviceTypeContextFunction · 0.85
pkgWithDefaultFunction · 0.70
MethodMethod · 0.65
NameMethod · 0.65
AttributeMethod · 0.65

Tested by

no test coverage detected