зеркало из https://github.com/golang/tools.git
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:
Родитель
bd8de46c84
Коммит
e591801c2d
|
@ -244,9 +244,7 @@ func (m *mover) move() error {
|
|||
// None of the subpackages will change their name---only the from package
|
||||
// itself will.
|
||||
for p := range m.rev[m.from] {
|
||||
_, err := importName(
|
||||
m.iprog, m.iprog.Imported[p], m.from, path.Base(m.from), newName)
|
||||
if err != nil {
|
||||
if err := importName(m.iprog, m.iprog.Imported[p], m.from, path.Base(m.from), newName); err != nil {
|
||||
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
|
||||
// the given package. If fromName is not empty, only imports as
|
||||
// fromName will be renamed. Even if renaming is successful, there
|
||||
// may be some files that are unchanged; they are reported in
|
||||
// unchangedFiles.
|
||||
func importName(iprog *loader.Program, info *loader.PackageInfo, fromPath, fromName, to string) (unchangedFiles []string, err error) {
|
||||
// fromName will be renamed. If the renaming would lead to a conflict,
|
||||
// the file is left unchanged.
|
||||
func importName(iprog *loader.Program, info *loader.PackageInfo, fromPath, fromName, to string) error {
|
||||
for _, f := range info.Files {
|
||||
var from types.Object
|
||||
for _, imp := range f.Imports {
|
||||
|
@ -193,13 +192,12 @@ func importName(iprog *loader.Program, info *loader.PackageInfo, fromPath, fromN
|
|||
r.check(from)
|
||||
if r.hadConflicts {
|
||||
continue // ignore errors; leave the existing name
|
||||
unchangedFiles = append(unchangedFiles, f.Name.Name)
|
||||
}
|
||||
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 {
|
||||
|
|
Загрузка…
Ссылка в новой задаче