resultContext returns the method result attribute and the result context for the given endpoint.
(e *expr.GRPCEndpointExpr, sd *ServiceData)
| 1420 | // resultContext returns the method result attribute and the result context for the given |
| 1421 | // endpoint. |
| 1422 | func 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. |
| 1435 | func pkgWithDefault(loc *codegen.Location, def string) string { |
no test coverage detected