Change information
Commit message:
go/analysis/passes/modernize: modernizer for iterator APIs
This CL adds the stditerators modernizer, which replaces loops
of the form
for i := 0; i < x.Len(); i++ {
use(x.At(i))
}
or their "range x.Len()" equivalent by
for elem := range x.All() {
use(x.At(i)
}
for various well-known std types.
Publishing each new Analyzer symbol requires going through the
proposal process, so we plan to do them in one batch per Go
release. In the interim, we cannot make such symbols public,
so we use a backdoor mechanism to export them to gopls.
+ test, doc, relnote
Updates golang/go#75693
Change-Id: I3accd1925ad990b84500a9e77c3c589aeaeabfb0
Files:
- M go/analysis/passes/modernize/bloop.go
- M go/analysis/passes/modernize/doc.go
- M go/analysis/passes/modernize/modernize.go
- M go/analysis/passes/modernize/modernize_test.go
- A go/analysis/passes/modernize/stditerators.go
- A go/analysis/passes/modernize/testdata/src/stditerators/stditerators.go
- A go/analysis/passes/modernize/testdata/src/stditerators/stditerators.go.golden
- M gopls/doc/analyzers.md
- M gopls/doc/release/v0.21.0.md
- M gopls/internal/doc/api.json
- M gopls/internal/settings/analysis.go
- A internal/goplsexport/export.go
Change size: L
Delta: 12 files changed, 580 insertions(+), 9 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Robert Findley
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI