MCPcopy
hub / github.com/golang/protobuf / generateMessageStruct

Method generateMessageStruct

protoc-gen-go/generator/generator.go:2076–2095  ·  view source on GitHub ↗

generateMessageStruct adds the actual struct with it's members (but not methods) to the output.

(mc *msgCtx, topLevelFields []topLevelField)

Source from the content-addressed store, hash-verified

2074
2075// generateMessageStruct adds the actual struct with it's members (but not methods) to the output.
2076func (g *Generator) generateMessageStruct(mc *msgCtx, topLevelFields []topLevelField) {
2077 comments := g.PrintComments(mc.message.path)
2078
2079 // Guarantee deprecation comments appear after user-provided comments.
2080 if mc.message.GetOptions().GetDeprecated() {
2081 if comments {
2082 // Convention: Separate deprecation comments from original
2083 // comments with an empty line.
2084 g.P("//")
2085 }
2086 g.P(deprecationComment)
2087 }
2088
2089 g.P("type ", Annotate(mc.message.file, mc.message.path, mc.goName), " struct {")
2090 for _, pf := range topLevelFields {
2091 pf.decl(g, mc)
2092 }
2093 g.generateInternalStructFields(mc, topLevelFields)
2094 g.P("}")
2095}
2096
2097// generateGetters adds getters for all fields, including oneofs and weak fields when applicable.
2098func (g *Generator) generateGetters(mc *msgCtx, topLevelFields []topLevelField) {

Callers 1

generateMessageMethod · 0.95

Calls 5

PrintCommentsMethod · 0.95
PMethod · 0.95
AnnotateFunction · 0.85
declMethod · 0.65

Tested by

no test coverage detected