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

Function buildStreamEnvelopeData

grpc/codegen/service_data.go:1387–1401  ·  view source on GitHub ↗

buildStreamEnvelopeData computes the generated Go names for the protobuf oneof field and wrapper types of the synthesized stream envelope.

(envelope *expr.AttributeExpr, message *service.UserTypeData, sd *ServiceData)

Source from the content-addressed store, hash-verified

1385// buildStreamEnvelopeData computes the generated Go names for the protobuf
1386// oneof field and wrapper types of the synthesized stream envelope.
1387func buildStreamEnvelopeData(envelope *expr.AttributeExpr, message *service.UserTypeData, sd *ServiceData) *StreamEnvelopeData {
1388 body := envelope.Find("body")
1389 union := expr.AsUnion(body.Type)
1390 scope := &protoBufScope{scope: sd.Scope}
1391 fieldName := scope.Field(body, union.TypeName, true)
1392 initialFieldName := scope.Field(union.Values[0].Attribute, union.Values[0].Name, true)
1393 streamItemFieldName := scope.Field(union.Values[1].Attribute, union.Values[1].Name, true)
1394 return &StreamEnvelopeData{
1395 FieldName: fieldName,
1396 InitialFieldName: initialFieldName,
1397 InitialWrapperRef: fmt.Sprintf("%s.%s_%s", sd.PkgName, message.VarName, initialFieldName),
1398 StreamItemFieldName: streamItemFieldName,
1399 StreamItemWrapperRef: fmt.Sprintf("%s.%s_%s", sd.PkgName, message.VarName, streamItemFieldName),
1400 }
1401}
1402
1403func unalias(att *expr.AttributeExpr) *expr.AttributeExpr {
1404 if ut, ok := att.Type.(expr.UserType); ok {

Callers 1

analyzeMethod · 0.85

Calls 3

FieldMethod · 0.95
AsUnionFunction · 0.92
FindMethod · 0.80

Tested by

no test coverage detected