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

Method GenerateAllFiles

protoc-gen-go/generator/generator.go:1061–1095  ·  view source on GitHub ↗

GenerateAllFiles generates the output for all the files we're outputting.

()

Source from the content-addressed store, hash-verified

1059
1060// GenerateAllFiles generates the output for all the files we're outputting.
1061func (g *Generator) GenerateAllFiles() {
1062 // Initialize the plugins
1063 for _, p := range plugins {
1064 p.Init(g)
1065 }
1066 // Generate the output. The generator runs for every file, even the files
1067 // that we don't generate output for, so that we can collate the full list
1068 // of exported symbols to support public imports.
1069 genFileMap := make(map[*FileDescriptor]bool, len(g.genFiles))
1070 for _, file := range g.genFiles {
1071 genFileMap[file] = true
1072 }
1073 for _, file := range g.allFiles {
1074 g.Reset()
1075 g.annotations = nil
1076 g.writeOutput = genFileMap[file]
1077 g.generate(file)
1078 if !g.writeOutput {
1079 continue
1080 }
1081 fname := file.goFileName(g.pathType)
1082 g.Response.File = append(g.Response.File, &plugin.CodeGeneratorResponse_File{
1083 Name: proto.String(fname),
1084 Content: proto.String(g.String()),
1085 })
1086 if g.annotateCode {
1087 // Store the generated code annotations in text, as the protoc plugin protocol requires that
1088 // strings contain valid UTF-8.
1089 g.Response.File = append(g.Response.File, &plugin.CodeGeneratorResponse_File{
1090 Name: proto.String(file.goFileName(g.pathType) + ".meta"),
1091 Content: proto.String(proto.CompactTextString(&descriptor.GeneratedCodeInfo{Annotation: g.annotations})),
1092 })
1093 }
1094 }
1095}
1096
1097// Run all the plugins associated with the file.
1098func (g *Generator) runPlugins(file *FileDescriptor) {

Callers

nothing calls this directly

Calls 7

generateMethod · 0.95
StringFunction · 0.92
CompactTextStringFunction · 0.92
goFileNameMethod · 0.80
InitMethod · 0.65
ResetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected