Generate validates the source code
(ctx *genall.GenerationContext)
| 57 | |
| 58 | // Generate validates the source code |
| 59 | func (g Generator) Generate(ctx *genall.GenerationContext) error { |
| 60 | for _, root := range ctx.Roots { |
| 61 | ctx.Checker.Check(root) |
| 62 | |
| 63 | root.NeedTypesInfo() |
| 64 | |
| 65 | packageTypes := map[string]*markers.TypeInfo{} |
| 66 | if err := markers.EachType(ctx.Collector, root, func(info *markers.TypeInfo) { |
| 67 | packageTypes[info.Name] = info |
| 68 | }); err != nil { |
| 69 | root.AddError(err) |
| 70 | return nil |
| 71 | } |
| 72 | |
| 73 | for _, typeToCheck := range packageTypes { |
| 74 | checkUnion(typeToCheck, root, packageTypes) |
| 75 | } |
| 76 | |
| 77 | } |
| 78 | |
| 79 | return nil |
| 80 | } |
| 81 | |
| 82 | func checkUnion(typeToCheck *markers.TypeInfo, root *loader.Package, packageTypes map[string]*markers.TypeInfo) { |
| 83 | if typeToCheck.Markers.Get(genutils.UnionMarker.Name) == nil { |
nothing calls this directly
no test coverage detected