CL 587555 suppressed some code actions if the request was triggered
automatically, but that was too invasive and suppressed useful code
actions like quick fixes and organize imports. Maybe some refactoring
code actions and source.* actions can be also useful enough to be
presented in the light bulb menu.
Partially revert CL 587555, by suppress only refactor.inline code
action if the user's intention is not refactoring
(e.g. cursor move around a function call). However, if the user
selected a code area (function name), that is likely an action for
refactoring, so continue to present refactor.inline in the light bulb
menu.
Fixesgolang/go#67823Fixesgolang/go#65167
Change-Id: I2d4a3d92199e501103596d0aed78ece34760149f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590935
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
CL 589975 accidentally removed an extensibility seam that was used
internally at Google. Strengthen the comment to make it more apparent
that this seam is necessary.
Change-Id: I7bb402a717968eec76cda514cddb4268c67b7329
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590816
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>
http://go.dev/cl/589975 incorrectly made fixImports a regular function
because the extension was not visible in the tools repository.
Google-internally, we do use this extension point.
Change-Id: I7ff41e49f852e0f72671141a7a2baa272ec5a6ce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591035
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
An apparent bad merge in CL 561235 caused the critical component--
clearing the resolver for a new scan--to be dropped. Fix this, so that
the imports state is actually refreshed asynchronously.
It is surprising that this was not reported, though I see perhaps two
related comments in survey results. Most likely adding a new import is
infrequent enough that users were simply confused, or learned to restart
gopls (alas).
Also, add more instrumentation that would help debug golang/go#67289.
For golang/go#67289
Change-Id: I50d70a470eb393caf9e0b41856997942372b216f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590377
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 CL causes the generator to treat the next/*.txt files
as if they comprise the next (e.g. go1.23.txt) manifest,
which doesn't exist until close to the release (specifically,
between the start of the freeze and the first release
candidate).
Change-Id: I84158032484d5aa4b1d2d57c11209a24e6924b5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/590355
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Pointed out by Dominik Honnef in CL 555075.
Change-Id: I2f178870838d10163af6267386a8ddb0f6111a98
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Tim King <taking@google.com>
For golang/go#54461
Change-Id: I2de5a10673345342e30e50cb39359c10e8eb7319
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589956
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>
Historically, FixImports did not have access to a context, and performed
its imports scan with context.Background. Since then, FixImports is
called by gopls with the CodeAction Context, yet cancelling this context
does not abort the scan. Fix this by using the correct context, and
checking context cancellation before parsing.
It's a little hard to see that context cancellation doesn't leave the
process environent in a broken state, but we can infer that this is OK
because other scans (such as that used by unimported completion) do
cancel their context.
Additionally, remove a 'fixImportsDefault' extensibility seam that is
apparently unused after six years.
For golang/go#67289
Change-Id: I32261b1bfb38af32880e981cd2423414069b32a3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589975
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>
The copylock analyzer is marked RunDespiteErrors. In ill-typed
code such as S{T} where S and T are both types, the compiler will
warn that T is not an expression; the copylocks analyzer should
not additionally report a diagnostic as if T had been an expression
of type T.
The fix feels rather ad hoc. In general, analyzers marked
RunDespiteErrors are unlikely to be able to anticipate the
myriad ways that trees can be ill-formed and avoid spurious
diagnostics.
Also, add a main.go file for copylock.
Fixesgolang/go#67787
Change-Id: I07afbed16a4138fe602c22ec42171b4a5e634286
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Update the support table to warn when users install gopls with Go 1.19
or 1.20, or have these older Go versions in their PATH.
Clarify current and future support in the README.
Fixesgolang/go#50825
Updates golang/go#65917
Change-Id: I99de1a7717a8cf99cae1a561ced63e9724dfff66
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588763
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Now that our CI builds (have for some time) set
an explicit GOPLSCACHE, it's not necessary for
tests to run the filecache GC, and it is costly
since they all try to do so at once.
This CL rotates the main loop so the first GC
doesn't start until after 5m, by which time the
tests are done.
This improves the real time of the integration
tests on macOS by about 8%.
n=3
before: 119 115 117 mean=117s real
after: 104 107 111 mean=107s real
Change-Id: I5eddb850795976e4a9fde33b0fc909e3d8e87169
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588768
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>
The go command treats imports of packages whose path contains
"/internal/" specially, and gopls must simulate it in several
places. However, other build systems such as Bazel have their
own mechanisms for representing visibility.
This CL suppresses the check for packages obtained from a
build system other than go list. (We derive this information
from the view type, which in turn simulates the go/packages
driver protocol switch using $GOPACKAGESDRIVER, etc.)
Added test using Rob's new pass-through gopackagesdriver.
Fixesgolang/go#66856
Change-Id: I6e0671caeabe2146d397eb56d5cd4f7a40384370
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587931
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Even in the trivial go list invocations (to enumerate
modules or type sizes), the complex behavior of Go modules
requires that the appropriate overlays are visible, since
they may define go.mod files.
Also, a test case suggested by Dominik Honnef.
Fixesgolang/go#67644
Change-Id: I19348ae7270769de438a7f4ce69c3f7a55fb2f55
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588936
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
When a file->package association changes, it may fix broken imports.
Fix this invalidation in Snapshot.clone.
Fixesgolang/go#66384
Change-Id: If0f491548043a30bb6302bf207733f6f458f2574
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588764
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
The bug report in golang/go#67144 likely means that we got a change
notification after the session was shut down (and thus s.viewMap was
nil).
Fix this by being more rigorous in guarding any function that resets
s.viewMap with a check for s.viewMap != nil. Also, refactor to remove
the confusing updateViewLocked and dropView functions, which obscure the
logic of their callers.
Fixesgolang/go#67144
Change-Id: Ic76ae56fa631f6a7b11709437ad74a2897d1e537
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589456
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
GOPACKAGESDRIVER commands absolutize filenames
relative to their current working directory. However,
os.Getwd may inadvertently expand out any symbolic
links in the path, causing files to have the "wrong"
path, and breaking various name-based equivalence tests
that are common in the go/packages domain.
This CL exploits the same trick used in gocommand to
prevent os.Getwd from expanding symbolic links:
if Stat(Getenv(PWD) returns the process's working
directory, then the iterated ".." search (which
inadvertently expands symlinks) is avoided.
It is unfortunate that driver writers must think about
this. Mostly it only shows up in tests, as that's
where the subprocess directory varies from the parent
directory.
Also, add -driver flag to gopackages debug helper,
which causes it to use drivertest instead of go list
directly.
Change-Id: Ibe12531fe565e74ca1d2565805b0f2458803f6b4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588767
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
The mkLeaf and mkBranch functions use hash consing to dedup values, by
constructing the leaf or branch value, and inserting it into a hash map
if the value is not already there.
This change uses two variables, one as the key for the map lookup, and a
second for the map value. This leads the compiler to place the first on
the stack and the second on the heap, so that a heap allocation is only
done if there is a cache miss.
This can be a significant saving for large VTA type graphs.
name old time/op new time/op delta
TrieStandard-16 2.35µs ± 6% 2.03µs ± 5% -13.48% (p=0.008 n=5+5)
TrieSmallWide-16 1.70µs ± 8% 1.41µs ± 5% -16.76% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
TrieStandard-16 1.20kB ± 9% 0.89kB ± 5% -26.33% (p=0.008 n=5+5)
TrieSmallWide-16 812B ±12% 480B ± 5% -40.94% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
TrieStandard-16 6.00 ± 0% 3.00 ± 0% -50.00% (p=0.008 n=5+5)
TrieSmallWide-16 8.00 ± 0% 1.00 ± 0% -87.50% (p=0.008 n=5+5)
Change-Id: I7faeb5458320972f9a267ff7ead04b4e5c31dfb8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588217
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
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>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
It is not used anywhere except tests, where it can be easily replaced.
Change-Id: Iec816099b7ce24685e2b42591a243a322689f6a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587098
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
stringintconv will return the alias name if available.
Make the test agnostic.
Updates golang/go#64581
Change-Id: I47d245c62f45cd6c02f45ba5eb770318dcb7cbec
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577657
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Simplify the file used to seed the marker test cache, as suggested in CL
588940.
Change-Id: I421a3e013fcc17f2c6ab2ff5c269e6f360ca9d6e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588942
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
The 'bestView' function was used in two places, where the meaning of
'best' differed. When re-evaluating view definitions in selectViewDefs,
we may want to create a new view if none of them matched build tags.
When operating on a file in viewOfLocked, we want to choose the most
relevant view out of the existing view definitions.
In golang/go#60776, we see that the latter concern was poorly handled by
the 'bestView' abstraction. Returning nil was not, in fact, best,
because it resulted in the file being associated with the default AdHoc
view, which doesn't know about modules.
Refactor so that viewOfLocked chooses the most relevant view, even if
none match build tags. This causes the orphaned file diagnostic to more
accurately report that the file is excluded due to build tags.
Fixesgolang/go#60776
Change-Id: I40f236b3b63468faa1dfe6ae6aeac590c952594f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588941
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>
CL 589118 is changing the format of go/types errors.
Update tests and the unusedvariable analyzer to be tolerant of this new
format.
For golang/go#67685
Change-Id: Ic1d3e663973edac3dcc6d0d6cc512fffd595eeb2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589455
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>
Fixes a test failure following the submission of CL 589135.
Change-Id: I746d06d6a661552de472c21e7010d5b07ad261d3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589059
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
The marker tests are heavily parallelized, and many import common
standary library packages. As a result, depending on concurrency, they
perform a LOT of duplicate type checking and analysis.
Seeding the cache before running the tests resulted in an ~80% decrease
in CPU time on my workstation, from ~250s to ~50s, which is close to the
~40s of CPU time observed on the second invocation, which has a cache
seeded by the previous run. I also observed a ~33% decrease in run time.
Admittedly my workstation has 48 cores, and so I'd expect less of an
improvement on smaller machines.
Change-Id: Ied15062aa8d847a887cc8293c37cb3399e7a82b6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588940
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This reverts CL 579337.
Reason for revert: need more work on staging this change in VS Code.
Change-Id: I82eea17f96a0365bd616ee2617536f10869e08f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589060
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Also, audit the golang package for similar places where we
discriminate builtins, and make them all use the new isBuiltin
helper, which is based on lack of a position instead of messing
around with pkg==nil||pkg==types.Unsafe||...
"A symbol without a position" is a fair definition of a built-in.
Fixesgolang/go#66923
Change-Id: I7f94b8d0f865f8c079f1164fd61121eefbb40522
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588937
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>
Make the missing import error knowledgeable of the view type, so that it
can correctly reference modules, GOROOT, GOPATH, or go/packages driver
as applicable.
While at it, fix some duplicated and broken logic for determining if the
view is in go/packages driver mode, consolidate on representing the
driver accurately as GoEnv.EffectiveGOPACKAGESDRIVER.
Fixesgolang/go#64980
Change-Id: I7961aade981173098ab02cbe1862ac2eca2c394b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Add a new drivertest package that implements a fake go/packages driver,
which simply wraps a call to a (non-driver) go/packages.Load. This will
be used for writing gopls tests in GOPACKAGESDRIVER mode.
The test for this new package turned up an asymmetric in Package JSON
serialization: the IgnoredFiles field was not being set while
unmarshalling. As you might imagine, this was initially very confusing.
Fixesgolang/go#67615
Change-Id: Ia400650947ade5984fa342cdafccfd4e80e9a4dd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/589135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Change propTypes and siteCallees to call a supplied function for each
value they yield, instead of returning a slice of all the values.
Change resolve to return a map instead of a slice. Its output is passed
to intersect, where the values were needed in a map.
Change intersect to produce its output more directly, using the above.
These changes can significantly reduce the amount of heap data created
for large graphs.
name old time/op new time/op delta
VTA-16 629ms ± 1% 627ms ± 1% ~ (p=0.548 n=5+5)
name old alloc/op new alloc/op delta
VTA-16 88.9MB ± 0% 79.6MB ± 0% -10.49% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
VTA-16 1.92M ± 0% 1.83M ± 0% -4.84% (p=0.008 n=5+5)
Change-Id: Ia143d3bb14df42980ce1b1bc027babd631d0d61c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588218
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Package is both the "cooked" result data type of a Load
call, and the "raw" JSON schema used by DriverResponse.
This change documents the fields that are part of the
protocol, and ensures that the others are omitted from
the JSON encoding. (They are populated by the post-
processing done by 'refine', if the appropriate Need
bits are set.)
Also
- document that there are a number of open bugs
in places where it may be likely to help,
particularly Mode-related issues.
- document that Load returns new Packages,
using distinct symbol realms (types.Importers).
- document Overlays in slightly more detail.
Fixesgolang/go#67614Fixesgolang/go#61418Fixesgolang/go#67601Fixesgolang/go#43850
Updates golang/go#65816
Updates golang/go#58726
Updates golang/go#56677
Updates golang/go#48226
Updates golang/go#63517
Updates golang/go#56633
Change-Id: I2f5f2567baf61512042fc344fca56494f0f5e638
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588141
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
This test was (surprisingly) the only source of failure on js/wasm. Skip
it to keep the build dashboard clean.
Change-Id: I69aa5b91152c313b5dba7d13a76fd6d32cd159a9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588755
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Many editors support two different operations when accepting
a completion item: insert and replace. LSP 3.16 introduced support
for both using `InsertReplaceEdit`. For clients that declare
textDocument.completion.insertReplaceSupport capability, gopls
can provide both insert/repace mode text edits.
See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem
VS Code client supports this capability, and users can switch
the mode with the editor.suggest.insertMode setting.
Note that in VS Code, "insert" is the default. That means,
providing a different range for insert changes the
user-perceived completion behavior greatly.
To reduce potential regression, this CL sets a different range
for insert only if all of the following conditions are met:
* there is a surrounding identifier token for the position.
* when splitting the identifier surrounding the position
to prefix and suffix, the suffix is not empty.
* the suffix is not part of the candidate's insert text,
which means the suffix may be deleted in replace mode.
Fixesgolang/vscode-go#3365Fixesgolang/go#61215
Change-Id: Ibe2476ddb9c13ecbaca7fb88cb3564912c4e5f4a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/585275
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
I missed a few in my previous CL:
- FindParam
- ParamInfo and its fields
- TestFn
- TestFns (eliminated entirely)
Change-Id: Ib8dabba73e679be5842bf1af359db80157446993
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587932
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>
An interface conversion such as any(x) can be a MakeInterface
(if x is a non-interface type) or a ChangeInterface (if x has
an interface type), and their nilabilities differ.
If x's type is a type parameter, SSA uses MakeInterface, so
we have to ascertain whether the type parameter is definitely
or only maybe a concrete type in order to determine its
nilability.
This change required exposing NormalTerms to x/tools,
and making it take the Underlying of its argument,
so that NormalTerms(error) = NormalTerms(any) = [].
Previously, NormalTerms(error) was [error].
Fixesgolang/go#66835
Change-Id: Idf9c39afeaeab918b0f8e6288dd93570f7cb7081
Reviewed-on: https://go-review.googlesource.com/c/tools/+/578938
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
VS Code has a complex and undocumented logic for presenting
Code Actions of various kinds in the user interface.
This CL documents the empirically observed behavior at
CodeActionKind.
Previously, users found that "nearly always available"
code actions such as "Inline call to f" were a distracting
source of lightbulb icons in the UI. This change suppresses
non-diagnostic-associated Code Actions (such as "Inline call")
when the CodeAction request does not have TriggerKind=Invoked.
(Invoked means the CodeAction request was caused by opening
a menu, as opposed to mere cursor motion.)
Also, rename BundleQuickFixes et al using "lazy" instead
of "quick" as QuickFix has a different special meaning
and lazy fixes do not necesarily have kind "quickfix"
(though all currently do).
Fixesgolang/go#65167
Update golang/go#40438
Change-Id: I83563e1bb476e56a8404443d7e48b7c240bfa2e0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
For now, incorporate godebug support by just updating x/mod and write
some tests. Diagnostics are mispositioned due to golang/go#67623.
While writing tests, I realized that the expect package still did not
support go.work files. Add this missing support. Also, remove a stale
comment from go.mod comment extraction, and simplify.
Fixesgolang/go#67583
Change-Id: I9d9bb53824b8c817ee18f51a0cfca63842565513
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588055
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This CL splits codelenses.md out of settings.md, since
they aren't settings.
This reduces the indentation level of settings by one,
since we can dispense with a heading. Also, don't increase
the <h%d> nesting level for each level of nested dotted options:
ui.foo.bar should not be rendered smaller than ui.foo.
Use only h2 for groupings and h3 for settings.
Also:
- improve the introduction.
- add anchors for groupings.
- delete handwritten .md doc for obsolete newDiff setting.
- add TODOs for some existing bugs in the generator.
Change-Id: If6e7fff028b2c372e0d766d3d092bd0e41d61486
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586879
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>
go1.23's range-over-func currently requires all the vars be
declared, blank if necessary. That may change, but for now,
suppress the checker.
Fixesgolang/go#67239
Updates golang/go#65236
Change-Id: I3e783fcfcb6a6f01f3acf62428cd9accbeb160c1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588056
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>
Commit-Queue: Alan Donovan <adonovan@google.com>
InsertReplaceEdit is used instead of TextEdit in CompletionItem
in editors that support it. These two types are alike in appearance
but can be differentiated by the presence or absence of
certain properties. UnmarshalJSON of the sum type tries to
unmarshal as TextEdit only if unmarshal as InsertReplaceEdit fails.
Due to this similarity, unmarshal with the different type never fails.
Add a custom JSON unmarshaller for InsertReplaceEdit,
so it fails when the required fields are missing. That makes
Or_CompletionItem_textEdit decode TextEdit type correctly.
For golang/go#40871
For golang/go#61215
Change-Id: I62471fa973fa376cad5eb3934522ff21c14e3647
Reviewed-on: https://go-review.googlesource.com/c/tools/+/587135
Reviewed-by: Peter Weinberger <pjw@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
All of these functions are no longer referenced across
packages since we cleaned up the server/lsprpc/golang split.
CanExtractVariable
EmbedDefinition
EnclosingStaticCall
FormatNodeFile
LinknameDefinition
CanExtractFunction
Updates golang/go#67573
Change-Id: I18490b333d79bad83eb5fcc34688fb41381771d1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586781
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>
The AfterChange predicate is insufficient for awaiting the GC details
command. We must await the specific diagnosis of GC details.
Fix the predicate, and update the documentation for AfterChange to more
clearly spell out what it awaits.
Fixesgolang/go#67428
Change-Id: I4923a4dac773f2c953a21bf026cadca4b9370ef3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586878
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>
Details:
- add introduction.
- change generator to put title in H2 heading,
and add anchors.
- organize list of analyzers in gopls settings.
- fix typos.
Change-Id: Ie559a331a2ac51171c366104416d53a8329afe7c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586779
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>
The special case for dot imports was spuriously matching
struct field names from other packages.
+ regression test
Change-Id: Ib125e22f092b793007f6ee60d8e58890762c37a4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586780
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>
This change adds a new "Show free symbols" (source.freesymbols)
code action that reports the set of free symbols referenced by
the selected region of Go source. The HTML report, produced by
the /freerefs endpoint of gopls' web server, includes an
itemized list of symbols, and a color-annotated source listing.
Symbols are presented in three groups: imported symbols
(grouped by package); package-level symbols and local symbols.
Each symbol is a link to either the integrated doc viewer
(for imported symbols) or the declaration, for others.
The feature is visible in editors as:
- VS Code: Source actions... > Show free references
- Emacs+eglot: M-x go-freesymbols
(Requires (eglot--code-action go-freerefs "source.freesymbols")
until dominikh/go-mode.el#436 is resolved.)
There are a number of opportunities for factoring in common
with RenderPackageDoc; they will be dealt with in a follow-up.
Also:
- a unit test of the freeRefs algorithm;
- an integration test of the web interaction.
- release notes.
Change-Id: I97de76686fcc28e445a72e7c611673c47e467dfd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/539663
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>
Remove TestHoverLit_Issue65072 now that the aix-ppc64 bug is confirmed
and reported. Instead, update the note for the conditionally skipped
basiclit.txt.
Updates golang/go#67526
Change-Id: Id7dd54006e015ac6d8c06c0abe022d77826f71b0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586777
Reviewed-by: Peter Weinberger <pjw@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Historically, CodeLenses were identified in the UI (LSP, CLI, docs)
by the command.Command that they return, but this is confusing
and potentially ambiguous as a single lens algorithm may offer
many commands, potentially overlapping.
This change establishes a separate CodeLensKind identifier for
them. The actual string values must remain unchanged to avoid
breaking users.
The documentation generator now uses the doc comments attached
to these CodeLensKind enum declarations. I have updated and
elaborated the documentation for each one.
Change-Id: I4a331930ca6a22b85150615e87ee79a66434ebe3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586175
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>
While benchmarking, I noticed that the didChange benchmarks become much
slower on successive runs in the same session (-count=10), despite using
the same amount of server-side CPU per operation. Investigation revealed
that this was due to the time spent client side repeatedly counting
started work items. That predicate initially assumed a small number of
operations, but for benchmarks there will be tens or hundreds of
thousands of work items, as the didChange benchmarks run fast and share
a common session.
Fix this by materializing the startedWork and completedWork maps.
Change-Id: I4e96648cfd0f5af2285a35891f43a77143798856
Reviewed-on: https://go-review.googlesource.com/c/tools/+/586455
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>