mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Add Finalize method to go2idl Generator interface
This commit is contained in:
parent
da4f824265
commit
641b625a2a
@ -50,6 +50,7 @@ func (d DefaultGen) PackageConsts(*Context) []string { retur
|
||||
func (d DefaultGen) GenerateType(*Context, *types.Type, io.Writer) error { return nil }
|
||||
func (d DefaultGen) Filename() string { return d.OptionalName + ".go" }
|
||||
func (d DefaultGen) FileType() string { return GolangFileType }
|
||||
func (d DefaultGen) Finalize(*Context, io.Writer) error { return nil }
|
||||
|
||||
func (d DefaultGen) Init(c *Context, w io.Writer) error {
|
||||
_, err := w.Write(d.OptionalBody)
|
||||
|
@ -302,5 +302,8 @@ func (c *Context) executeBody(w io.Writer, generator Generator) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := generator.Finalize(c, et); err != nil {
|
||||
return err
|
||||
}
|
||||
return et.Error()
|
||||
}
|
||||
|
@ -110,6 +110,11 @@ type Generator interface {
|
||||
// Generators.)
|
||||
Init(*Context, io.Writer) error
|
||||
|
||||
// Finalize should write finish up codes, and any other content that's not
|
||||
// generated per-type. For example if you are generating one block (function,
|
||||
// type, etc) for all types, this function can be used to close the block.
|
||||
Finalize(*Context, io.Writer) error
|
||||
|
||||
// PackageVars should emit an array of variable lines. They will be
|
||||
// placed in a var ( ... ) block. There's no need to include a leading
|
||||
// \t or trailing \n.
|
||||
|
@ -252,6 +252,7 @@ func (r *importRules) GenerateType(*generator.Context, *types.Type, io.Writer) e
|
||||
func (r *importRules) Filename() string { return ".import-restrictions" }
|
||||
func (r *importRules) FileType() string { return importBossFileType }
|
||||
func (r *importRules) Init(c *generator.Context, w io.Writer) error { return nil }
|
||||
func (r *importRules) Finalize(c *generator.Context, w io.Writer) error { return nil }
|
||||
|
||||
func dfsImports(dest *[]string, seen map[string]bool, p *types.Package) {
|
||||
for _, p2 := range p.Imports {
|
||||
|
Loading…
Reference in New Issue
Block a user