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

9001 Коммитов

Автор SHA1 Сообщение Дата
Rob Findley 36684df4ab go/analysis/passes/unusedwrite: silence if unsafe is imported
As reported in golang/go#67684, the unusedwrite analyzer may have false
positives when used with unsafe, so silence it if unsafe is imported.

This is a rather large hammer, but there is a high likelihood of such
false positives, and they significantly detracting from the usefulness
of the analysis. Specifically: this noise causes Go developers to
disable the analyzer.

Fixes golang/go#67684

Change-Id: I855a5da6124a0495c7eb11722b466824689780a3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621817
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-28 18:18:25 +00:00
Rob Findley 17213ba81a gopls/internal/cache/parsego: support lazy object resolution for Files
For the purposes of go/analysis, gopls could not skip syntactic object
resolution, as it is part of the go/analysis contract. This prevents
analysis from reusing existing type-checked packages, leading to
increased CPU and memory during diagnostics.

Fix this by making object resolution lazy, and ensuring that all
analysed files are resolved prior to analysis.

This could introduce a race if gopls were to read the fields set by
object resolution, for example if it was printing the tree using
ast.Fprint, so we include a test that these fields are only accessed
from packages or declarations that are verified to be safe.

Since the resolver is not separate from the parser, we fork the code and
use go generate to keep it in sync.

For golang/go#53275

Change-Id: I24ce94b5d8532c5e679789d2ec1f75376e9e9208
Reviewed-on: https://go-review.googlesource.com/c/tools/+/619516
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-28 16:00:44 +00:00
Alan Donovan 7d1d070935 go/ssa/interp: disable interp tests on wasm
...as it lacks various OS fundamentals like pipes,
which are now used in the test (see CL 622355).

Fixes golang/go#70052
Fixes golang/go#70051

Change-Id: I7f247a77a284f0e61f207bd84a5f3c1c2f412b68
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622323
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-10-28 14:39:00 +00:00
Peter Weinberger ae56d93f7a internal/modindex: implement Lookups in the index
(*Index).Lookup returns matching symbols from the index.

Change-Id: I7b805be9a08116e111bb8d6453ed67f8cc92dd4d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-10-25 22:31:22 +00:00
Alan Donovan 044b16f3bb internal/gcimporter: extend markBlack workaround go1.22
Although the workaround in CL 621855 was effective for gopls,
which uses go1.23, the x/tools builders using go1.22 are
still bumping into this data race.

This change applies the same workaround to go1.22;
the data type has not changed.

Fixes golang/go#69912
Fixed golang/go#70015

Change-Id: I9f12f8815a0b089a188b9d02aec9d07eb30a496a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622319
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-10-25 17:52:35 +00:00
Peter Weinberger dabba6ac3f internal/modindex: new API for incremental update
Create() creates a new index, while Update() may write an
updated index, if there have been any changes in the module cache
since the last index was written. If there is no index it creates
one. It returns true if it wrote a new index, false if there was
no need to write a new index.

Change-Id: Ic797796c2ab6db6bd93b2059df86249ae62ca8ec
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621860
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-25 15:30:29 +00:00
Alan Donovan 7d196fc81b go/ssa/interp: fix failing recover2.go test
The "unhashable" panic message had changed in go1.14.

Fixes golang/go#34089

Change-Id: I6ba97d33fefee9e217b65904db2b07c2091d80be
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Tim King <taking@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
2024-10-25 12:38:00 +00:00
Alan Donovan f8613771ea go/ssa/interp: redirect interpreter std{out,err} to testing.T.Log
The interpreter tests have long been exceedingly noisy because
they write to os.Stdout and os.Stderr directly. This CL
temporarily redirects the output to a buffer (via a pipe),
which is printed via t.Log once the interpreter returns.
This means that a test failure only prints the output relevant
to that test.

Change-Id: Id1835a9b0f91a09fdc7e61dab38906a7b42e300f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622355
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-10-25 12:37:51 +00:00
Rob Findley 9f3c6463b9 gopls/internal/cache: memoize cache keys
analysisNode.cacheKey shows up as very hot in benchmarks, yet analysis
should observe the same invalidation heuristics as other package data.

Memoizing the cache keys in the snapshot reduced total CPU of
BenchmarkDiagnosePackageFiles by 10-15%.

For golang/go#53275

