Skip to content

Commit 481d425

Browse files
committed
[gopls-release-branch.0.6] all: merge master into gopls-release-branch.0.6
ef3185b internal/lsp/cache: add a check for snapshot invariants b841374 internal/lsp: fix autocomplete appends on imports 929a849 internal/lsp: restructure the way we report critical errors fbbba25 gopls/doc: generate documentation for analyzers 84d76fe internal/lsp: fix unimported completions with -mod=readonly 0661ca7 gopls/internal/regtest: show line numbers if TestUseGoplsMod fails 13ff221 internal/lsp/cmd: include new name in rename help message 0f6027f gopls/doc/vim.md: add table of contents, improve neovim docs 34cd474 internal/lsp: use an enum for GC annotations settings b1c9089 internal/lsp/source: do not panic in "var func" outgoing callhierarchy 2b0845d gopls/release: add a command to validate the gopls release process 57089f8 internal/lsp: remove dependencies using text edits when necessary 834755c internal/lsp: add tests to set configuration options bdbb3c9 internal/lsp/cache: only reload the workspace on saved changes 3e0a2b7 gopls/internal/regtest: skip a some new builders where regtests time out f6952e4 internal/lsp/cache: fix some package event tags 9cbb1ef internal/lsp/source: add the shadow analyzer 3fa0e8f gopls: disable TestTemplate on Android f2e330f gopls/test: add type checking for debug server templates 1965356 internal/lsp/mod: fix misplaced code lens with individual requires b57d1c5 internal/lsp: return an error if code action has no title ae774e9 internal/lsp: don't show duplicate diagnostics for go.mod errors 5b06639 internal/lsp/source: only show "run file benchmarks" if available 11a5667 gopls/internal/regtest: test metadata validation only on save for go.mod 5b43ef9 go/analysis/passes/fieldalignment: filter comments from suggested fix 4b31ac3 gopls/internal/regtest: test that accepting fix removes diagnostics 008e477 internal/lsp, gopls: recover from go-diff panics 48e5bd1 internal/lsp: add titles to `go mod tidy` and update go.sum fixes fa10ef0 internal/lsp/source: update codelenses example 6307297 go/analysis/passes/fieldalignment: support fields without name Change-Id: I449fee8301240637662f60930fe8b20e133fdd81
2 parents 1eed487 + ef3185b commit 481d425

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2536
-906
lines changed

go/analysis/analysistest/analysistest.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ func RunWithSuggestedFixes(t Testing, dir string, a *analysis.Analyzer, patterns
195195
continue
196196
}
197197
if want != string(formatted) {
198-
d := myers.ComputeEdits("", want, string(formatted))
198+
d, err := myers.ComputeEdits("", want, string(formatted))
199+
if err != nil {
200+
t.Errorf("failed to compute suggested fixes: %v", err)
201+
}
199202
t.Errorf("suggested fixes failed for %s:\n%s", file.Name(), diff.ToUnified(fmt.Sprintf("%s.golden [%s]", file.Name(), sf), "actual", want, d))
200203
}
201204
break
@@ -221,7 +224,10 @@ func RunWithSuggestedFixes(t Testing, dir string, a *analysis.Analyzer, patterns
221224
continue
222225
}
223226
if want != string(formatted) {
224-
d := myers.ComputeEdits("", want, string(formatted))
227+
d, err := myers.ComputeEdits("", want, string(formatted))
228+
if err != nil {
229+
t.Errorf("failed to compute edits: %s", err)
230+
}
225231
t.Errorf("suggested fixes failed for %s:\n%s", file.Name(), diff.ToUnified(file.Name()+".golden", "actual", want, d))
226232
}
227233
}

go/analysis/passes/fieldalignment/fieldalignment.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ func fieldalignment(pass *analysis.Pass, node *ast.StructType, typ *types.Struct
7676
// TODO: Preserve multi-named fields instead of flattening.
7777
var flat []*ast.Field
7878
for _, f := range node.Fields.List {
79-
if len(f.Names) == 1 {
79+
// TODO: Preserve comment, for now get rid of them.
80+
// See https://github.com/golang/go/issues/20744
81+
f.Comment = nil
82+
if len(f.Names) <= 1 {
8083
flat = append(flat, f)
8184
continue
8285
}

go/analysis/passes/fieldalignment/testdata/src/a/a.go

+14
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@ type ZeroBad struct { // want "struct of size 8 could be 4"
2121
a uint32
2222
b [0]byte
2323
}
24+
25+
type NoNameGood struct {
26+
Good
27+
y int32
28+
x byte
29+
z byte
30+
}
31+
32+
type NoNameBad struct { // want "struct of size 20 could be 16"
33+
Good
34+
x byte
35+
y int32
36+
z byte
37+
}

go/analysis/passes/fieldalignment/testdata/src/a/a.go.golden

+14
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@ type ZeroBad struct {
2121
b [0]byte
2222
a uint32
2323
}
24+
25+
type NoNameGood struct {
26+
Good
27+
y int32
28+
x byte
29+
z byte
30+
}
31+
32+
type NoNameBad struct {
33+
Good
34+
y int32
35+
x byte
36+
z byte
37+
}

go/analysis/passes/fieldalignment/testdata/src/a/a_amd64.go

+8
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ type MultiField struct { // want "struct of size 40 could be 24"
3838
a3 [3]bool
3939
_ [0]func()
4040
}
41+
42+
type Issue43233 struct { // want "struct with 88 pointer bytes could be 80"
43+
AllowedEvents []*string // allowed events
44+
BlockedEvents []*string // blocked events
45+
APIVersion string `mapstructure:"api_version"`
46+
BaseURL string `mapstructure:"base_url"`
47+
AccessToken string `mapstructure:"access_token"`
48+
}

go/analysis/passes/fieldalignment/testdata/src/a/a_amd64.go.golden

+8
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,11 @@ type MultiField struct {
3939
a3 [3]bool
4040
b bool
4141
}
42+
43+
type Issue43233 struct {
44+
APIVersion string `mapstructure:"api_version"`
45+
BaseURL string `mapstructure:"base_url"`
46+
AccessToken string `mapstructure:"access_token"`
47+
AllowedEvents []*string
48+
BlockedEvents []*string
49+
}

0 commit comments

Comments
 (0)