1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:08:33 -06:00

internal/lsp: return rename errors for one package only

Rename checks all of the packages that may be affected for conflicts. An
error in any of them leads to renaming error. Returning errors from
multiple packages may be confusing (for example, when there is a test
variant of a package and the same error appears twice). This change
stops after an error is found and returns that error instead of
continuing to search.

Change-Id: Ifba1feddbf8829d3aad30309154d578967e05a36
Reviewed-on: https://go-review.googlesource.com/c/tools/+/190416
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Suzy Mueller 2019-08-16 12:23:59 -04:00
parent d0b4265052
commit d5940c88eb
2 changed files with 4 additions and 0 deletions

View File

@ -78,6 +78,9 @@ func (i *IdentifierInfo) Rename(ctx context.Context, newName string) (map[span.U
// Check that the renaming of the identifier is ok. // Check that the renaming of the identifier is ok.
for _, ref := range refs { for _, ref := range refs {
r.check(ref.obj) r.check(ref.obj)
if r.hadConflicts { // one error is enough.
break
}
} }
if r.hadConflicts { if r.hadConflicts {
return nil, errors.Errorf(r.errors) return nil, errors.Errorf(r.errors)

View File

@ -0,0 +1 @@
package bad