Change-Id: I0f60c3e78c77ac6e58b14308bb0331022babae69
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622037
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-10-24 15:50:50 +00:00
Rob Findley 1f162c6c5b gopls/internal/cache: async pull diagnostics and joined analysis
Make pull diagnostics async, to optimize handling of many simultaneous
requests for the diagnostics of open files. Accordingly, update the pull
diagnostic benchmark to request diagnostics concurrently.

Naively, these concurrent diagnostics would cause gopls to incur major
performance penalty due to duplicate analyses -- as much as 5x total CPU
in the pull diagnostic benchmark. To mitigate this cost, join ongoing
analysis operations using a shared global transient futureCache. This
reduces the benchmark back down close to its previous total CPU, with
reduced latency. Eyeballing the net delta of this CL in the benchmark,
it looks like +20% total CPU, -30% latency.

As a nice side effect, this more than eliminates the need to pre-seed
the file cache in the gopls marker tests. The shared futures provide
more consolidation of work than the pre-seeding, because of variance in
the cache keys of standard library packages, due to different gopls
options.

For golang/go#53275

Change-Id: Ie92bab4c140e3f86852531be8204b6574b254d8e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622036
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-10-23 20:06:04 +00:00
Alan Donovan dbb82528bc gopls/release: remove unused(?) script
It confuses me whenever I look for doc/release/*.md and
appears not to have been touched in a long time.

Change-Id: I101577e75e884ace46e0fc49d550ada1036237e9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622175
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-23 19:34:19 +00:00
Rob Findley 617638456b go/types/objectpath: break cycles through interface methods
As demonstrated in golang/go#68046, it was possible to have infinite
recursion in objectpath.For searching for objects within recursive
interface definitions. Fix this by breaking cycles.

Refactor somewhat to simplify the recursive search.

Fixes golang/go#68046

Change-Id: Idb65e305ec5949d212ec8dafff824486178652df
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621818
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-10-23 17:21:13 +00:00
Rob Findley 9e6388a3c6 internal/gcimporter: work around go/types data race in 1.23.
Work around golang/go#69912 by punching a hole through the TypeName type
to mark it black after importing. This is an unfortunate workaround, but
the fix for the long-standing data race is probably not worth
back-porting.

For golang/go#69912

Change-Id: I583305f6e893e28b881dab932c9c4825430bc4ad
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621855
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-22 22:30:52 +00:00
Rob Findley c45778760f gopls/internal/cache: avoid reporting bugs when go/packages has errors
When go/packages.Load returns an error, or has packages with errors, we
should not assume that assumptions of the resulting packages still hold.
I believe this is the cause of the two telemetry bug reports below.

Fixes golang/go#66204
Fixes golang/go#69895

Change-Id: I9beab020ddb37d36a8826cb36a576990463d7bce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621859
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-22 22:05:38 +00:00
Rob Findley 401eca0e4a gopls/internal/settings: remove "allowImplicitNetworkAccess"
This setting was slated for removal in gopls@v0.16. Nobody has
complained on the linked bug. Remove it.

Fixes golang/go#66861

Change-Id: I942dbd06755114a13ef097b4a57ffe169441e76f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621877
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-10-22 21:03:59 +00:00
Rob Findley 6618569404 gopls/internal/cache: refine a bug report related to package metadata
Refine a bug report to isolate incoherent package metadata potentially
related to using a GOPACKAGESDRIVER.

For golang/go#64235

Change-Id: I82dc6f53b1668d15cbfc146e5cf9b3c5d2ad79c5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621858
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-10-22 20:55:56 +00:00
Rob Findley 6381f0b832 gopls/internal/cache: refine bug reports
Refine a few bug reports related to incorrectly positioned type checker
errors, by differentiating the 'fixed file' case from the case with no
fixed files.

Since we haven't made progress on these bugs, we need more information
to guide our debugging.

If the bugs only occur in the presence of AST fixes, we can probably
downgrade them to not be a bug: if we're fixing the AST, we won't
display type checker errors anyway. Nevertheless, leave the bug reports
for now, so that we can collect data.

For golang/go#65960
For golang/go#66765
For golang/go#66766

Change-Id: I2060c897d249cdd5cc3e7bb183d3f563987bec57
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621876
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-10-22 20:17:14 +00:00
Alan Donovan 63e4449835 gopls/internal/telemetry/cmd/stacks: print double-claimed stacks
Otherwise it can be very hard to guess why two issues' rules
intersect!

Change-Id: I4ac88b9e95f79cf4b2b1f4c8072a6c90c07bb295
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-10-22 13:42:14 +00:00
Alan Donovan f003ff6c8f gopls/internal/test/marker: rename s/suggestedfix/quickfix/
At the protocol level, this operation requests all CodeActions
of kind "quickfix", so that's the appropriate name.
(SuggestedFix refers to types in go/analysis and in
gopls/internal/cache that are only loosely related.)

All the tests of @quickfix are now beneath testdata/quickfix
(except diagnostics/typeerr.txt since that's not its primary aim).

Change-Id: I907aab2fcc4c7f99170c1eefa5ee2cb8aca6331f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621598
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-10-21 21:43:12 +00:00
Rob Findley 8128bcf18d gopls/internal/cache: add tolerance for builtin test variants
Gopls tests are failing on CL 620196, where a test file is being added
to the builtin package. The failures were caused by test workspace
picking up new std dependencies through the builtin test variants, which
were being handled like normal packages. Queries like completion or
workspace symbols were affected, as they scan transitive imports.

Ignore builtin test variants to fix the breakage.

Change-Id: Ia1a99918b0bfb470c74470fa82e03e49fa460b06
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621095
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-18 23:04:33 +00:00
Rob Findley a199121ba9 gopls: allow for asynchronous request handling
As described in golang/go#69937, we need a mechanism that allows for
concurrent request handling in gopls. However, this cannot be
implemented entirely within the jsonrpc2 layer, because we need gopls to
observe requests in the order they arrive, so it can handle them with
the correct logical state.

This CL adds such a concurrency mechanism using a trick similar to
t.Parallel. Specifically, a new jsonrpc2.Async method is introduced
which, when invoked on the request context, signals the
jsonrpc2.AsyncHandler to start handling the next request.

Initially, we use this new mechanism within gopls to allow certain
long-running commands to execute asynchronously, once they have acquired
a cache.Snapshot representing the current logical state. This solves a
long-standing awkwardness in the govulncheck integration, which required
an additional gopls.fetch_vulncheck_result command to fetch an
asynchronous result.

This enables some code deletion and simplification, though we could
simplify further. Notably, change the code_action subcommand to
eliminate the progress handler registration, since we don't need
progress to know when a command is complete. Instead, use -v as a signal
to log progress reports to stderr.

Fixes golang/go#69937

Change-Id: I8736a445084cfa093f37c479d419294d5a1acbce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621055
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-18 20:45:24 +00:00
Alan Donovan 8ecf757a96 internal/gcimporter: remove test of unsupported "goroot" iimport
This CL eliminates the "goroot" flavor of
TestIExportDataTypeParameterizedAliases, leaving just
the "tools" flavor, and simplifies accordingly.

The logic of the goroot version assumed that importer.Default()
could read what gcexportdata.Write would write... except that
that comments correctly stated the assumption was false.

Updates golang/go#68898

Change-Id: Ifded4ed2cc2103de32ac869731176a49877d10e0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/620036
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-10-16 19:24:23 +00:00
myeunee 7310c72fba importgraph: correct typo in graph_test.go
This PR corrects a typo in the error message for the reverse.Search function.
The word "irrefexive" was incorrectly spelled and has been corrected to
"irreflexive."

Change-Id: Iaf838962c994919d4a0c39b78907c3a716d16dd9
GitHub-Last-Rev: 8ee307e3ed
GitHub-Pull-Request: golang/tools#531
Reviewed-on: https://go-review.googlesource.com/c/tools/+/620057
Reviewed-by: Robert Findley <rfindley@google.com>
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-10-16 13:52:19 +00:00
Peter Weinberger ce4cb559c3 internal/modindex: fix two bugs
Symbol types should be a single character, and now they are.

func F(int, float) is legal. Before it was being treated as if it were
F(), now it is treated as if it were F(_ int, _ float), which seems
better.

Change-Id: I051f60b16edccf54c4ce30f11b33a458413fa9af
Reviewed-on: https://go-review.googlesource.com/c/tools/+/620138
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-10-15 14:51:56 +00:00
Peter Weinberger b3482cc681 internal/modindex/cmd: Command for maintaining module cache indexes
Presently the command will create or update the index of the module
cache, or clean out obsolete indexes. An index is obsolete if it is
both more that an hour old, and not a current index pointed to by some
index-name file.

Change-Id: Ie3a79587e0e230ae7ab0b7d854c97003ace783ff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/616838
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-10-15 12:27:49 +00:00
Alan Donovan 454be607b6 x/tools: be defensive after types.Info.Types[expr] lookups
This CL is the result of a quick audit
of x/tools for places that look in the Types map and do
not handle missing entries gracefully (unless dominated
by a check for welltypedness, such as RunDespiteErrors:false
in the analysis framework). In each case it either adds
a defensive check or documents the assumption.

See https://github.com/golang/go/issues/69092#issuecomment-2389643780

Updates golang/go#69092

Change-Id: I3573512fd47ee4dca2e0b4bce2803b92424d7037
Reviewed-on: https://go-review.googlesource.com/c/tools/+/617416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-10-14 18:46:52 +00:00
Peter Weinberger dec6bf18ed internal/modindex: update module cache index
This CL contains tests that the module cache
index can be updated. The tests cover all the
cases in modindex.go.
Change-Id: Ia5988fb0d2be1cbe5e26d9d5d0f0d43ce1e0e5d2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/619695
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-14 15:11:07 +00:00
Alan Donovan 6c6def26dd gopls/internal/telemetry/cmd/stacks: fix bad tmpreaper interaction
This CL causes stacks to check for the presence of a go.mod file
for each cloned repo, not just a directory, as the tmpreaper (at
least on macOS) deletes the stales files before it deletes the
directories. If the file is not found, we delete the directory
tree.

Change-Id: Idf4990f707704e12ae15120269cf7d490e406b41
Reviewed-on: https://go-review.googlesource.com/c/tools/+/620035
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-10-14 14:49:53 +00:00
Alan Donovan 1a5fe8307f gopls: remove cruft
This CL deletes unreferenced declarations and unexports
some unnecessarily public ones.

Change-Id: Ic257645c39bedfe151b92134b148ddb99bf3bf4a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/619855
Auto-Submit: 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-10-14 14:09:51 +00:00
xzb 244a31e15e gopls/internal: CodeAction: quickfix to generate missing method
This change provides a new "quickfix" code action to repair a
 function call x.f() with a "type X has no field or method f" error
by generating a stub declaration of the missing method.

- extract common functionality about adjusting import,
generating diffs to a shared function.
- add new stubMissingCalledFunctionFixer (for missing method calls),
change stubMethodsFixer to stubMissingInterfaceMethodsFixer
(for interfaces) to make it  not vague about which kind of stub
it actually be.
- algos to get type info:  for arguments, get type directly,
for return values, currently only implement inferring from variable
assignment and parameter assignment.
- remove a test in stub.txt that tests local types can't be stubbed,
after this CL, this check has been moved to GetCallStubInfo
and GetIfaceStubInfo, thus gopls will not offer a bad fix.

There is a detailed test that demonstrated this pr.

Fixes golang/go#69692

Change-Id: Ia7aecdaf895da2a9a33b706f26b7766e4d42c8a1
GitHub-Last-Rev: 7d9f4e0b46
GitHub-Pull-Request: golang/tools#528
Reviewed-on: https://go-review.googlesource.com/c/tools/+/617619
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
2024-10-14 13:51:43 +00:00
Tim King 87d613117b internal/typeparams: support parameterized aliases in Free
Derived from https://go.dev/cl/603935.

Change-Id: I1c5ab7cc180c33e69244fe2cfdc79fd9625eab95
Reviewed-on: https://go-review.googlesource.com/c/tools/+/619235
Commit-Queue: Tim King <taking@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-11 19:29:29 +00:00
cuishuang aa87dcfff7 go/analysis/passes: execute gofmt
Change-Id: I4f4c670f002272b3fa45e7f7eb43916413c975a4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/618896
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Tim King <taking@google.com>
Commit-Queue: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-10 21:01:00 +00:00
xieyuschen feffeaabe7 go/packages: report an error from Load when GOROOT is misconfigured
Load should return an error when 'go list' command returns the following error:

    err: exit status 2: stderr: go: no such tool "compile"

This occurs when internally running `go list` on a misconfigured GOROOT directory.

Fixes golang/go#69606

Change-Id: Ib7bf58293612e26aa33d2cf8230378747ad01820
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615396
Reviewed-by: Michael Podtserkovskii <michaelpo@meta.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Commit-Queue: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2024-10-10 20:22:38 +00:00
Tim King 50179f2225 Revert "internal/aliases: add a function to conditionally enable aliases"
This reverts commit f8f3c13ff3.

Reason for revert: https://go.dev/cl/619395 appears to be a better solution for the same problem.

Change-Id: Ie3f290fca74b2cc2627484504b6db780f89b3bb4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/619415
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Tim King <taking@google.com>
2024-10-10 20:20:59 +00:00
Tim King 4f6e118e23 all: set gotypesalias=1 when using >=1.23 toolchain
Set gotypesalias=1 when using >=1.23 toolchain on all of
the main packages in x/tools that use go/types. Does not include
packages that are ignored due to build tags.

This effectively upgrades commit https://go.dev/cl/617095.

For golang/go#69772

Change-Id: I434c280b928ad21e1fd9c7f880e1324c14741dc3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/619395
Reviewed-by: Robert Findley <rfindley@google.com>
Commit-Queue: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-10 17:44:59 +00:00
Tim King 915132c3ad internal/typesinternal: add NamedOrAlias type
A NamedOrAlias represents either a *types.Named or a *types.Alias.

Used this generalization in gopls.

This change is derived from https://go.dev/cl/603935.

Change-Id: Ica1669784dec6bcdefafde02e9a6ce789db28814
Reviewed-on: https://go-review.googlesource.com/c/tools/+/618735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Commit-Queue: Tim King <taking@google.com>
2024-10-10 17:08:25 +00:00
Rob Findley bd86f8c28a gopls/internal/cache/analysis: lazily resolve the import map
In CL 613715, we made import lookup lazy to mitigate the quadratic
construction of the import map during type checking. This CL makes the
equivalent change for the analysis driver.

Since analysis does not have fine-grained invalidation, it is even more
susceptible to the performance cost of this quadratic operation:

DiagnosePackageFiles-64
│  before.txt   │              after.txt              │
│    sec/op     │    sec/op     vs base               │
  1691.6m ± ∞ ¹   693.6m ± ∞ ¹  -59.00% (p=0.008 n=5)

│   before.txt   │               after.txt               │
│ cpu_seconds/op │ cpu_seconds/op  vs base               │
     6.480 ± ∞ ¹      3.260 ± ∞ ¹  -49.69% (p=0.008 n=5)

For golang/go#53275

Change-Id: I8690bc85848fe1e36391d4622aa2e3d3f9878f57
Reviewed-on: https://go-review.googlesource.com/c/tools/+/619095
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-10-09 17:58:41 +00:00
Tim King a4e0a9e3d7 cmd/bundle: enable materialized aliases
Change-Id: If402c12e2412890334c7188b6579964cb4b97454
Reviewed-on: https://go-review.googlesource.com/c/tools/+/618676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-10-09 17:01:35 +00:00
Rob Findley db26c69117 cmd/stringer: fix test on android
Fix a broken test build on android due to inconsistent build constraints
in test files.

Change-Id: I6350797fb65f2f2699e11b95b01a4aa3b3b84307
Reviewed-on: https://go-review.googlesource.com/c/tools/+/618996
Run-TryBot: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-10-09 16:29:45 +00:00
Rob Findley f08b5c1e7c gopls/internal/test/integration/bench: add a pull diagnostics benchmark
Add a benchmark that exercises a currently slow operation using pull
diagnostics: requesting diagnostics for a large number of package files.

For golang/go#53275

Change-Id: I233cfaeb4242ab44a7b46c870a195fdf7793c05c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/618995
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-10-09 15:28:35 +00:00
John Dethridge bbb979fff6 go/callgraph/vta: use node IDs for type flow graph
The vtaGraph type stores a directed graph, where the nodes are interface
values.

This change maps the nodes to unique integers internally and stores the
adjacency lists of the graph using the integers, which are smaller and
faster to work with.

This saves 40% time and peak memory usage when analyzing some very large
projects.

Change-Id: I45468ea9b478d2291f80140158cc8719e992b14e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614095
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-09 15:01:56 +00:00
Alan Donovan cf8979b7fc gopls/doc/features: add index of supported Code Actions
Also:
- add reminders to keep things in sync.
- use explicit anchors instead of relying on GitHub's
  unspecified algorithm (which doesn't work in mdweb preview).

Fixes golang/go#54115
Fixes golang/go#68791

Change-Id: I17c800075260e2e72dcd239fb7248a0cb3851d5d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/618616
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-10-08 22:13:03 +00:00
Tim King 86219190c2 go/ssa/ssautil: disable fmt imports on wasm tests
Fixes golang/go#69783

Change-Id: Iebdd90527de4efe8995d5b42d6e25089761135dc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/618555
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tim King <taking@google.com>
2024-10-08 17:49:19 +00:00
Peter Weinberger f439874c29 internal/modindex: add symbol information
This CL adds information about exported symbols to the module cache
index, together with a minimal test.

A future CL will add a Lookup function for finding completions for
selectors.

Change-Id: Ic36b5f30383187f9c5551ee2757258ed1445ea53
Reviewed-on: https://go-review.googlesource.com/c/tools/+/616416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-10-08 11:58:44 +00:00
Rob Findley f21a1dce1e gopls: add initial support for pull diagnostics
Implement the scaffolding for pull diagnostics. For now, these are only
supported for Go files, only return parse/type errors for the narrowest
package in the default view, do not report related diagnostics, and do
not run analysis. All of these limitations can be fixed, but this
implementation should be sufficient for some end-to-end testing.

Since the implementation is incomplete, guard the server capability
behind a new internal "pullDiagnostics" setting.

Wire in pull diagnostics to the marker tests: if the server supports it
("pullDiagnostics": true), use pull diagnostics rather than awaiting to
collect the marker test diagnostics.

For golang/go#53275

Change-Id: If6d1c0838d69e43f187863adeca6a3bd5d9bb45d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/616835
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-10-07 22:08:29 +00:00
Rob Findley c19060b012 gopls/internal/cache: use packageHandles to hold an active package cache
Previously, gopls was keeping a common import graph up to date between
snapshots, to optimize re-typechecking open packages. However, this had
several downsides:
 - It required rather complicated accounting
 - Working in package A could get slower after opening package B, if
   package B was in the forward closure of A, since it reduced the
   common import graph.
 - Since imports were constructed a-priori to type checking, we imported
   *all* packages in the forward closure of open packages, even if they
   wouldn't be needed for type checking, inflating the memory footprint.

This CL changes gopls to instead keep track of the active package on the
packageHandle, and invalidate its imports independently of other active
packages. As a result, we can eliminate the complicated importGraph
logic and the associated relationships between open packages. We also
reduce memory by holding on to a minimal set of imports for open
packages.

Change-Id: I82c49bb7002ab748497f34b43844b34176bdef9c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614165
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-10-07 21:38:32 +00:00
Tim King a30b2075ca internal/versions: remove InitFileVersions
InitFileVersions is not longer conditionally needed at x/tools
supports Go >= 1.22.

Change-Id: I5df1b46463d23acda569e1378027d542ac749f93
Reviewed-on: https://go-review.googlesource.com/c/tools/+/617637
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Commit-Queue: Tim King <taking@google.com>
2024-10-07 18:12:27 +00:00
Jack Baldry de11c555db gopls/doc/codelenses: fix link typo
Change-Id: I1105cec5cf851932a15410a674196e32c97ac832
GitHub-Last-Rev: a324267649
GitHub-Pull-Request: golang/tools#527
Reviewed-on: https://go-review.googlesource.com/c/tools/+/617617
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tim King <taking@google.com>
2024-10-06 21:46:03 +00:00
Tim King 0b989c812d internal/versions: update test expectations
Updates test expecations now that go.dev/cl/607955 has been submitted.

Change-Id: I795a14f7690026620f270e2db329945286764046
Reviewed-on: https://go-review.googlesource.com/c/tools/+/617635
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Tim King <taking@google.com>
2024-10-05 18:05:32 +00:00
Meng Zhuo 89a53114db go/analysis/passes/asmdecl: allow syscall write registers implicitly
Syscall will write register implicity, which asmdecl should allow
this writes.

Fixes golang/go#69352

Change-Id: I7e0dece5428e9ef359b89ce418adc533f7515b1b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611815
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-10-05 11:54:47 +00:00