Refactor pgen to use a visitor struct instead of globals.
This commit is contained in:
@@ -131,14 +131,16 @@ func (g *Generator) Add(newName, typName, typ string) {
|
||||
g.firstone = false
|
||||
}
|
||||
|
||||
func (g *Generator) Import(name string) {
|
||||
func (g *Generator) Import(ns ...string) {
|
||||
if g.nodes == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// strip quotation marks from imports
|
||||
name = qexp.ReplaceAllString(name,"")
|
||||
astutil.AddImport(g.fset, g.nodes, name)
|
||||
for _,n := range ns {
|
||||
// strip quotation marks from imports
|
||||
n = qexp.ReplaceAllString(n,"")
|
||||
astutil.AddImport(g.fset, g.nodes, n)
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Generator) Save(of io.Writer) {
|
||||
|
||||
Reference in New Issue
Block a user