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)
| 1385 | // buildStreamEnvelopeData computes the generated Go names for the protobuf |
| 1386 | // oneof field and wrapper types of the synthesized stream envelope. |
| 1387 | func 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 | |
| 1403 | func unalias(att *expr.AttributeExpr) *expr.AttributeExpr { |
| 1404 | if ut, ok := att.Type.(expr.UserType); ok { |