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

Function transformHelperName

grpc/codegen/protobuf_transform.go:1085–1111  ·  view source on GitHub ↗

transformHelperName returns the transformation function name to initialize a target user type from an instance of a source user type.

(source, target *expr.AttributeExpr, ta *transformAttrs)

Source from the content-addressed store, hash-verified

1083// transformHelperName returns the transformation function name to initialize a
1084// target user type from an instance of a source user type.
1085func transformHelperName(source, target *expr.AttributeExpr, ta *transformAttrs) string {
1086 var (
1087 sname string
1088 tname string
1089 prefix string
1090 )
1091 {
1092 // Do not consider package overrides for protogen generated types
1093 if ta.proto {
1094 target = expr.DupAtt(target)
1095 codegen.Walk(target, func(att *expr.AttributeExpr) error { // nolint: errcheck
1096 delete(att.Meta, "struct:pkg:path")
1097 return nil
1098 })
1099 } else {
1100 source = expr.DupAtt(source)
1101 codegen.Walk(source, func(att *expr.AttributeExpr) error { // nolint: errcheck
1102 delete(att.Meta, "struct:pkg:path")
1103 return nil
1104 })
1105 }
1106 sname = codegen.Goify(ta.SourceCtx.Scope.Name(source, ta.SourceCtx.Pkg(source), ta.TargetCtx.Pointer, ta.TargetCtx.UseDefault), true)
1107 tname = codegen.Goify(ta.TargetCtx.Scope.Name(target, ta.TargetCtx.Pkg(target), ta.TargetCtx.Pointer, ta.TargetCtx.UseDefault), true)
1108 prefix = ta.Prefix
1109 }
1110 return codegen.Goify(prefix+sname+"To"+tname, false)
1111}
1112
1113// unAlias returns the base AttributeExpr of an aliased one.
1114func unAlias(at *expr.AttributeExpr) *expr.AttributeExpr {

Callers 3

transformObjectFunction · 0.70
convertTypeFunction · 0.70
collectHelpersFunction · 0.70

Calls 5

DupAttFunction · 0.92
WalkFunction · 0.92
GoifyFunction · 0.92
PkgMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected