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

8455 Коммитов

Автор SHA1 Сообщение Дата
Alan Donovan b4b81864a1 internal/apidiff: support materialized aliases
(The previous CL 559935 was insufficient.)

Also, improve test output.

Updates golang/go#65294

Change-Id: I05cafadce0dd6f18ff66d2ca462a3eb546c4ca81
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577576
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-04-09 16:22:16 +00:00
Alan Donovan 3520955d2d go/types/typeutil: implement correct hashing of aliases
Only the Alias constructors should be ignored, not any
Named ones.

(The existing map_test caught this.)

Change-Id: I8593bd6e7a6a00b9ea5921e402c61db948fad6bd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577575
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-04-09 14:12:03 +00:00
Alan Donovan f6298eb118 gopls/internal/cache: add debug assertions to refine golang/go#66732
Also, use go1.19 generic helpers for atomics.

Updates golang/go#66732

Change-Id: I7aa447144353ff2ac5906ca746e2f98b115aa732
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577435
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-04-08 20:26:43 +00:00
Robert Findley f41d27ef3a gopls/internal/cache: avoid panic when the primary diagnostic is broken
If the primary diagnostic has invalid position information (due to a bug
in the parser or AST fix logic), gopls may panics when linking primary
and related information. Avoid this panic.

Fixes golang/go#66731

Change-Id: Ie2f95d158a1c93d00603a7ce4d38d8097bd8cb08
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577259
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-04-08 18:28:40 +00:00
Alan Donovan c0ab01382c go/packages: doc: type symbols are consistent only within one Load
Updates golang/go#66690

Change-Id: I26199c39434ab83c1a25756bd5f135a0ea785fad
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577256
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-08 16:32:52 +00:00
Alan Donovan 564c0e987c gopls/internal/telemetry/cmd/stacks: improve summary
This CL causes the summary displayed by stacks to:
- display each unique stack ID for new issues;
- display a count for each issue (if known) or stack ID (if not);
- sort by descending order of those counts;
- separate the existing and new issues; and
- ignore "devel" binaries in the total count figure.

The "new issue" form logic is extracted to a function.

Change-Id: I52249915f63865fba4e9fa836b47de1f290f16a9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576683
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-04-08 16:27:19 +00:00
Robert Findley de6db989f5 internal/check: filter out too-new Go versions for type checking
The type checker produces an error if the Go version is too new. When
compiled with Go 1.21, this error is silently dropped on the floor and
the type checked package is empty, due to golang/go##66525.

Guard against this very problematic failure mode by filtering out Go
versions that are too new. We should also produce a diagnostic, but that
is more complicated and covered by golang/go#61673.

Also: fix a bug where sandbox cleanup would fail due to being run with a
non-local toolchain.

Fixes golang/go#66677

Change-Id: Ia66f17c195382c9c55cf0ef883e898553ce950e3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576678
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-08 16:03:56 +00:00
Alan Donovan 5c3c2ff0f0 gopls/internal/golang: RenderPkgDoc: fix anchors for promoted methods
The anchor of a promoted method should be based on the documented
type, not the embedded type.

Change-Id: I547ec00bffce223b045b1f1bb7b101769451b844
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577296
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-08 15:12:55 +00:00
Alan Donovan 8a0c6e2d04 gopls/internal/server: report HTTP panics via telemetry
Change-Id: Ifcb5cdbcde92d73fd5d626b8d70ed47200745633
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576682
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-04-08 13:17:01 +00:00
Alan Donovan c7b6b8d02f gopls/internal/cache: analysis: repair start/end and refine bug report
Poor parser error recovery may cause Node.End to be zero, or
a small positive displacement from zero due to recursive Node.End
computation (#66683).

This change further refines the bug.Reports for such problems,
and additionally repairs the values heuristically to avoid
downstream bug.Reports after toGobDiagnostics (#64547).

Updates golang/go#66683
Updates golang/go#64547

Change-Id: I7c795622ec6b63574978d2953c82036fcc4425af
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-04-05 22:26:53 +00:00
Robert Findley cb3eb43c5d internal/test/integration: parse flags earlier
In some code paths, it was possible to call testing.Short() before flags
had been parsed. Fix this by calling
flag.Parse() earlier.

See https://build.golang.org/log/7f2caf626b9d159437f3d406a1e992ec9ada2c90
for an example failure.

Change-Id: If12e3257503cc5491cd35f379a1f9ff776868e93
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576918
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-05 19:48:09 +00:00
Alan Donovan 4794229b8c gopls/internal/golang: RenderPkgDoc: add <title> element
...following pkg.go.dev.

Change-Id: Ibf55871a4f7b4f160c1f83de5e3bec07b287ad9f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576915
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-04-05 15:37:04 +00:00
Alan Donovan 2db5a34c05 gopls/internal/golang: RenderPkgDoc: navigational <select>
This CL adds a <select> element with an index of all
sections in the page, following the design of pkg.go.dev.

Change-Id: I41b6719e85d0ace7edb864c5b20ae1f5b8e39d1b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576596
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-05 14:38:06 +00:00
Alan Donovan 11c692eb24 gopls/internal/test/marker/testdata: skip hover size tests on 32-bit arm
Fixes golang/go#66686

Change-Id: I74388fa8788ff6893146e3ca0cdfccfd28275625
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576657
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-04-04 21:32:40 +00:00
Gopher Robot fc660e510f go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: Ibb4c78e3b460f607474ae0433392c85bc2e60511
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2024-04-04 20:44:12 +00:00
Alan Donovan 6590f47255 internal/gcimporter: renable tests of issue50259.go
Now that the compiler support for gotypesalias=1 is
fixed (by CL 574737), we can reenable these tests.

Updates golang/go#66550
Updates golang/go#65294

Change-Id: I70b187c561d2eeb3f7a4cc078107b7bcce5ced01
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576139
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-04-04 19:28:08 +00:00
Alan Donovan f1d5252456 gopls/internal/golang: Hover: show wasted % of struct space
This change causes Hover to reveal the percentage of a struct
type's size that is wasted due to suboptimal field ordering,
if >=20%.

+ test, release note

Fixes golang/go#66582

Change-Id: I618f68d8a277eb21c27a320c7a62cca09d8eef0a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
2024-04-04 16:56:32 +00:00
Alan Donovan 951bb4069c gopls/internal/test/integration/misc: fix flaky test
The random base64 strings in gopls URLs caused occasional
spurious matches for the substring t1. This change uses
a non-base64 letter to eliminate this source of
nondeterminism.

Change-Id: I1db1dca8d93cc299b13b591567fa72b2227ac436
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576140
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-04-04 13:59:32 +00:00
Alan Donovan c9b0c65fdb gopls/internal/analysis/fillreturns: skip test if gotypesalias=1
It changes (improves) the behavior of the test; we will reenable
it once the default has changed.

Updates golang/go#65294

Change-Id: I716da405a9f0c03c303c4c0be8b738dd7c5ebdcd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576137
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-03 23:06:45 +00:00
Robert Findley c623a2817b gopls/internal/cache: fix crash in snapshot.Analyze with patch versions
Fix the same crash as golang/go#66195, this time in Analyze: don't set
invalid Go versions on the types.Config.

The largest part of this change was writing a realistic test, since the
lack of a test for golang/go#66195 caused us to miss this additional
location. It was possible to create a test that worked, by using a flag
to select a go1.21 binary location.

For this test, it was required to move a couple additional integration
test preconditions into integration.Main (otherwise, the test would be
skipped due to the modified environment).

Fixes golang/go#66636

Change-Id: I24385474d4a6ebf6b7e9ae8f20948564bad3f55e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576135
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-04-03 19:36:59 +00:00
Robert Findley f345449c09 gopls/internal/server: filter diagnostics to "best" views
Filter diagnostics only to the "best" view for a file. This reduces the
likelihood that we show spurious import diagnostics due to module graph
pruning, as reported by golang/go#66425.

Absent a reproducer this is hard to test, yet the change makes intuitive
sense (arguably): it is confusing if diagnostics are inconsistent with
other operations like jump-to-definition that find the "best" view.

Fixes golang/go#66425

Change-Id: Iadb1a01518a30cc3dad2d412b1ded612ab35d6cc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/574718
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-03 18:28:02 +00:00
Robert Findley 42d590c9cf gopls/internal/test/integration: add a WriteGoSum run option
Working with go.sum files in integration tests was cumbersome, involving
temporarily modifying the test to call env.DumpGoSum(...), then copying
its output into the static go.sum file.

For some tests, we may actually want to check in a fixed go.sum file,
but the majority of the tests just want to avoid go.sum errors. To
support this use case, add a new RunOption that writes the go.sum file
before starting the test. Use this option in a test to illustrate its
usage.

Also, update DumpGoSum to use the faster "./..." pattern to create the
go.sum output. "..." matches all modules, but we only care about the
main module.

Change-Id: I32cca005e10411033422cf8fee64cbd56e83f64c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575700
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-04-03 15:32:40 +00:00
Alan Donovan 53d35a51d3 gopls/internal/golang: RenderPackageDoc: fix doc links
Previously, a variety of links generated by the go/doc/comment
package were not valid. This CL configures the parser and printer
hooks to query the cache.Package representation, and now
generates valid crosslinks for all references.

Tested interactively on a wide variety of cross links.

Change-Id: Iaf1fffe52ea96e3be5df78227cf8395006caa59a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575377
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-04-03 14:07:30 +00:00
Alan Donovan 222cddee50 internal/analysisinternal: ZeroValue: support materialized aliases
My previous audit of this file contained a mistake in the order
in which constructors were tested; it was revealed by testing
with gotypesalias=1.

Updates golang/go#65294

Change-Id: I80f6f0bb24bceb2c69b9919e9c482b780c0d546a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575699
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-04-02 20:54:20 +00:00
Alan Donovan 0a4fc723d7 internal/gcimporter: support materialized aliases
This CL adds support for preserving materialized aliases
while types transit export data (indexed or unified).

(This CL depends on CL 574737 to the compiler and
go/types.)

Updates golang/go#65294
Updates golang/go#64581

Change-Id: I1a0a08357e4f6a480ba6250fbea327922e455873
Reviewed-on: https://go-review.googlesource.com/c/tools/+/574717
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-04-02 20:54:11 +00:00
Alan Donovan 85b65275a6 gopls/internal/test: temporarily disable staticcheck with gotypesalias=1
staticcheck will need work to accommodate gotypesalias=1.
In the meantime we disable this test in that mode; we plan
to reenable it before the next gopls release.

Updates golang/go#65294

Change-Id: I857edb758f83f180a4d92b7100e99c3401b1d957
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575698
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-02 20:54:01 +00:00
Alan Donovan 118b98be87 gopls/internal/golang: RenderPackageDoc: emit anchors for var/const
This CL causes the package rendering to emit an <a id=...> anchor
for each name defined by a var or const declaration.

Also, choose the initial fragment id (e.g. "#Buffer.Len") based
on the selection.

+ Test that anchors are emitted.

Change-Id: Idb4838a6d2741a26cd9dbb5ad31a76d6f811ff26
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575697
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-04-02 20:45:46 +00:00
Alan Donovan 1e68fee9c2 gopls/internal/server: "view package doc" of package under test
When "View package documentation" is invoked in a _test.go file,
this change ensures that the documentation for the package under
test is displayed, instead of a 404 Not Found.

Change-Id: I9c9f2205d6ec72cbe5acea1480acdbf2bd3b8b53
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-04-02 20:23:42 +00:00
Alan Donovan b303e13db8 gopls/internal/golang: view pkg doc: display when "disconnected"
This CL causes the "View package doc" pages to display a
banner when the gopls server dies, at which point the page
is no longer operative. (A new server will have a different
port.)

Change-Id: Icde10a7b4c25a28177d043c573dfdab4ce7c7964
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575536
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-02 20:23:35 +00:00
Tim King 41a9213ce5 go/packages: report type errors unconditionally
Ensure that when types.Checker.Files returns an error some
error is always reported and the package is illTyped.

Adds an additional hint to recompile the tool when types returns
an error "package requires newer Go version 1.22" or similar.

Updates golang/go#65608
Updates golang/go#66525

Change-Id: I131ee3e668815f88d16a18c6e92f002220284a03
Reviewed-on: https://go-review.googlesource.com/c/tools/+/574255
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-04-02 19:54:57 +00:00
Alan Donovan 7204363f23 gopls/doc/release/v0.16.0.md: augment notes for "view pkg doc"
Change-Id: Ieaef6c74b7fe1f7d736c1fb23c13c7569193ff3a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575376
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-01 14:40:43 +00:00
Alan Donovan 904c6baa6e gopls/internal/settings: enable "unusedwrite" analyzer
This analyzer shows a very high rate of true positives,
indicating that code is (at best) unnecessarily complex
and confusing but, often, not working as intended.

+ release note

Fixes golang/go#44461

Change-Id: I1c86e7305a8d512d7e4d1bbec3b2b44ce3a9c9ab
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575061
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-29 17:16:18 +00:00
Alan Donovan 96639992ee gopls/internal/golang: hover: show size/offset info
This change causes Hover to report size information for
types and struct fields when hovering over
the declaring identifier, plus offset information for
struct fields.

Some tests needed tweaks to make them CPU-independent,
or to disable them on 32-bit machines.

Also, add the first release notes using the new
git+gerrit workflow (and backfill a missing item for
"View package documentation").

Change-Id: Ibe8ac5937912c3802f3ad79e3d9f92ba24eb51de
Reviewed-on: https://go-review.googlesource.com/c/tools/+/573076
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-29 16:14:30 +00:00
Alan Donovan 509ed1c81d gopls/internal/golang: work around bug in go/doc
The associated bug was a crash in package doc rendering due to
invalid ASTs resulting from mutation caused by doc.New, even
in PreserveAST mode. (This bug has been latent since 2018.)
The mutation occurs when filtering out unexported symbols.

This change is a workaround: we enable AllDecls mode to
suppress filtering, and perform the filtering ourselves.

Also, add a regression test for the panic, and check
the new filtering behavior. This required some test
refactoring.

Fixes golang/go#66449
Updates golang/go#66453

Change-Id: I434c97e08930728d4894b90c1c7e010e7a922209
Reviewed-on: https://go-review.googlesource.com/c/tools/+/573575
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-03-29 15:08:21 +00:00
Zvonimir Pavlinovic 9551398269 go/callgraph: keep instantiations in DeleteSyntheticNodes
DeleteSyntheticNodes currently removes instantiations of generics from
the call graph. This function is intended to remove synthetic functions
that don't have a counterpart in the source code. Instantiations of
generics do not fit that bill. This also caused problems in govulncheck
where a function call to instantiation was missing from a call stack.

The fix is to keep instantiations and improved the documentation of
DeleteSyntheticNodes.

Change-Id: I32392b7495a8c1a5f6b26f795d46c8f184983e67
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575095
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Auto-Submit: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-28 22:49:04 +00:00
Alan Donovan 11b4b5e922 go/analysis/passes/nilness: add longer example to doc
Fixes Google Issue 331478795

Change-Id: I0258bdd6a50000effc66c4e1fe03f99e2720c0cc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/575056
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-28 20:16:23 +00:00
Peter Weinberger 9ed98faaba gopls/internal/test: option to suppress LSP logs on failure
Adds a RunOption NoLogsOnFailure() to suppress the printing of
the voluminous LSP logs when there is a test failure. While debugging
tests these logs can be a noisy distraction.

Change-Id: I41379fdcef8ba00f8b8a49ec89d8795274797888
Reviewed-on: https://go-review.googlesource.com/c/tools/+/574035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-26 17:46:31 +00:00
Lasse Folger 867c912ea6 inline: make it possible to gob encode/decode inlineMeFacts
Before this change gob encoding of these facts was failing with:

  `gob: type analyzer.inlineMeFact has no exported fields`

gob encoding is required for all facts as analyzer drivers use it to
share facts between the analysis of different packages as stated in
the docs:

  A Fact type must be a pointer. Facts are encoded and decoded using
  encoding/gob. A Fact may implement the GobEncoder/GobDecoder
  interfaces to customize its encoding. Fact encoding should not fail.

Change-Id: Ifb0eb57b0f582ec228a21a0d17e3bbd33c560d3d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/574435
Auto-Submit: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-26 14:22:20 +00:00
Alan Donovan db5d12bad8 go/types/internal/play: display method receiver type
Change-Id: Ib42e91d90ecd6e3bda69dbfa6ae2489fd2a0185c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572476
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
2024-03-25 21:49:14 +00:00
Alan Donovan 2c8dd3ec05 gopls: add explicit Unalias operations
This CL does for the gopls module what CL 565035 did
for the x/tools module.

In particular, we don't yet address desired behavior
changes for materialized aliases, nor generic aliases.

Change-Id: Iace78c1f8466afe8a6a24e3da3d6f431bf5ebc3e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/565756
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
2024-03-25 21:28:01 +00:00
Alan Donovan 814f676cf4 internal/gcimporter: add tool to inspect export data
This CL adds an unexported command for inspecting "unified" export
data produced by the compiler, and checking that it can be
roundtripped through "indexed" format as used by gopls.

Change-Id: Idc8eea5c8d7287d7f10af7bd15c7a52e6987a4bf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572795
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-25 20:14:41 +00:00
Alan Donovan 4fe2c29e13 refactor/rename: fix renaming of aliases
This change gets the renaming of aliases right when
they are materialized by GODEBUG=gotypesaliases=1.
(Obviously there's no way to get it right without
that feature.) And it adds a (conditional) test.

Updates golang/go#65294

Change-Id: Ie242e3a0a9d012218067bdc61a901f6618fecbb5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567842
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-25 20:14:39 +00:00
Alan Donovan 71acab9a7f internal/typesparams: add Deref
This change defines Deref(T), which returns the type of
the variable pointed to by T if its core type is a pointer,
or T otherwise, and removes all the various other flavors
of 'deref' helper that exist across the repo.

Also fix and test a generics bug in fillstruct.

Updates golang/go#65294

Change-Id: I14f6f35b58eefbad316391745745d662b061c013
Reviewed-on: https://go-review.googlesource.com/c/tools/+/565456
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-25 20:14:32 +00:00
Alan Donovan 63b3b5af27 internal/imports: fix two "nil pointer in interface" bugs
CL 559635 changed newModuleResolver so that it can return
(nil, err). That means it is no longer safe to unconditionally
convert the first result to a Resolver interface, but we
forgot to check in two places, causing a crash that was
reported by telemetry.

This change adds the two checks.

Fixes golang/go#66490

Change-Id: I3f2b84ed792b1eea179fc0d4d5ee9843281506fc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/574136
Reviewed-by: Peter Weinberger <pjw@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-25 17:46:54 +00:00
Tim King 3f9badb7e4 go/ssa: types.Unalias() cleanup.
Removes a few instances of unneeded Unalias calls, and
adds additional documentation about aliases.

Change-Id: I02045ef74d6d9b80189caf6a9831bded2bae5ad4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/568176
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-03-21 20:17:18 +00:00
Alan Donovan e5cf370df9 internal/typeparams: factor 2 copies of isParameterized
The typeparams.Free.Has(T) method reports whether type T
has free type parameters. It factors two copies of this
algorithm, themselves copied from go/types.

Change-Id: I285e26ba82b28ca0a3ddbd956fa75e342a0dc22d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/573135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
2024-03-21 18:24:44 +00:00
vitalmotif e0a95673cd all: fix some comments
Change-Id: Id4d3bcdcb663dccaf149ccadae1d0513c868a049
GitHub-Last-Rev: 4534649b01
GitHub-Pull-Request: golang/tools#486
Reviewed-on: https://go-review.googlesource.com/c/tools/+/573015
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tim King <taking@google.com>
2024-03-20 18:23:00 +00:00
Tim King c3544e2e53 go/analysis/passes/httpresponse: fix ReceiverNamed usage
Fixes a bug where ReceiverNamed returns a nil *types.Named if the type is
not a Named type.

Updates related documentation in httpmux.

Fixes golang/go#66259

Change-Id: I512feeb11473f2278edf4d9ef3312319d9dd1edf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/571057
Run-TryBot: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-20 16:54:27 +00:00
Hana (Hyang-Ah) Kim d0f7dcef44 gopls: update x/vuln to 1.0.4
x/vuln/cmd/govulncheck -json output format has changed to include
module level vulnerabilities. We knew this change would eventually
come and had handling in gopls/internal/mod/diagnostics.go
'foundVuln'. But we didn't update TestRunVulncheckWarning &
TestRunVulncheckInfo to get prepared. This is a test-only bug.

Fixes golang/go#65942

Change-Id: Ib7545279d07caf708c4f5392b51df273256432e6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567155
Reviewed-by: Suzy Mueller <suzmue@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-19 20:46:25 +00:00
Alan Donovan dd5264629a go/ssa: create fewer goroutines
This CL limits the number of goroutines created by Program.Build
to the number of P's, since building is entirely CPU bound.
Creating more than this number of goroutines just increases
churn, and potentially increases cache and allocator contention,
and increases peak memory usage and GC.

The effect on TestStdlib's "build SSA" timing metric seems
to be a reduction of around 2-3%, but it's fairly noisy.

Change-Id: Ie85e93b99c27ece245be05892818d52ae3b7fbc1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/572796
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
2024-03-19 19:46:15 +00:00