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

3401 Коммитов

Автор SHA1 Сообщение Дата
Rob Findley 8c3ba8c103 internal/refactor: undo variadic elimination during substitution
When substituting an argument that has been synthetically packed into a
composite literal expression, into the varadic argument of a call, we
can undo the variadic elimination and unpack the arguments into the
call.

Fixes golang/go#63717
Fixes golang/go#69441

Change-Id: I8a48664b2e6486ca492e03e233b8600473e9d1a9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/629136
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 19:06:21 +00:00
Rob Findley 3b0b264579 internal/refactor: handle qualified names in inlined assignments
Rewrite our call site processing of imports, to simplify, and so that we
can re-use the import lookup logic in the assignStmts strategy for the
purpose of writing out types.

A large TODO is included for a hypothetical refactoring of the inlining
logic that could formalize these types of interactions between call site
analysis and inlining strategy.

Fixes golang/go#65217

Change-Id: Ifd99ea14430deba3a03cdfb936b6edee9e81d0bf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/629435
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 19:05:51 +00:00
Hongxiang Jiang e751756721 internal/analysisinternal: unify zero value function to typesinternal
Refactors the ZeroExpr and ZeroString functions to provide more
consistent and correct handling of zero values for input types.

- Refactor: Unify similar switch case statements in both functions with
exception of types.Tuple. ZeroExpr panic due to the lack of a valid
ast.Expr representation.
- Fixing an issue where ZeroExpr returned nil for types.Array instead of
a composite literal.
- Adding support for type parameters in ZeroExpr, similar to ZeroString.
- Consolidating tests for both functions into TestZeroValue.

Change-Id: Ic77ae17ea091cf51bd4d4642186fe13093e0d461
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627604
Reviewed-by: 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>
Auto-Submit: Hongxiang Jiang <hxjiang@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-11-20 16:07:55 +00:00
Peter Weinberger a2874818ed internal/imports: test Source for go mod cache
This CL provides an implementation of the Source interface to
use an index to the go module cache to satisfy imports.

There is also a test.

Change-Id: Ic931cb132fcf7253add7fc7faadd89726ee65567
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-11-20 12:37:14 +00:00
Rob Findley 0c01408d03 internal/refactor/inline: avoid binding decl for name used by other args
When inlining, a removed argument does not contain the last use of a
name if that name is also used by another arg that is referenced by the
callee. Implementing this logic improved a test case for
golang/go#65217.

For golang/go#65217

Change-Id: I486306f4ed57d759d5ab65bb390db5e81332d3ef
Reviewed-on: https://go-review.googlesource.com/c/tools/+/629295
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-11-18 22:15:53 +00:00
Tim King 39cb6f0e85 internal/facts: use alias type parameters and arguments during imports
Derived from https://go.dev/cl/603935.

Change-Id: I409347a5bdf2218450d06f688b4c13fd302b2a16
Reviewed-on: https://go-review.googlesource.com/c/tools/+/619416
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Tim King <taking@google.com>
2024-11-18 18:50:39 +00:00
Daniel McCarney 52eb446eff internal/imports: adjust TestStdlibSelfImports pkg
This commit switches the test to use crypto/rc4 instead of crypto/ecdsa.

The crypto.ecdsa package will soon be imported into the FIPS module,
producing an unexpected import of crypto/internal/fips/ecdsa by the
pre-existing test.

Instead, use the rc4 stdlib package. This won't be under consideration
for FIPS.

Change-Id: I87bcaa04efe1138aa80bf7ce88f0df74469daf4d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/629115
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2024-11-18 16:05:08 +00:00
Hongxiang Jiang b4332e09d1 gopls/internal/golang, go/ssa: remove unnamed input parameter
- Unnamed/blank parameters are now assigned zero values, as
   they are not referenced within the function body.
- The `zeroString` function has been moved from `go/ssa` to
  `internal/typesinternal` for better organization.
- Honor the input parameter name from the function signature.
- Input parameters from both consutrctor and target functions
  are flattened into the test case struct. Potential field
  name duplication is handled by introducing prefixes.

For golang/vscode-go#1594

Change-Id: I8b56d8f3e0f0432d4f9fe269cc7ba86ea46decfc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/626537
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Hongxiang Jiang <hxjiang@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 19:09:26 +00:00
Rob Findley 47a5f7d131 gopls/internal/golang: fix bad slice append in function extraction
With multiple return statements, a slice append would overwrite the
return values of earlier returns. Fix by using slices.Concat.

