Граф коммитов

8748 Коммитов

Автор SHA1 Сообщение Дата
cuishuang 7398f36f57 all: fix some symbols error in comment
Change-Id: If4bd2e8cd8dded33d434f4b60217fa46fcf5e934
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611796
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2024-09-09 14:44:08 +00:00
Alan Donovan f111c72426 go/callgraph/rta: skip test on js platform
(Yesterday's CL 609576 added a dependency on packages.Load.)

Fixes golang/go#69299

Change-Id: Id858bbbb347ef137e053669b2fdef9522d057776
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611576
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-09-06 22:55:36 +00:00
Rob Findley 9f9b7e39b5 gopls/internal/settings: add missing deep cloning in Options.Clone
As noted in a TODO, it appeared that settings.Clone was failing to deep
clone several map or slice fields. A test revealed that ten (!) fields
were not deeply cloned.

Fix this by:
1. Removing pointers and interfaces from settings.Options, by making
   ClientInfo a non-pointer, and by making LinksInHover a proper enum.
2. Adding a deepclone package that implements deep cloning using
   reflection. By avoiding supporting pointers and interfaces, this
   package doesn't need to worry about recursive data structures.

Change-Id: Ic89916f7cad51d8e60ed0a8a095758acd1c09a2d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/606816
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2024-09-06 21:56:41 +00:00
Rob Findley ce7eed4960 doc/generate: minor cleanup
Remove the unused 'upperFirst' function, and fix a potential NPE due to
an incorrect predicate.

Change-Id: I671a3418b82ea77e5c9bb598f2be0b958078e464
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611575
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2024-09-06 21:37:56 +00:00
Zvonimir Pavlinovic 075ae7d276 go/callgraph/vta: add basic tests for range-over-func
The tests check the callees at the call to yield and type flow out of
the range-over-func iterator. If needed, a test for defer will be added
in a follow-up CL.

Change-Id: Ic9208ac0824a36fb50879730e8ec9398b9b6e284
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611395
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
2024-09-06 19:23:05 +00:00
Alan Donovan 2c7aaab748 go/ssa: skip failing test
Updates golang/go#69287

Change-Id: I1312d3ceb40ce0f899008730cf4bbfde04c2b648
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610938
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-06 13:08:02 +00:00
Zvonimir Pavlinovic 1b5663fbc8 go/callgraph/vta: perform minor cleanups
Change-Id: Icc92a565c67f0678da50cb18255d8cd590e7c66a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611275
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-09-05 21:14:23 +00:00
Rob Findley 0a498831d1 gopls/go.mod: update the go directive to 1.23.1
With Go 1.23.1 released, fixing some bugs in go/types Alias support, we
can now update the gopls go.mod go directive.

Fixes golang/go#65917

Change-Id: I2d6d3966de424048dceab1b2f7b795ec6998c863
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610936
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-09-05 19:37:13 +00:00
Gopher Robot ad366a81ee go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I7da2478d54e3963cf485b5d95e3b65f03a80343d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610661
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-09-05 17:57:31 +00:00
xieyuschen 4fb36d15cc go/callgraph/rta: add rta analysis test case for multiple go packages
* use go/packages to load packages

Change-Id: I6e9f81b282cddc186b4905a23ff635cd98245ac8
GitHub-Last-Rev: a859e27d81
GitHub-Pull-Request: golang/tools#513
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609576
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-09-04 20:07:52 +00:00
Rob Findley dc4d64cc1c gopls: fix non-constant format strings
Fix vet failures related to the new vet check for non-constant format
strings with no args (golang/go#60529).

Change-Id: If63006613ec4827b8f7d23990654f5ecc1521ec8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610795
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-04 18:00:29 +00:00
Zvonimir Pavlinovic c758e54fc7 cmd/callgraph: make vta use internal version of CHA
That version is faster and uses less memory.

Change-Id: I1839aa672fab25833da2ffa2dfcb079db67dd922
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610537
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-04 17:50:33 +00:00
Rob Findley 94b564cd92 go.mod: for consistency with other repos, use 1.22.0 in go.mod
For golang/go#69095

Change-Id: I181e405753866699e70632e5057bb3c7e39e7dfb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610716
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-09-04 16:43:30 +00:00
Rob Findley 70f5626413 all: with 1.23 out, update Go directive to Go 1.22
Now that 1.23 is out, and 1.19 and 1.20 trybots have been updated to be
optional in CL 610395, we can update the go.mod files to use Go 1.22.6.
This will unblock tagging x-repos, since there won't be conflicts with
x/mod.

A subsequent CL will update the gopls go.mod file to 1.23.1, once that
minor version is released (shortly).

For golang/go#65917

Change-Id: I663918f7be5a3e340703ae82e13b93e9e0f2877d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-09-04 14:33:11 +00:00
Andrew Pollock 5a3171b601 internal/typesinternal: correct spec anchors in comments
It seems somewhere along the way, an additional underscore was added
to the anchors in the spec, breaking these links.

Change-Id: I1bff23e0c0e3f85bcb4700fb9983c19a327c94d1
GitHub-Last-Rev: d5c41f1874
GitHub-Pull-Request: golang/tools#515
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609578
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
2024-09-04 14:10:57 +00:00
Alan Donovan c538e2c079 go/callgraph/static: avoid ssautil.AllFunctions
AllFunctions is complex mess. This change rewrites the static
algorithm to avoid it. It does reduce the number of
call graph nodes that are discovered (by something like 15%),
and the running time by a similar amount, but the principle
is slightly more defensible.

Also, document exactly what it does, and why it is the way
it is.

Updates golang/go#69231

Change-Id: I7e25237f0908315602ba0092083f247a140b9e22
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609280
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-03 23:32:36 +00:00
Tim King 2db563b1a3 internal/gcimporter: copy over ureader changes
Copy over the ureader.go changes from GOROOT's
go/internal/gcimporter.

Adds a test that goes through gc export data.

Updates golang/go#68778

Change-Id: Ie4b91dfdb1ab9f952631a34c3691dc84be8831a7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609317
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-09-03 21:06:05 +00:00
Zvonimir Pavlinovic 09886e004e go/callgraph/vta: allow nil initial call graph
When nil is passed as the initial call graph, vta will use a more
performant version of CHA. For this purpose, lazyCallees function of CHA
is exposed to VTA.

This change reduces the time and memory footprint for ~10%, measured on
several large real world Go projects.

Updates golang/go#57357

Change-Id: Ib5c5edca0026e6902e453fa10fc14f2b763849db
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609978
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-09-03 16:28:51 +00:00
Tim King e5ae0a9e68 internal/pkgbits: cleanup pre-Go 1.17 workaround
Now that golang/go#44505 is resolved, we can simplify frames_go1*.go.

This was already done in GOROOT in https://go.dev/cl/420903.

Change-Id: Ia7f2a123794fad62532bae2da267b0c8034917bc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-08-30 22:00:18 +00:00
Zvonimir Pavlinovic 264b4b5b0d go/callgraph/vta: add return parameter nodes for functions
The change improves the performance of VTA. If a function returns F
values, has R return instructions, and is called at C places (as
given by the initial call graph), previously we could generate
R x F x C edges in the type propagation graph. With the approach
of introducing artificial return parameters, we create F x (R + C)
edges instead.

Measured on a large project, this introduces ~5% time savings on
average. When the initial call graph is CHA, the type propagation graph
is ~31% smaller. When the resulting call graph is then used as the
initial call graph, then the graph is ~21% smaller.

This will also enable use of one-direction callgraphs.

Change-Id: I5de1774f11ce3bf23ac3c768df9e2c9f37777817
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609318
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Tim King <taking@google.com>
2024-08-30 21:09:21 +00:00
Rob Findley 063360f92f gopls: update x/telemetry dependency
Update x/telemetry to pick up the fixes for golang/go#68976 and
golang/go#68946.

Commands run (from the gopls module):
  go get golang.org/x/telemetry@f29ab53
  go mod tidy -compat=1.19

For golang/go#68916

Change-Id: Ifbe16ece970a89336f3e372ddfde088cf0770eac
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609195
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2024-08-30 17:49:51 +00:00
Tim King 28f3bc0bf6 internal/pkgbits: copy over changes for V2
Copy over changes from GOROOT's internal/pkgbits for unified IR
version V2.

Updates golang/go#68778

Change-Id: I7813767e8c11a0d0227e2284af07ce0d86291476
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609316
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-30 17:46:31 +00:00
Zvonimir Pavlinovic fd2067f0e7 go/callgraph/vta: use struct{} instead of bool in sets
Since type propagation graphs can get large, switch using bools and use
the lighter struct{}{} values. This does not affect readability much, so
in principle this change should be a no brainer.

Change-Id: I8fcc0ad0ab2ab38d39c958da30e7502c9e108981
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609695
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-29 20:34:00 +00:00
Rob Findley ce02ccd159 gopls/internal/test/marker: simplify completion markers
Simplify the rank, rankl, and snippet markers, and address TODOS, by
introducing a completionLabel parameter type which may be converted from
a string literal or completionItem (by taking its label).

This change allowed the rank and rankl markers to be combined, and
eliminates the need to use @item markers in snippet tests, just to
extract their label.

This will make it easier for external contributors to add tests for
completion, such as in CL 608695.

Change-Id: I0f848b788ac4cb179a8ce264d99f93c952a0bdd7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609595
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-29 16:17:54 +00:00
xzb 4ead70ccce gopls: report semantic tokens of top-level type constructor modifiers
These new semantic type modifiers will be reported in places of type definition,
type embedding, type alias, variable definition, parameter type,
return type and comments link.

Fixes golang/go#68975

Change-Id: I21ebd758351ee4c6e7bd7a0d34a093b3a6ad4ac8
GitHub-Last-Rev: f825f8aeb7
GitHub-Pull-Request: golang/tools#511
Reviewed-on: https://go-review.googlesource.com/c/tools/+/608156
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2024-08-28 20:45:25 +00:00
Rob Findley 826d8d971b gopls/internal/cache: add a note about GOMEMLIMIT and ballasts
As suggested post-submit in CL 608796, add a note explaining why
GOMEMLIMIT doesn't help gopls solve its GC CPU problems, and a ballast
is still necessary.

Change-Id: Ia452129e259c6f44a0f807028543699d3dd19495
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609236
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-28 17:58:38 +00:00
Rob Findley aaf49f1fb8 gopls/internal/cache: add a 100MB ballast to reduce GC CPU
As described in the doc comment, add a 100MB ballast to reduce GC CPU in
small workspaces or during gopls startup.

Change-Id: I43ff2dcd15e62bebde43fb27567d19e462b2fa22
Reviewed-on: https://go-review.googlesource.com/c/tools/+/608796
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-28 16:26:39 +00:00
Rob Findley 12307aad20 gopls/internal/util/lru: make lru.Cache generic
The lru.Cache type was written before we could use generics in gopls.
Make it generic, to benefit from a bit more ergonomic APIs.

Change-Id: I8475613580156c644b170eaa473f927f8bd37e67
Reviewed-on: https://go-review.googlesource.com/c/tools/+/608795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-08-28 16:22:06 +00:00
Rob Findley 594cdabebb gopls: increment the telemetryprompt acceptance counter for each session
Increment the gopls/telemetryprompt/accepted counter every time we read
the prompt file, so that we can actually use the resulting data. We
don't upload any counter files that overlap with periods of time when
telemetry uploading was not enabled, so with the previous model of only
incrementing the counter at the moment the prompt was accepted, we will
never upload the counter file into which the acceptance is recorded.

With the new model, the counter will give us a sense of what fraction of
telemetry participants opted-in as a result of the prompt.

For golang/go#68770

Change-Id: I8890c73b5bfa19023bb24fd156bcaa9eb46295ad
Reviewed-on: https://go-review.googlesource.com/c/tools/+/607758
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-28 15:34:29 +00:00
Michael Matloob adb7301a7f internal/versions: disable a test case incompatible with CL 607955
CL 607955 is changing the behavior of "//go:build" file versions.
Before, file versions did not apply if go version was set for the
package, but after CL 6079055, the package's go version does not
influence whether the file version is applied: max(fileVersion, go1.21)
will always be applied.

Once CL 607955 is released in a go 1.23 minor release, we can update the
test to require go1.23 and test for the new behavior (though it would
fail for users building with a version of go older than the minor
release with the behavior update).

For golang/go#68658

Change-Id: I99d39ce108274edf401d861e553ad923b508f936
Reviewed-on: https://go-review.googlesource.com/c/tools/+/608797
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-27 21:22:16 +00:00
Tim King 0734f6249f internal/gcimporter: support type parameterized aliases in indexed format
Adds support for type parameterized aliases in indexed format to gcimporter.

Updates golang/go#68778

Change-Id: I475ab30fee8d1d273f678496a1c2c12b011b8a95
Reviewed-on: https://go-review.googlesource.com/c/tools/+/606335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-08-23 19:22:19 +00:00
Tim King b5f24ec37b internal/aliases: add type parameters argument to NewAliases
Adds a type parameters argument to NewAliases and updates all
usage locations. Also adds a unit test that creates a type
parameterized alias.

Updates golang/go#68778

Change-Id: I5e3e76a5f597cf658faa9036319eded33eeb9286
Reviewed-on: https://go-review.googlesource.com/c/tools/+/607535
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-22 22:34:20 +00:00
Ethan Reesor f5c7449850 gopls/internal: implement Packages command
Implements the `gopls.packages` command.

Updates golang/go#59445

Change-Id: Ia72a971b7aac9baa964c8cf5eee8b332b3125fa4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/600355
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-08-22 18:55:30 +00:00
Ethan Reesor e5e8aa8472 gopls/internal: implement Modules command
Implements the `gopls.modules` command.

Updates golang/go#59445

Change-Id: Ifb39e0ba79be688af81ddc6389570011b4d441cc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/598815
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-22 00:06:43 +00:00
Tim King 9ef0547234 internal/gcimporter: move indexed format docs
Move the documentation for indexed export data format from
  $GOROOT/src/cmd/compile/internal/typecheck/iexport.go
to
  x/tools/internal/gcimporter/iexport.go .
This is the only current writer of this format.

Updates golang/go#68778
Updates golang/go#68898

Change-Id: I365f56315d03affc5860cf407ea6e3d0caa1a88e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/607495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-08-21 22:05:09 +00:00
Kevin Burke c7adb6311f go/analysis/passes/fieldalignment: fix doc
"go fieldalignment" is not a command that works.

Change-Id: I0eda2c0491c26c30c6661be96d3f6c7e5db920ff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/607295
Reviewed-by: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-21 17:24:47 +00:00
Tim King 66adacf20f internal/pkgbits: improve ureader panic message
Improves the ureader panic message to tell users what
package has the problem and to update their tools.

Updates golang/go#68778

Change-Id: Ia19f43aa2301627109abbebac0ddc7c5666ffd9a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/604596
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-08-16 16:31:42 +00:00
Alan Donovan e104dc835a gopls/internal/settings: rename goTest code action to source.test
Change-Id: I0ef0285cd35e32d259a7dc0bb9712ff61d99f3f6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/604795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-08-15 21:04:46 +00:00
Tim King dfcdf50220 go/analysis/passes/copylock: add support for ForStmt
Adds diagnostics when ForStmt variables are copied by
iteration in files with GoVersion>=1.22.

Fixes golang/go#66387

Change-Id: Id4aaaa7feb78bf89e5bf1320be3859af5998d8d0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-08-15 19:58:07 +00:00
Alan Donovan 136c165474 gopls/internal/cache: remove spurious assertions
The various assertions that the package "unsafe" has
Metadata ID "unsafe" all appear to be false when using
Bazel via its gopackagesdriver.

I was (rather embarassingly) unable, within a reasonable
amount of time, to successfully analyze a trivial
hello-world Bazel project using the gopackages debugging
tool and the Bazel gopackagesdriver, so unfortunately
I can't verify the bug or its fix. The documentation
https://github.com/bazelbuild/rules_go/wiki/Editor-and-tool-integration#standard-library
seems to say that all the std packages should be recognized
as command-line targets. Nonetheless, the issue is clearly
related to Bazel from the statistics, and the ID==PkgPath
assumption is clearly unwarranted.

Fixes golang/go#60890

Change-Id: I4769083bfb0cba0a8698c7ec2e8e7b2d044e3a5c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/605735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-08-15 15:01:08 +00:00
Rob Findley 7cc3be7d11 internal/imports: use a clean GOMODCACHE for the scan root directory
The directories processed by gopathwalk are clean, yet in the scan
callback are assumed to have the root as a prefix. For the module cache,
this root was previous not guaranteed to be clean, if it came from a
GOMODCACHE environment variable. As a result, the computed relative path
may be inaccurate, and may even panic if the unclean root is much longer
than its clean form.

Reproduce the crash of golang/go#67156 in a test, update
scanDirForPackage to be more robust, and fix the uncleanliness of the
module cache root.

Also fix some handling of GOMODCACHE cleanup in imports tests.

Fixes golang/go#67156

Change-Id: Ia899256fed9629b7e753a52feb02b4235bfc8388
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-08-13 17:53:00 +00:00
Tim King d47b4fb9d8 internal/testfiles: adjust test so all modules are after 1.21
Updates golang/go#68658

Change-Id: Ifcc6c4b2cc8fb15ce903176d2817d796317a97be
Reviewed-on: https://go-review.googlesource.com/c/tools/+/604955
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-13 17:11:19 +00:00
Gopher Robot c1241b9c5d internal/stdlib: update stdlib index for Go 1.23.0
For golang/go#38706.

Change-Id: If78cbed6c279709908bd85579da1f5dc0fd45df3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/605196
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2024-08-13 17:00:02 +00:00
Alan Donovan e6bef924df gopls/internal/golang: downgrade assertion in methodsets index
A query for exported method T.M triggers a paradoxical
methodset(T)={} assertion. But an ill-typed T may have
both a field and a method named M causing the methodset
to indeed be empty.

+ Test.

Fixes golang/go#67978

Change-Id: Iecbf98ff53afab00ebb51f83ed261a0318b42771
Reviewed-on: https://go-review.googlesource.com/c/tools/+/605015
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-12 22:27:54 +00:00
Michael Matloob 7f262d66c5 all: disable tests incompatible with CL 603895
The tests disabled in this CL depend on being able to downgrade Go
versions to versions earlier than Go 1.21. This behavior will change
with CL 603895. Disable these tests for now and re-enable them with
fixes in a later CL.

For golang/go#68658

Change-Id: I13bdc03117989a128d90195ac90b2905102d293f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/604817
Commit-Queue: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
2024-08-12 18:00:05 +00:00
ZHOU Zehua a76f882cf0 gopls: enhance read/write access distinction in document highlighting for symbols
The definition of 'write access' is same as it in GoLand. Some examples are
access to variables in declaration, assignment(left value), self increasing,
channel sending and composite literal.

The algorithm to find write access is same as it in jdt (Java LSP), by
visiting every write statement in ast traversal and collecting the positions
of access to variables.

Fixes golang/go#64579

Change-Id: I497ec7f15906cf4157ad1965e01264eb35ce973b
GitHub-Last-Rev: cee436c69b
GitHub-Pull-Request: golang/tools#503
Reviewed-on: https://go-review.googlesource.com/c/tools/+/597675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-08-10 20:21:02 +00:00
Alan Donovan 4dc9194b31 go/callgraph/vta: fix test under GODEBUG=gotypesalias=1
The test expectations depend on whether aliases are
materialized; update them, and suppress the test when
gotypesalias=0.

Also, clarify the failure message.

Fixes golang/go#68799

Change-Id: I4cb9429377e5423d04651c45a99d0c3fee5bef5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/604257
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-08-09 13:36:18 +00:00
Alan Donovan 28ba9914c6 go/analysis/passes/printf: add missing Unalias call
The maybePrintfWrapper function checks to see that a function
has the form of a printf wrapper, but it wrongly assumed that
the representation of the type of the "args ...any" parameter
is exactly interface{}, not a named alias. This will not work
with gotypesalias=1.

Unfortunately our CL system failed to report this (or indeed
any gotypesalias=1 coverage at all) because of a bug in the
Go bootstrapping process that, in the absence of a go.work file
(which sets the language version to go1.23), the default values
of the GODEBUG table were based on an older version of Go.
(The problem was only noticed when running a test of unitchecker
locally in the context of issue 68796.)

Also, the problem wasn't caught by our existing tests of the
printf checker because they all pre-date "any", and so spelled
it "interface{}".

This CL will need to be vendored into the go1.23 release.

Updates golang/go#68744
Updates golang/go#68796

Change-Id: I834ea20c2a684ffcd7ce9494d3700371ae6ab3c1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603938
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-08 21:40:27 +00:00
Gopher Robot 3057be8f63 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I81218876c6b66a0aa17beb6e0917d60cd6987100
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603419
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
2024-08-06 19:12:18 +00:00
idnandre 4653e48eb8 gopls/internal/analysis: add skipped analysis simplify on generated code
On generated code, gopls always suggest to simplify code produced literals polluting the "Problems" pane in IDE, while properly refusing to format file on save because it is generated code.

This change will make simplifycompositelit, simplifyrange, simplifyslice skipped on generated code, so it will not polluting the "Problems" pane in IDE.

Fixes golang/go#67733

Change-Id: I99b3f083ce96594f360576f530cfc7f4b77c1cc1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/598835
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-08-06 13:34:56 +00:00