(f *ast.File, tab []rename)
| 791 | } |
| 792 | |
| 793 | func renameFixTab(f *ast.File, tab []rename) bool { |
| 794 | fixed := false |
| 795 | added := map[string]bool{} |
| 796 | check := map[string]bool{} |
| 797 | for _, t := range tab { |
| 798 | if !imports(f, t.OldImport) { |
| 799 | continue |
| 800 | } |
| 801 | optr, opkg, onam := parseName(t.Old) |
| 802 | walk(f, func(n interface{}) { |
| 803 | np, ok := n.(*ast.Expr) |
| 804 | if !ok { |
| 805 | return |
| 806 | } |
| 807 | x := *np |
| 808 | if optr { |
| 809 | p, ok := x.(*ast.StarExpr) |
| 810 | if !ok { |
| 811 | return |
| 812 | } |
| 813 | x = p.X |
| 814 | } |
| 815 | if !isPkgDot(x, opkg, onam) { |
| 816 | return |
| 817 | } |
| 818 | if t.NewImport != "" && !added[t.NewImport] { |
| 819 | addImport(f, t.NewImport) |
| 820 | added[t.NewImport] = true |
| 821 | } |
| 822 | *np = expr(t.New) |
| 823 | check[t.OldImport] = true |
| 824 | fixed = true |
| 825 | }) |
| 826 | } |
| 827 | |
| 828 | for ipath := range check { |
| 829 | if !usesImport(f, ipath) { |
| 830 | deleteImport(f, ipath) |
| 831 | } |
| 832 | } |
| 833 | return fixed |
| 834 | } |
no test coverage detected