mirror of
https://github.com/golang/go
synced 2024-11-18 10:04:43 -07:00
refactor/rename: fix misplaced 'continue'.
This was not a visible bug since the only caller discards the relevant result, so I also deleted the result. Fixes #9999 Change-Id: I276d6523b2891d3cb9c8137448e1aed32a5fd197 Reviewed-on: https://go-review.googlesource.com/5921 Reviewed-by: Michael Matloob <michaelmatloob@gmail.com> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
bd8de46c84
commit
e591801c2d
@ -244,9 +244,7 @@ func (m *mover) move() error {
|
|||||||
// None of the subpackages will change their name---only the from package
|
// None of the subpackages will change their name---only the from package
|
||||||
// itself will.
|
// itself will.
|
||||||
for p := range m.rev[m.from] {
|
for p := range m.rev[m.from] {
|
||||||
_, err := importName(
|
if err := importName(m.iprog, m.iprog.Imported[p], m.from, path.Base(m.from), newName); err != nil {
|
||||||
m.iprog, m.iprog.Imported[p], m.from, path.Base(m.from), newName)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,10 +164,9 @@ var reportError = func(posn token.Position, message string) {
|
|||||||
|
|
||||||
// importName renames imports of the package with the given path in
|
// importName renames imports of the package with the given path in
|
||||||
// the given package. If fromName is not empty, only imports as
|
// the given package. If fromName is not empty, only imports as
|
||||||
// fromName will be renamed. Even if renaming is successful, there
|
// fromName will be renamed. If the renaming would lead to a conflict,
|
||||||
// may be some files that are unchanged; they are reported in
|
// the file is left unchanged.
|
||||||
// unchangedFiles.
|
func importName(iprog *loader.Program, info *loader.PackageInfo, fromPath, fromName, to string) error {
|
||||||
func importName(iprog *loader.Program, info *loader.PackageInfo, fromPath, fromName, to string) (unchangedFiles []string, err error) {
|
|
||||||
for _, f := range info.Files {
|
for _, f := range info.Files {
|
||||||
var from types.Object
|
var from types.Object
|
||||||
for _, imp := range f.Imports {
|
for _, imp := range f.Imports {
|
||||||
@ -193,13 +192,12 @@ func importName(iprog *loader.Program, info *loader.PackageInfo, fromPath, fromN
|
|||||||
r.check(from)
|
r.check(from)
|
||||||
if r.hadConflicts {
|
if r.hadConflicts {
|
||||||
continue // ignore errors; leave the existing name
|
continue // ignore errors; leave the existing name
|
||||||
unchangedFiles = append(unchangedFiles, f.Name.Name)
|
|
||||||
}
|
}
|
||||||
if err := r.update(); err != nil {
|
if err := r.update(); err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return unchangedFiles, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Main(ctxt *build.Context, offsetFlag, fromFlag, to string) error {
|
func Main(ctxt *build.Context, offsetFlag, fromFlag, to string) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user