mirror of
https://github.com/golang/go
synced 2024-11-18 18:04:46 -07: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:
parent
d0b4265052
commit
d5940c88eb
@ -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.
|
||||
for _, ref := range refs {
|
||||
r.check(ref.obj)
|
||||
if r.hadConflicts { // one error is enough.
|
||||
break
|
||||
}
|
||||
}
|
||||
if r.hadConflicts {
|
||||
return nil, errors.Errorf(r.errors)
|
||||
|
1
internal/lsp/testdata/rename/bad/bad_test.go.in
vendored
Normal file
1
internal/lsp/testdata/rename/bad/bad_test.go.in
vendored
Normal file
@ -0,0 +1 @@
|
||||
package bad
|
Loading…
Reference in New Issue
Block a user