diff --git a/generate/generate.go b/generate/generate.go index 5cf188b..dd29ed6 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -40,8 +40,8 @@ func sub(dst *string,spec subspec) { func (g *Generator) Visit(node ast.Node) ast.Visitor { switch n := node.(type) { case *ast.Ident: + subs(&n.Name,g.nspecs) if n.Obj != nil && n.Obj.Kind == ast.Typ { - subs(&n.Name,g.nspecs) subs(&n.Obj.Name,g.nspecs) } case *ast.TypeSwitchStmt: @@ -52,34 +52,8 @@ func (g *Generator) Visit(node ast.Node) ast.Visitor { subs(&ci.Name,g.nspecs) } } - case *ast.TypeAssertExpr: - nt, ok := n.Type.(*ast.Ident); if !ok { return g } - subs(&nt.Name,g.nspecs) - case *ast.Ellipsis: - nt, ok := n.Elt.(*ast.Ident); if !ok { return g } - subs(&nt.Name,g.nspecs) - case *ast.Field: - nt, ok := n.Type.(*ast.Ident); if !ok { return g } - subs(&nt.Name,g.nspecs) - case *ast.StarExpr: - nt, ok := n.X.(*ast.Ident); if !ok { return g } - subs(&nt.Name,g.nspecs) - case *ast.ValueSpec: - nt, ok := n.Type.(*ast.Ident); if !ok { return g } - subs(&nt.Name,g.nspecs) - case *ast.ArrayType: - nt, ok := n.Elt.(*ast.Ident); if !ok { return g } - subs(&nt.Name,g.nspecs) - case *ast.MapType: - nt, ok := n.Key.(*ast.Ident); if ok { - subs(&nt.Name,g.nspecs) - } - nt, ok = n.Value.(*ast.Ident); if ok { - subs(&nt.Name,g.nspecs) - } case *ast.FuncDecl: sub(&n.Name.Name,g.fspec) - //ast.Print(g.fset,n) } return g }