We wrap the last argument f(x...) in an explicit Ellipsis
to record that it was a variadic call, and add the "..."
back with corresponding logic when creating the edits.
Fixesgolang/go#70519
Change-Id: I1fdfa5f3ccb000c9622f856ed7703b31d7911620
Reviewed-on: https://go-review.googlesource.com/c/tools/+/631335
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>
packages.Load needs os.Pipe.
Fixesgolang/go#70502
Change-Id: I4fd5c0a0a4e2d76fdda24d474e9f0465462d649a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/630677
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
As we've seen many times, it is currently (unfortunately) possible that
go/ast nodes exceed the bounds of the parsed file. Handle this
possibility correctly while building the xrefs index.
Updates golang/go#66683Fixesgolang/go#70446
Change-Id: If6364876eb7b8ed8ca11a058417aa028d6b55b41
Reviewed-on: https://go-review.googlesource.com/c/tools/+/630675
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>
- This commit updates addTest and extractToFile to preserve
copyright and build constraint comments when creating new files.
- The change introduces utility functions to extract these comments
from an ast.File.
For golang/vscode-go#1594
Change-Id: I2b2f70d6d4de662c8357bca8558c094496c8b2e9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/629756
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Hongxiang Jiang <hxjiang@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Address a long-standing TODO in the marker tests by adding a new value
marker @defloc, which binds a name to the result of a definition
request.
Also
- more documentation improvements
- add support for formatting positions outside of the test archive
- refactor location formatting, to better handle external locations
Change-Id: I33e0d0e1a5d6d58cd83c62b8ad9b50e147077e2e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/630555
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Update our marker test documentation to discuss the recently added
support for named parameters. Also, make a few other superficial doc
improvements (notably, adding missing documentation for
-{min,max}_go_command).
Change-Id: Ib210443fc4afbb1420345a17ec5b1eed75687c04
Reviewed-on: https://go-review.googlesource.com/c/tools/+/630138
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
The {single,multi}checker packages provide the main function
for a complete application, as a black box. Many users want
the ability to customize the analyzer behavior with additional
logic, as described in the attached issues.
This change creates a new package, go/analysis/checker, that
exposes an Analyze pure function---one that avoids global flags,
os.Exit, logging, profiling, and other side effects---that
runs a set of analyzers on a set of packages loaded (by the
client) using go/packages, and presents the graph of results
in a form that allows postprocessing.
package checker
func Analyze([]*analysis.Analyzer, []*packages.Package, *Options) (*Graph, error)
type Graph struct {
Roots []*Action
}
type Action struct { ... } // information about each step
func (*Graph) WriteJSONDiagnostics(io.Writer) error
func (*Graph) WriteTextDiagnostics(io.Writer, contextLines int) error
func (*Graph) All() iter.Seq[*Action] // (was Visit in the proposal)
See the example_test.go file for typical API usage.
API feedback welcome.
This change should have no effect on the behavior of
existing programs. Logic changes have been kept to a
minimum, so the large diffs are mostly code motion.
Auxiliary functions for printing, flags, fixes,
and so on has been kept to a minimum so that we
can make progress on this change.
They will be dealt with in follow-up changes.
Detailed list of changes to ease review:
analysistest:
- Run: we report Load errors to t.Log up front
(unless RunDespiteErrors); this was previously in loadPackages.
- Run: the Validate call is now done by checker.Analyze.
- internal/checker.TestAnalyzer has melted away
- the logic to construct the "legacy" Result slice is new.
- Result: this type used to be an alias for
internal/checker.checker.TestAnalyzerResult (regrettably
exposing more than intended); now it is a plain public struct.
- check: the logic to check fact expectations is new.
- The buildtag and directive analyzers both used a similar
hack w.r.t. IgnoredFiles; this hack is now in analysistest.
Better ideas welcome.
checker:
- checker.go is mostly moved from internal/checker/checker.go.
- print.go is mostly split from old printDiagnostics in
internal/checker/checker.go.
- Action.execOnce: the pass.Result/Err logic was simplified
using an immediately-applied lambda.
- inheritFacts: the comments on package-fact handling are new.
- Graph.Visit is "born deprecated".
Clients using go1.23 should use Graph.All (iter.Seq).
- Example: this is new code.
internal/checker:
- applyFixes: now accepts only the actions to apply, without
calling visitAll over the action graph.
The previous code was wrong, a latent bug.
Some files outside go/analysis were updated, not out of
necessity (it's not a breaking change) but to modernize
them (e.g. avoiding analysistest.Result.Pass).
Updates golang/go#61324 (new API proposal)
Fixesgolang/go#53215 (feature proposal)
Fixesgolang/go#31897Fixesgolang/go#50265Fixesgolang/go#53336Fixesgolang/go#66745
Updates golang/go#30231
Updates golang/go#30219
Updates golang/go#31007
Updates golang/go#66745
Change-Id: I745d319a587dca506564a4624b52a7f1eb5f4751
Reviewed-on: https://go-review.googlesource.com/c/tools/+/411907
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Use printer.CommentedNode to preserve comments in function and method
extraction.
Fixesgolang/go#50851
Change-Id: I7d8aa2683c980e613592f64646f8077952ea61be
Reviewed-on: https://go-review.googlesource.com/c/tools/+/629376
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
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.
Fixesgolang/go#63717Fixesgolang/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>
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.
Fixesgolang/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>
go/types now (correctly) produces a diagnostic for this code.
For golang/go#59944
Change-Id: I858acbf4199171f6e6c98eb1286d037e89462018
Reviewed-on: https://go-review.googlesource.com/c/tools/+/630117
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
The hoverJSON.LinkPath field was incorrectly documented, and
the gopls links formed from it were invalid when a module
version was present. This CL fixes the URL logic.
The existing test covered the behavior, but the assertion
concealed a mistake.
Fixesgolang/go#70453
Change-Id: If9a7d3e65dabff50c9f528d82df9de67a71c41d1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/630077
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
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>
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>
We are overwhelmed by contributions. This change updates
our expectations about CLs in an attempt to move more of
the discussion of the design and implementation plan into
the issue tracker. It also clarifies that we expect
review comments to be addressed.
Change-Id: Ibccd268d4f7d9b6daf256ac7c60b7fbd821e2a69
Reviewed-on: https://go-review.googlesource.com/c/tools/+/629755
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>
This change removes the undeclaredname analyzer,
and instead computes it directly from the
protocol.QuickFix code action producer,
follow the same structure in CL 617035.
Also:
- include return types for undeclared function
- add basic return type test in missingfunction.txt,
the major functionality should be the same as
fromcall_returns.txt
- add more cases in TypesFromContext, and
corresponding tests.
Fixesgolang/go#47558
Change-Id: Ic79cf2f07a3baee60631bf0b8f5c2b9f4f4393d0
GitHub-Last-Rev: 33b78d7997
GitHub-Pull-Request: golang/tools#538
Reviewed-on: https://go-review.googlesource.com/c/tools/+/623156
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
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>
Address a TODO to consolidate the three codeaction marks into one, by
using named arguments to provide an optional end location and one of
edit, result, or err.
Along the way, I accidentally nuked my golden files after doing quite a
lot of manual editing of the test cases. To restore them, implement a
heuristic I've wanted for a while: when running with -update, add new
golden files immediately after the first reference to them among test
files. This is the convention we've been using, but previously we'd have
to position the golden files manually.
Change-Id: Ie78f759045aa0c07817d4eb21672be63e51c5067
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627136
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
CL 628435 moved and disabled these tests. This CL re-enables them for
the time when CL 627777 lands.
Change-Id: I16cb8d4c23db35fadaac94054183f26bba2449e2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/629235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
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>
Right now the copylock tests check for details on these types that are
implementation details and/or have some other problem (a less useful
error message, or a false negative altogether).
CL 627777 modifies the sync package to attach explicit anonymous noCopy
fields on each of these types. This change updates the tests to match
that, which also helps with and/or resolves a couple issues with
copylock captured in the test suite.
Note: this change also temporarily disables a couple of the problematic
tests. In the next CL we'll re-enable them, once CL 627777 lands.
Change-Id: I100c71ea05b4f08595e37d0c8e81f9543abe7d74
Reviewed-on: https://go-review.googlesource.com/c/tools/+/628435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Tim King <taking@google.com>
Gopls previously reported a bug when encountering a dynamic method
reference. Instead, we should just skip this reference when inlining all
calls.
Fixesgolang/go#69896
Change-Id: Id6971e2a3eb79a94e76eecbfcefc44bec9040b8e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/628376
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>
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>
The most likely cause of an inconsistent view of a dependency is a
mismatching test variant. Refine the bug report to identify this case.
For golang/go#63822
Change-Id: I1334501be1ea55a43a49557ad2cb1d03178268cc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/628495
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Follow up to https://go.dev/cl/626537
Change-Id: Ib8dee860c5ca65ea3dab8ef68564f9fe46c74832
Reviewed-on: https://go-review.googlesource.com/c/tools/+/628535
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>
It is not a bug for go/packages to return no packages for standalone
files, if they use cgo and cgo is disabled. There may also be other
scenarios where standalone packages are not produced. In any case,
downgrade the bug report to a normal error.
Also, fix the failing test to require cgo.
Fixesgolang/go#70363Fixesgolang/go#70362
Change-Id: I2b8a8b3947e4d7ff6482279540638e13dc9de2b4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/628017
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
It turns out that in the jsonrcp2 package, call responses are
asynchronous to other notifications. Therefore, we must synchronize
tests using progress notifications.
Introduce a DelayMessages test option to reproduce these types of races.
(It worked for reproducing golang/go#70342.)
Fixesgolang/go#70342
Change-Id: I4cfcd7675335694a47eaf1a2547be0301fc244c9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627696
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Although the LSP specifies that diagnostic data should be transmitted
unmodified to codeAction requests, we can't control whether clients
abide by this rule. Therefore, a failure to extract fixes should be
treated as a user-facing error, not a bug.
Fixesgolang/go#68819
Change-Id: I57e629cf381ee1112d98d22e728449995679b05f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/628237
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
In the partial rollback CL 627556, I failed to remove the call to
jsonrpc2.Async in RunGoVulncheck, which is now (once again) async to
request handling. This introduces a race, leading to a panic if the
handler responds before the call to Async.
Fixesgolang/go#70355
Change-Id: I8b33599a3f62b82dc6acf9d9b3616194c0372b9c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/628236
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
As suggested on CL 626715, using a named bool clarifies call sites.
Change-Id: Ie36f406dcca382c7edc277895826265ae9040ee2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/628235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
To simplify many callsites where we called filepath.Dir on uri.Path(),
introduce the DocumentURI.DirPath helper method. This clarified many
call sites, and could make it easier to optimize URI manipulation in the
future.
Change-Id: Icc64155b6bba631f9df5da5a05e3126c7cb7954b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/626716
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
The Snapshot.GoCommandInvocation API is a source of confusion, because
it passes in a gocommand.Invocation, performs arbitrary mutation, and
then passes it back to the caller (which may perform mutation on top).
Aside from the readability problems of this indirectness, this API can
lead to real bugs, for example if one of the mutations is incompatible
with another.
Furthermore, the fact that the GoCommandInvocation is the golden source
of information about the Go command environment leads to awkwardness and
redundant work. For example, to get the packages.Config we called
Snapshot.GoCommandInvocation, just to read env, working dir, and build
flags (and the now irrelevant ModFile and ModFlag). But
GoCommandInvocation wrote overlays, so we'd end up writing overlays
twice: once within the gopls layer, and then again in the go/packages go
list driver.
Simplify as follows:
- Pass in dir, verb, args, and env to GoCommandInvocation, to avoid
passing around and mutating an Invocation.
- Extract the View.Env, which is a useful concept, and apply invocation
env on top. Surveying existing use cases that this was correct, as all
call sites expected their env not to be overwritten.
- Move Snapshot.config to load.go, where it belongs, and simplify not to
depend on GoCommandInvocation.
Also add an additional test case for BenchmarkReload.
Change-Id: I8ae7a13a033360e0e7b0b24ff718b5a22123e99c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/626715
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>
This analyzer detects failure to check the result of a call to
yield (which can cause a range loop to run beyond the sequence,
leading to a panic).
It is not always a mistake to ignore the
result of a call to yield; it depends on whether control can
reach another call to yield without checking that the first
call returned true. Consequently, this analyzer uses SSA
for control flow analysis.
We plan to add this analyzer to gopls before we promote it to vet.
+ test, relnote
Fixesgolang/go#65795
Change-Id: I75fa272e2f546be0c2acb10a1978c82bc19db5bd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609617
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Previously, we were using the first CompiledGoFiles to disambiguate the
ID of command-line-arguments packages, but in the presence of cgo
preprocessing there can actually be multiple CompiledGoFiles, leading
to the bug report of golang/go#64557. Fix this by using GoFiles instead.
Fixesgolang/go#64557
Change-Id: I3eff976d07da32db1f26ced69228af41a388d9a1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627776
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>
Use field names or type names for result variables names, if available.
Otherwise, use the same conventions for var naming as completion. If all
else fails, use 'result' rather than 'returnValue'.
For golang/go#66289
Change-Id: Ife1d5435f00d2c4930fad48e7373e987668139ef
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627775
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
- Read and determine whether the first input parameter of function
or constructor is a context.Context through package name and name
comparison.
- Call the function or constructor with context.Background() but
honor is there is any renaming in foo.go or foo_test.go.
- Fix the issue where the constructor param is added to function
or method call.
For golang/vscode-go#1594
Change-Id: Ic1d145e65bc4b7cb34f637bab8ebdeccd36a33f9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627355
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Hongxiang Jiang <hxjiang@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
- 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>
To be consistent with other tests, and fix the breakage on js/wasm,
skip TestDirAndForTest on incompatible platforms.
Fixesgolang/go#70286
Change-Id: I6195005e39103bbff4b5bb9ff99a63247eb0e9c6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627996
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
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>
Don't unconditionally call window/showDocument; check the client
capability. In the case of opening a browser window, use showMessage if
showDocument is unsupported.
Also somewhat clean up the way that we check for shown documents.
Fixesgolang/go#68904
Change-Id: I29b281b615185f2bbda2f00e7c17575678177cd0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/626616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
- Gopls will honor any renaming of package "testing" if any.
- Gopls will collect all the package that have not been imported
in foo_test.go and modify the foo_test.go imports.
For golang/vscode-go#1594
Change-Id: Id6b87b6417a26f8e925582317e91fb4ebff4a0e7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/620697
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
As described in golang/vscode-go#3572 this CL reverts the behavior of
the gopls.run_govulncheck command to be asynchronous. Instead, we
introduce a new gopls.vulncheck command to run synchronously. We also
introduce a new "vulncheck" codelens setting to control the availability
of codelenses for this new command.
For expedience, the command handler is simply copied rather than
refactored, and minimal tests are added/modified to test the new
command. Hopefully we can migrate everything to the new command soon,
and delete the old command.
For golang/vscode-go#3572
Change-Id: Ib3cffd5fd038813680087fa1916127663f377581
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627556
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Avoid a crash where types.Info.TyepOf(n) is assumed to be a non-nil
Struct for a StructType expr: this is not guaranteed in the presence of
type errors.
Unfortunately, I was not able to reproduce the crash after ~20m of
trying. Nevertheless, the existing code is making invalid assumptions.
Fixesgolang/go#69150
Change-Id: I48abe9c134722db5c43f1c7c382b59e7632e367f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Change-Id: Ia82717808152cc4f88c94ec58fe82f51dc95952d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/625716
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This CL causes the interpreter to assign all phi nodes of a block
in parallel, as required by SSA semantics. Previously it would
execute them in order like real instructions, so that earlier
phis might clobber the environment values required as inputs
to later phis.
The phi handling is moved out of the ordinary visitInstr code
and into the block-entry logic, since all phis need to be
handled en bloc.
Also, a test, based on the user-reported problem in the attached
issue.
Fixesgolang/go#69929
Change-Id: I12a61286b2151e2e72b642ca336e4ae31b7fa614
Reviewed-on: https://go-review.googlesource.com/c/tools/+/621595
Reviewed-by: Matthew Dempsky <matthew@golang.org>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
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>
This CL uses the new output-capturing mechanism (via a pipe)
exclusively, eliminating two old mechanisms:
1) the CapturedOutput global var that was written by
print and println; now those two functions just
write to stderr, which is more faithful (than stdout).
2) TestRangeFunc called the interpreter in a subprocess
so that it could capture output (via pipes), but
that is no longer necessary; 'run' returns the captured
output.
Also:
- t.Log the duration unconditionally; remove "if false" cruft.
- eliminate the unnecessary cwd arguments to filepath.Join.
Change-Id: Ib23f895fafecab059ecda60f73fb7082388f0240
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622416
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>
This CL splits the various fallible checks that may have
been responsible for the crash report in golang/go#69362 onto
separate lines so that we can confirm whether a nil
map entry is indeed the cause. (I am almost certain that
it is, but I still can't explain it.)
Updates golang/go#69362
Change-Id: I0469e285bda65c21e80a348af04ea0e69f6a31c0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/627015
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>