mirror of https://github.com/golang/go.git
gopls: update dependencies following the v0.10.0 release
Update selected dependencies following the v0.10.0 release, excluding sergi/go-diff and x/vuln. Gofumpt@v0.4.0 requires go1.18, so link it selectively following the pattern of staticcheck. While at it, clean up some things related to the wiring of staticcheck and gofumpt support. Notably, in VS Code error messages do not support formatting such as newlines or tabs. Add a test for the conditional Gofumpt support. For golang/go#56211 Change-Id: Id09fdcc30ad83c0ace11b0dea9a5556a6461d552 Reviewed-on: https://go-review.googlesource.com/c/tools/+/446736 Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
2b29c66d7e
commit
ec044b1a47
14
gopls/go.mod
14
gopls/go.mod
|
|
@ -3,7 +3,7 @@ module golang.org/x/tools/gopls
|
|||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/google/go-cmp v0.5.8
|
||||
github.com/google/go-cmp v0.5.9
|
||||
github.com/jba/printsrc v0.2.2
|
||||
github.com/jba/templatecheck v0.6.0
|
||||
github.com/sergi/go-diff v1.1.0
|
||||
|
|
@ -11,20 +11,20 @@ require (
|
|||
golang.org/x/sync v0.1.0
|
||||
golang.org/x/sys v0.1.0
|
||||
golang.org/x/text v0.4.0
|
||||
golang.org/x/tools v0.1.13-0.20220928184430-f80e98464e27
|
||||
golang.org/x/tools v0.2.0
|
||||
golang.org/x/vuln v0.0.0-20221010193109-563322be2ea9
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
honnef.co/go/tools v0.3.3
|
||||
mvdan.cc/gofumpt v0.3.1
|
||||
mvdan.cc/gofumpt v0.4.0
|
||||
mvdan.cc/xurls/v2 v2.4.0
|
||||
)
|
||||
|
||||
require golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
|
||||
require golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 // indirect
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.0 // indirect
|
||||
github.com/google/safehtml v0.0.2 // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20220722155223-a9213eeb770e // indirect
|
||||
github.com/BurntSushi/toml v1.2.1 // indirect
|
||||
github.com/google/safehtml v0.1.0 // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20221031165847-c99f073a8326 // indirect
|
||||
)
|
||||
|
||||
replace golang.org/x/tools => ../
|
||||
|
|
|
|||
31
gopls/go.sum
31
gopls/go.sum
|
|
@ -1,23 +1,25 @@
|
|||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
|
||||
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/frankban/quicktest v1.14.2 h1:SPb1KFFmM+ybpEjPUhCCkZOM5xlovT5UbrMvWnXyBns=
|
||||
github.com/frankban/quicktest v1.14.2/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
|
||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
|
||||
github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/safehtml v0.0.2 h1:ZOt2VXg4x24bW0m2jtzAOkhoXV0iM8vNKc0paByCZqM=
|
||||
github.com/google/safehtml v0.0.2/go.mod h1:L4KWwDsUJdECRAEpZoBn3O64bQaywRscowZjJAzjHnU=
|
||||
github.com/google/safehtml v0.1.0 h1:EwLKo8qawTKfsi0orxcQAZzu07cICaBeFMegAU9eaT8=
|
||||
github.com/google/safehtml v0.1.0/go.mod h1:L4KWwDsUJdECRAEpZoBn3O64bQaywRscowZjJAzjHnU=
|
||||
github.com/jba/printsrc v0.2.2 h1:9OHK51UT+/iMAEBlQIIXW04qvKyF3/vvLuwW/hL8tDU=
|
||||
github.com/jba/printsrc v0.2.2/go.mod h1:1xULjw59sL0dPdWpDoVU06TIEO/Wnfv6AHRpiElTwYM=
|
||||
github.com/jba/templatecheck v0.6.0 h1:SwM8C4hlK/YNLsdcXStfnHWE2HKkuTVwy5FKQHt5ro8=
|
||||
|
|
@ -33,8 +35,9 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK
|
|||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
|
||||
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
|
@ -43,11 +46,12 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
|
|||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
|
||||
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 h1:QfTh0HpN6hlw6D3vu8DAwC8pBIwikq0AI1evdm+FksE=
|
||||
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
|
||||
golang.org/x/exp/typeparams v0.0.0-20220722155223-a9213eeb770e h1:7Xs2YCOpMlNqSQSmrrnhlzBXIE/bpMecZplbLePTJvE=
|
||||
golang.org/x/exp/typeparams v0.0.0-20220722155223-a9213eeb770e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
|
||||
golang.org/x/exp/typeparams v0.0.0-20221031165847-c99f073a8326 h1:fl8k2zg28yA23264d82M4dp+YlJ3ngDcpuB1bewkQi4=
|
||||
golang.org/x/exp/typeparams v0.0.0-20221031165847-c99f073a8326/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
|
||||
|
|
@ -56,14 +60,15 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
|||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211213223007-03aa0b5f6827/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
|
|
@ -89,8 +94,8 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|||
honnef.co/go/tools v0.2.2/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY=
|
||||
honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
|
||||
honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw=
|
||||
mvdan.cc/gofumpt v0.3.1 h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8=
|
||||
mvdan.cc/gofumpt v0.3.1/go.mod h1:w3ymliuxvzVx8DAutBnVyDqYb1Niy/yCJt/lk821YCE=
|
||||
mvdan.cc/gofumpt v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
|
||||
mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ=
|
||||
mvdan.cc/unparam v0.0.0-20211214103731-d0ef000c54e5 h1:Jh3LAeMt1eGpxomyu3jVkmVZWW2MxZ1qIIV2TZ/nRio=
|
||||
mvdan.cc/unparam v0.0.0-20211214103731-d0ef000c54e5/go.mod h1:b8RRCBm0eeiWR8cfN88xeq2G5SG3VKGO+5UPWi5FSOY=
|
||||
mvdan.cc/xurls/v2 v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.17
|
||||
// +build go1.17
|
||||
|
||||
package hooks
|
||||
|
||||
import (
|
||||
"golang.org/x/tools/gopls/internal/lsp/protocol"
|
||||
"golang.org/x/tools/gopls/internal/lsp/source"
|
||||
"honnef.co/go/tools/analysis/lint"
|
||||
"honnef.co/go/tools/quickfix"
|
||||
"honnef.co/go/tools/simple"
|
||||
"honnef.co/go/tools/staticcheck"
|
||||
"honnef.co/go/tools/stylecheck"
|
||||
)
|
||||
|
||||
func updateAnalyzers(options *source.Options) {
|
||||
options.StaticcheckSupported = true
|
||||
|
||||
mapSeverity := func(severity lint.Severity) protocol.DiagnosticSeverity {
|
||||
switch severity {
|
||||
case lint.SeverityError:
|
||||
return protocol.SeverityError
|
||||
case lint.SeverityDeprecated:
|
||||
// TODO(dh): in LSP, deprecated is a tag, not a severity.
|
||||
// We'll want to support this once we enable SA5011.
|
||||
return protocol.SeverityWarning
|
||||
case lint.SeverityWarning:
|
||||
return protocol.SeverityWarning
|
||||
case lint.SeverityInfo:
|
||||
return protocol.SeverityInformation
|
||||
case lint.SeverityHint:
|
||||
return protocol.SeverityHint
|
||||
default:
|
||||
return protocol.SeverityWarning
|
||||
}
|
||||
}
|
||||
add := func(analyzers []*lint.Analyzer, skip map[string]struct{}) {
|
||||
for _, a := range analyzers {
|
||||
if _, ok := skip[a.Analyzer.Name]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
enabled := !a.Doc.NonDefault
|
||||
options.AddStaticcheckAnalyzer(a.Analyzer, enabled, mapSeverity(a.Doc.Severity))
|
||||
}
|
||||
}
|
||||
|
||||
add(simple.Analyzers, nil)
|
||||
add(staticcheck.Analyzers, map[string]struct{}{
|
||||
// This check conflicts with the vet printf check (golang/go#34494).
|
||||
"SA5009": {},
|
||||
// This check relies on facts from dependencies, which
|
||||
// we don't currently compute.
|
||||
"SA5011": {},
|
||||
})
|
||||
add(stylecheck.Analyzers, nil)
|
||||
add(quickfix.Analyzers, nil)
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !go1.17
|
||||
// +build !go1.17
|
||||
|
||||
package hooks
|
||||
|
||||
import "golang.org/x/tools/gopls/internal/lsp/source"
|
||||
|
||||
func updateAnalyzers(options *source.Options) {
|
||||
options.StaticcheckSupported = false
|
||||
}
|
||||
|
|
@ -1,14 +1,62 @@
|
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !go1.17
|
||||
// +build !go1.17
|
||||
//go:build go1.17
|
||||
// +build go1.17
|
||||
|
||||
package hooks
|
||||
|
||||
import "golang.org/x/tools/gopls/internal/lsp/source"
|
||||
import (
|
||||
"golang.org/x/tools/gopls/internal/lsp/protocol"
|
||||
"golang.org/x/tools/gopls/internal/lsp/source"
|
||||
"honnef.co/go/tools/analysis/lint"
|
||||
"honnef.co/go/tools/quickfix"
|
||||
"honnef.co/go/tools/simple"
|
||||
"honnef.co/go/tools/staticcheck"
|
||||
"honnef.co/go/tools/stylecheck"
|
||||
)
|
||||
|
||||
func updateAnalyzers(options *source.Options) {
|
||||
options.StaticcheckSupported = false
|
||||
options.StaticcheckSupported = true
|
||||
|
||||
mapSeverity := func(severity lint.Severity) protocol.DiagnosticSeverity {
|
||||
switch severity {
|
||||
case lint.SeverityError:
|
||||
return protocol.SeverityError
|
||||
case lint.SeverityDeprecated:
|
||||
// TODO(dh): in LSP, deprecated is a tag, not a severity.
|
||||
// We'll want to support this once we enable SA5011.
|
||||
return protocol.SeverityWarning
|
||||
case lint.SeverityWarning:
|
||||
return protocol.SeverityWarning
|
||||
case lint.SeverityInfo:
|
||||
return protocol.SeverityInformation
|
||||
case lint.SeverityHint:
|
||||
return protocol.SeverityHint
|
||||
default:
|
||||
return protocol.SeverityWarning
|
||||
}
|
||||
}
|
||||
add := func(analyzers []*lint.Analyzer, skip map[string]struct{}) {
|
||||
for _, a := range analyzers {
|
||||
if _, ok := skip[a.Analyzer.Name]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
enabled := !a.Doc.NonDefault
|
||||
options.AddStaticcheckAnalyzer(a.Analyzer, enabled, mapSeverity(a.Doc.Severity))
|
||||
}
|
||||
}
|
||||
|
||||
add(simple.Analyzers, nil)
|
||||
add(staticcheck.Analyzers, map[string]struct{}{
|
||||
// This check conflicts with the vet printf check (golang/go#34494).
|
||||
"SA5009": {},
|
||||
// This check relies on facts from dependencies, which
|
||||
// we don't currently compute.
|
||||
"SA5011": {},
|
||||
})
|
||||
add(stylecheck.Analyzers, nil)
|
||||
add(quickfix.Analyzers, nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !go1.18
|
||||
// +build !go1.18
|
||||
|
||||
package hooks
|
||||
|
||||
import "golang.org/x/tools/gopls/internal/lsp/source"
|
||||
|
||||
func updateGofumpt(options *source.Options) {
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2022 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
package hooks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/tools/gopls/internal/lsp/source"
|
||||
"mvdan.cc/gofumpt/format"
|
||||
)
|
||||
|
||||
func updateGofumpt(options *source.Options) {
|
||||
options.GofumptFormat = func(ctx context.Context, langVersion, modulePath string, src []byte) ([]byte, error) {
|
||||
return format.Source(src, format.Options{
|
||||
LangVersion: langVersion,
|
||||
ModulePath: modulePath,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -8,11 +8,8 @@
|
|||
package hooks // import "golang.org/x/tools/gopls/internal/hooks"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/tools/gopls/internal/lsp/source"
|
||||
"golang.org/x/tools/internal/diff"
|
||||
"mvdan.cc/gofumpt/format"
|
||||
"mvdan.cc/xurls/v2"
|
||||
)
|
||||
|
||||
|
|
@ -29,11 +26,6 @@ func Options(options *source.Options) {
|
|||
}
|
||||
}
|
||||
options.URLRegexp = xurls.Relaxed()
|
||||
options.GofumptFormat = func(ctx context.Context, langVersion, modulePath string, src []byte) ([]byte, error) {
|
||||
return format.Source(src, format.Options{
|
||||
LangVersion: langVersion,
|
||||
ModulePath: modulePath,
|
||||
})
|
||||
}
|
||||
updateAnalyzers(options)
|
||||
updateGofumpt(options)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ import (
|
|||
)
|
||||
|
||||
func TestLicenses(t *testing.T) {
|
||||
// License text differs for older Go versions because staticcheck isn't
|
||||
// supported for those versions.
|
||||
testenv.NeedsGo1Point(t, 17)
|
||||
// License text differs for older Go versions because staticcheck or gofumpt
|
||||
// isn't supported for those versions.
|
||||
testenv.NeedsGo1Point(t, 18)
|
||||
|
||||
if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
|
||||
t.Skip("generating licenses only works on Unixes")
|
||||
|
|
|
|||
|
|
@ -1036,10 +1036,8 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
|
|||
if v, ok := result.asBool(); ok {
|
||||
o.Staticcheck = v
|
||||
if v && !o.StaticcheckSupported {
|
||||
// Warn if the user is trying to enable staticcheck, but staticcheck is
|
||||
// unsupported.
|
||||
result.Error = fmt.Errorf("applying setting %q: staticcheck is not supported at %s\n"+
|
||||
"\trebuild gopls with a more recent version of Go", result.Name, runtime.Version())
|
||||
result.Error = fmt.Errorf("applying setting %q: staticcheck is not supported at %s;"+
|
||||
" rebuild gopls with a more recent version of Go", result.Name, runtime.Version())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1059,7 +1057,13 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
|
|||
result.setBool(&o.ShowBugReports)
|
||||
|
||||
case "gofumpt":
|
||||
result.setBool(&o.Gofumpt)
|
||||
if v, ok := result.asBool(); ok {
|
||||
o.Gofumpt = v
|
||||
if v && o.GofumptFormat == nil {
|
||||
result.Error = fmt.Errorf("applying setting %q: gofumpt is not supported at %s;"+
|
||||
" rebuild gopls with a more recent version of Go", result.Name, runtime.Version())
|
||||
}
|
||||
}
|
||||
|
||||
case "semanticTokens":
|
||||
result.setBool(&o.SemanticTokens)
|
||||
|
|
|
|||
|
|
@ -80,6 +80,21 @@ var FooErr = errors.New("foo")
|
|||
})
|
||||
}
|
||||
|
||||
func TestGofumptWarning(t *testing.T) {
|
||||
testenv.SkipAfterGo1Point(t, 17)
|
||||
|
||||
WithOptions(
|
||||
Settings{"gofumpt": true},
|
||||
).Run(t, "", func(t *testing.T, env *Env) {
|
||||
env.Await(
|
||||
OnceMet(
|
||||
InitialWorkspaceLoad,
|
||||
ShownMessage("gofumpt is not supported"),
|
||||
),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func TestDeprecatedSettings(t *testing.T) {
|
||||
WithOptions(
|
||||
Settings{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
. "golang.org/x/tools/gopls/internal/lsp/regtest"
|
||||
"golang.org/x/tools/gopls/internal/lsp/tests/compare"
|
||||
"golang.org/x/tools/internal/testenv"
|
||||
)
|
||||
|
||||
const unformattedProgram = `
|
||||
|
|
@ -302,6 +303,7 @@ func main() {
|
|||
}
|
||||
|
||||
func TestGofumptFormatting(t *testing.T) {
|
||||
testenv.NeedsGo1Point(t, 18)
|
||||
|
||||
// Exercise some gofumpt formatting rules:
|
||||
// - No empty lines following an assignment operator
|
||||
|
|
|
|||
Loading…
Reference in New Issue