For golang/go#66289

Change-Id: Ib23bcb9ff297aa1ce9511c7ae54e692b14facca7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627537
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-14 15:42:56 +00:00
Peter Weinberger 12610a1270 internal/modindex: better behavior in edge cases
Write an index even if there is nothing in the module cache.

Change-Id: Ia98f8825d9914a0d4bd2ee9ff1bccf8519b91f37
Reviewed-on: https://go-review.googlesource.com/c/tools/+/626735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-11-12 14:35:26 +00:00
Rob Findley 35d7f2837a go/packages: add Dir and ForTest fields to Package
Add a new Dir field, and export ForTest, per golang/go#38445. The
needInternalForTest mode bit is promoted to NeedForTest, but no mode bit
is added for Dir as it is logically related to NeedFiles.

A test is added for the new fields using a simpler txtar-based setup,
since I did not have time to page in the quite heavyweight packagestest
framework.

For golang/go#38445

Change-Id: I92026462f7ed7e237db1f4e50a3bbf2936802fbb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/626495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-11-08 18:44:44 +00:00
Rob Findley 9a89d3a985 internal/analysisinternal: avoid sub-token spans in TypeErrorEndPos
Avoid assigning end positions to type errors that are within the current
token (such as could happen in an import path). To test this, introduce
our first named argument in the marker tests: 'exact' for the @diag
marker.

Also, attempt to document the heuristic of TypeErrorEndPos.

Fixes golang/go#69505

Change-Id: If3cf82f241dd354d834a7dcbf24b7b3c59246911
Reviewed-on: https://go-review.googlesource.com/c/tools/+/625916
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-11-07 22:10:20 +00:00
Alan Donovan 1115af6fe6 internal/expect: support named arguments f(a, b, c=d, e="f")
+ test

Change-Id: I6c44e32d34bcdf1ca68e8989e99595f691c88329
Reviewed-on: https://go-review.googlesource.com/c/tools/+/626016
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-11-06 21:25:26 +00:00
Alan Donovan efcd2bdbd9 internal/packagestest: fork go/packages/packagestest
Also, update all imports outside of that package.

Updates golang/go#70229

Change-Id: I8b08f892ec86d560c0406319c2954eb9912d78ad
Reviewed-on: https://go-review.googlesource.com/c/tools/+/625920
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-11-06 21:04:09 +00:00
Alan Donovan ca2b41b3fd x/tools: use internal/expect instead of go/expect
The only remaining uses of go/expect are from packagestest.

Updates golang/go#70229

Change-Id: I5a8c835b761381747fbd3f936d261ed773b536e3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/625919
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-11-06 19:53:11 +00:00
Alan Donovan b22f1adb94 internal/expect: fork go/expect
Almost no-one outside x/tools uses it, so we'd like to evolve
it for our needs, and tag and delete the public package.

Updates golang/go#70229

Change-Id: I77c7923881efdf772a1ad53134483ad0078c941d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/625918
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-11-06 19:53:09 +00:00
Rob Findley cceaf96b25 internal/imports: carve out a Source interface for index integration
In preparation for integrating the newly implemented shared module cache
index, carve out a minimal imports.Source interface to be used by
FixImports. For now, this interface has a single implementation,
wrapping the legacy ProcessEnv abstraction, but in the future we can
replace it with an implementation that synthesizes the module cache
index with gopls' own view of the workspace.

This CL intentionally avoids any refactoring aside from extracting the
ProcessEnv-specific logic into a ProcessEnvSource.

For golang/go#36077

Change-Id: I189a908c917aba68868b08845880b1f0aa731180
Reviewed-on: https://go-review.googlesource.com/c/tools/+/623296
Reviewed-by: Peter Weinberger <pjw@google.com>
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-11-04 18:14:50 +00:00
Rob Findley 109c5fcce2 gopls/internal/test: fix path to local go in integration tests
As described in golang/go#69630, our 1.21 and 1.22 builders were not
actually testing gopls' integration with the Go command, because go test
modifies PATH and GOROOT when performing a toolchain switch.

