GenerateAllFiles generates the output for all the files we're outputting.
()
| 1059 | |
| 1060 | // GenerateAllFiles generates the output for all the files we're outputting. |
| 1061 | func (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. |
| 1098 | func (g *Generator) runPlugins(file *FileDescriptor) { |
nothing calls this directly
no test coverage detected