"Fix" this by searching PATH for a local (=non-toolchain) go command,
and then mutating PATH and unsetting GOROOT to use this go command. This
is very much a hack, as noted in the relevant commentary, but allows us
to have much needed test coverage on the builders. In golang/go#69321,
we hope to design a better solution to this problem.

Many tests are updated to make their go version requirements accurate.

Fixes golang/go#69630

Change-Id: I431107b97845e1e99799c2c22f33b04f85ce6dd9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/623175
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-11-04 16:34:04 +00:00
Alan Donovan 99e8fee2bf x/tools: fset.File(file.Pos()) -> fset.File(file.FileStart)
This CL fixes a bug (#70149) in gopls/internal/golang/pkgdoc.go
in which a call to fset.File(file.Pos()) would return nil
because when file points to an empty ast.File, Pos() returns NoPos.

Instead, we should use file.FileStart, which is (in principle)
always valid even for an empty file. However, there is a separate
bug in go1.23 (#70162) that means FileStart is invalid whenever
Pos() is. So, this fix only works with go1.24, and there's no
real workaround short of the additional logic this CL adds to
parsego.Parse, which at least covers all of gopls.

Also, we audit all of x/tools for similar faulty uses of Pos()
and replace them with FileStart. In future, we should use File.Pos
only for its specific meaning related to the package decl.

Fixes golang/go#70149
Updates golang/go#70162

Change-Id: Ic8cedfe912e44a0b4eb6e5e6874a6266d4be9076
Reviewed-on: https://go-review.googlesource.com/c/tools/+/624437
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-11-04 15:48:36 +00:00
Ian Lance Taylor ce03cd6b1b internal/modindex: parse changed time in local time zone
The os package will return ModTime values in the local time zone.
We have to parse the time stamp in the local time zone so that
comparisons are done correctly.

Fixes golang/go#69893
Fixes golang/go#69894

Change-Id: I93631cdc64dda8fdfcdf668e10e0ec939ef1461d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/624615
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
2024-11-04 05:53:31 +00:00
Rob Findley 45a28e1c11 all: fix x/tools tests that fail with a go1.23.1 go.work file
Delete or selectively skip tests that made either of the following
assumptions:
- The default GODEBUG is that of Go 1.22 (not true given a go.work
  file).
- GOROOT is a development version of Go (not true if GOROOT is prepared
  by cmd/distpack).

Fixes golang/go#70081
Fixes golang/go#70082

Change-Id: I47dfb225427f75e3be833eed3ba677ff454935f1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622896
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-28 22:46:16 +00:00
Rob Findley 91421d7314 gopls/internal/cache: share type checking with analysis
Consolidate the logic of type checking and analysis, for the following
benefits:

- Simplify by eliminating redundant logic to type check and import
  packages in the analysis driver.
- Reduce work by reusing type checked packages in analysis. By the time
  we run analysis on open packages, we likely have type checked the
  packages already, so the work to type check inside the analysis driver
  is very much redundant.
- Reduce work by reusing the package key from packageHandle (which we
  have gone to great pains to optimize).
- Reduce work (and file cache space) by avoiding the need to store
  export data alongside analysis facts.
- Leverage the precision of our reachability analysis by using a bloom
  filter of reachable packages to better filter facts.
- This indirectly fixes golang/go#64227 and golang/go#64236, since the
  crashing logic is deleted.

For golang/go#53275
Fixes golang/go#64227
Fixes golang/go#64236

Change-Id: I431b8da35b2dce7c63f56ec1a3727e0747b79740
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622038
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-28 18:30:04 +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
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 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
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
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
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 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
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
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
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
Tim King f8f3c13ff3 internal/aliases: add a function to conditionally enable aliases
Conditionally enable the gotypesalias GODEBUG setting based on the
gotoolchain used to compile the tool.

Change-Id: I1e698249f943c8f2cb95c3acbc45aedf64260667
Reviewed-on: https://go-review.googlesource.com/c/tools/+/617636
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-04 19:46:29 +00:00
Tim King 2848ab8d89 internal/gcimporter: clean up test expectations
Use (types.Object).String() to write expectations now that the
formatting for type parameterized aliases was fixed.

This resolves a TODO in TestIExportDataTypeParameterizedAliases.

Change-Id: I5b5d55cb7c190686c89dec59bdad30d83de595a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/616995
Auto-Submit: 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-09-30 20:31:21 +00:00
Tim King 6ded0c4495 internal/gcexporter: cleanup test skipping in TestImportTypeparamTests
Cleaning up the documentation for skipping tests in 1.22 when gotypesalias=1.

Change-Id: Iaf387ff83d2d771d3a0196d6ca26aa49516799dd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615699
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Tim King <taking@google.com>
2024-09-30 18:23:58 +00:00
Tim King 6c47868975 internal/gcimporter: run larger tests with and without aliases
Run larger and standard library tests both with and without the
gotypesaliases GODEBUG enabled. Skips two know failures on 1.22.

Fixes an incorrectly copied constant in an expectation.

Change-Id: I8054bf5609b7a0e6fb544bd906a00f2f02f75b31
Reviewed-on: https://go-review.googlesource.com/c/tools/+/616157
Reviewed-by: Alan Donovan <adonovan@google.com>
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-09-27 19:01:38 +00:00
Tim King e55961d46c internal/gcimporter: use types.NewInterfaceType
Use types.NewInterfaceType directly. This has been available since Go 1.11.

Change-Id: I3669ce485bc99a758530158db02a470d81ad7b85
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615697
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-09-26 21:58:18 +00:00
Tim King c59bc300b2 internal/gcimporter: vary the value of any in predeclared
Vary the types in predeclared() based on the runtime value of any
in types.Universe (either universeAnyNoAlias or universeAnyAlias).

Change-Id: Iacf43d21c7d078706ac20ded7ffdeadffbb4baf5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615683
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-09-26 21:56:35 +00:00
Tim King 4fc0d79003 internal/gcimporter: remove goexperiment.unified tags
goexperiment.unified was removed in 1.21.

Change-Id: I388d657da578f33616c45b8a18a2266443956757
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615995
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Tim King <taking@google.com>
2024-09-26 20:52:18 +00:00
Tim King 1c9ca8b8ba go/types/objectpath,internal/aliases: miscellaneous clean up of tests that set gotypesalias
* Fix default value test ("") for TestNewAlias.
* Updates references to 1.19 to 1.22.

Change-Id: I9c19621e820c90c265235afff863863d03f2d171
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615696
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-09-26 17:11:08 +00:00
Rob Findley 7bb384dcf8 gopls/internal/test/integration/bench: add an IWL test that opens files
The existing BenchmarkInitialWorkspaceLoad does not open files, which
means it measures only the speed of loading and verifying the workspace
state, with hot caches. It does not measure the memory or time consumed
when starting to actually work on a file.

Fix this by opening a file.

Also, add -profile.block to gopls and -gopls_blockprofile to gopls
benchmarks, for better diagnosis of contention.

Change-Id: I63ef7c9a26ca71ddd9b6895369921655eaa4f090
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614163
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-09-26 14:44:37 +00:00
Tim King 81a4242b11 internal/gcimporter: update TestIssueAliases expectation
Fixes golang/go#69627

Change-Id: I96460aa3c4b2863ae50fefd09a85e670d166b773
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615855
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-09-25 18:37:33 +00:00
Peter Weinberger 54110aa199 internal/modindex: package for indexing GOMODCACHE
This CL contains the first part of a package for maintaining an
on-disk index of the module cache. The index is stored as text.
Eventually it will consist of a header, followed by groups of lines,
one for each import path, and sorted by package name. The groups of lines
start with a header containing the package name, import path, name of the
directory, and semantic version,
followed (but not in this first CL) by lines, each of which contains
information about one exported symbol.

This CL only contains the code for computing and updating the information
about directories and import paths, and reading the index. It does not
compute anything about exported symbols, which will be in the next CL,
and hence it does not present an API for looking up information about
completion of selectors.

There is a test that among directories with the same import path it can
find the one with the largest semantic version.

Change-Id: I0883ea732cf34f6700f5495e6dfd594e8f286af9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612355
TryBot-Bypass: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-09-25 18:30:44 +00:00
Alan Donovan d911e4a884 gopls: disable ast.Object resolution wherever possible
And where not, document why.

(Locations were found by instrumenting parser.ParseFile
and running gopls' tests.)

Change-Id: Iab205b1f96b4fb4b22a5d056b40fbbb326dcd7a4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615436
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Bypass: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
2024-09-25 16:16:45 +00:00