The annotations map should use an enum to indicate expected values. For
now, we reuse the EnumValues to expose the information in the settings.
Later, we'll create a separate EnumKeys field to expose this information
more correctly.
Also, adjust some of the logic that applies the settings because it was
incorrect.
Both gopls/doc/settings.md and internal/lsp/source/api_json.go are
generated files.
Updates golang/go#42961
Change-Id: Ifb032b70caaae73defe9a540df20d098d313e68e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280354
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
When trying to get outgoing call hierarchy from an var func like:
func main() {
foo := func() {}
foo()
}
gopls crashed with a panic.
This change makes it return an empty call hierarchy instead.
It also adds support for testing outgoing calls where the expected
result is 0 items, to be able to test this change.
Fixesgolang/go#43376
Change-Id: Icd91bf54cb4fbd5203f5865f0ff9d81365c27d5d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279469
Trust: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
The gopls release process has a number of steps which can be easily
forgotten, but they are also easy enough to check. In the future, we can
certainly automate this process further, but this basic program will
validate that mistakes like golang/go#43256 are not made again in the
future.
Change-Id: I04641ae202bc6615f2e4c8810b5dab4885d37fd4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279715
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
golang/go#43335 explains the issues with using `go get module@none`,
which will only be resolved in Go 1.17. In the meantime, we use the
go command whenever possible, but if the module is not tidied, we
have to use textual edits instead. This means the go.sum file will not
be accurately updated to remove the dependency, but unfortunately, I
don't believe there is anything that we can do in that case.
Fixesgolang/go#43335
Change-Id: I771f68f34a6136e73e9dd82b692ed4c235c3b293
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279716
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Added some tests to hoverKind, matcher, env and directoryFilters
of configuration options.
I'm also add a validation on `env`configuration, to initialize the map if is nil to avoid the risk of inserting the values in a nil map. Please let me know if this validation is unnecessary.
Fixesgolang/go#34244
Change-Id: I387ad0a393d981d070002c7e3736acad7b2191bf
GitHub-Last-Rev: 4fe354754323471f3260f990a264807525b3571b
GitHub-Pull-Request: golang/tools#261
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278072
Trust: Robert Findley <rfindley@google.com>
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Invalidating the workspace on any change to a go.mod can render a
workspace unusable. Only invalidate when changes are saved.
Additionally, invalidate the workspace if there is a saved change to
tracked go.sum changes.
Fixesgolang/go#42529Fixesgolang/go#42815
Change-Id: I5d903013b33b932eca4998513e3d0a534b2e5a61
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279720
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Package.ID() is far more useful to tag on events, as it disambiguates
multiple packages with the same path.
Change-Id: I03fd69f64641eb17155ca72ed2ef19641b75f004
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279722
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
The test doesn't pass on Android, likely because of the use of
go/packages.
Change-Id: If31ea39e9dfbbb1dc0d9c123a43384cb552cd025
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279712
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
When internal data structures in gopls changed, the templates driving
the debug server failed because fields or methods they relied on
had gone away. At some cost, this change adds tests that all the
fields and methods in the templates can be satisfied.
The test assumes that all the template uses are through render() in
debug/serve.go. It checks that is list of templates is the same
as the server's, and then type checks each template.
The costs are
1. the template type checking is done by a new external dependency,
github.com/jba/templatecheck
2. To avoid adding a new dependency to x/tools, the test is in
the gopls module, not the debug package, so variables from the
debug package have to be exported
In an ideal world the debug package, and much of internal/lsp,
would be in the gopls package. In that case the cost 2 about could
be avoided.
In an ideal world, the core runtime template packages would
contain template checking code, and cost 1 would be unnecessary.
In a more likely (or not so distant) world, perhaps jba would move
(or allow us to move) the template check package into x/tools.
Change-Id: I36b509a00cbdcb5323ee1af3c1193b603c7a907f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/277292
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Peter Weinberger <pjw@google.com>
If there is no require block, we were misplacing the Upgrade code
lenses.
Change-Id: Ic7ea5f254747bc1e1fc8aa42d0facc52702b745b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279172
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Hopefully this will prevent missing titles in the future. Confirmed this
works by removing an existing title.
Change-Id: Id8c7fa2eaffd043b5c66976d945376d6558f75bf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279173
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
We were getting duplicate diagnostics for certain mod tidy diagnostics.
The correct fix is to separate out the generation of such diagnostics
so that duplicates don't occur, but for now, this is the simplest fix.
I wanted to add a test, but my repro case involves `go clean -modcache`
and checking that a version cannot be downloaded, which doesn't work
with the file-based GOPROXY. I will probably have a CL at some point
that cleans up the way these diagnostics are produced.
Change-Id: I542648b4eae7aced15f720db6233c852879f2a26
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278917
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
We were previously showing them even if there were no benchmarks to run.
Fixesgolang/go#43239
Change-Id: I51d1de12e86009cca6d8ea41208949ed01484f6a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278780
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
There was never a test that actually confirmed that golang/go#42529 was
fixed, so it never actually was.
Updates golang/go#42529
Change-Id: I4264162e98c5fde804c780e098a1d4e21a2d88d8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279033
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
go/ast has problem with comments from its design, for now, best way is
to get rid of the comments.
See https://github.com/golang/go/issues/20744 for general problem.
Updates golang/go#43233
Change-Id: I7c29dc9d0573f5f894859cd8b24e010a777ebba2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278872
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This test currently fails, as we don't treat go.sum updates as
invalidation events.
Updates golang/go#42815
Change-Id: I01a94ac99293a425ff7cff5d5effab19d0fd2772
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279032
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This CL handles the panic in the sergi/go-diff library which has not
yet been resolved. We add an error return to the ComputeEdits function
and return an error if there is a panic. I'm not sure if this is the
best approach, but it does seem better than allowing the server to
crash.
A concern would be that the user wouldn't know why their code wasn't
being formatted, but hopefully they might look through the logs and
notice the error message. At least, other features would continue
working. The best fix will definitely be the fix for the panic, but that
is not yet available.
Threading through the error return was not pretty, but I thought it was
probably worth doing since it could be needed in other situations.
Updates golang/go#42927
Change-Id: I7f0c05eb296ef9e93b4de8ef071301cdb9dce152
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278775
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Rebecca Stambler <rstambler@golang.org>
These were missing titles, which was showing up empty for users in the
VS Code UI and leading people not to trust the fixes.
Also did a find references on SuggestedFix to confirm that we always
set the title in other cases.
Fixesgolang/go#43234
Change-Id: I8d0f272c383a2e1a364aefcec6650988d18d4fb4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278778
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
And regenerate docs and api_json.go
Change-Id: I7504c5257893617adcc0b657b61feb3cdb235061
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278356
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
The flattening didn't account for fields without name resulting in a
panic when calculating suggested fixes for such struct.
They are now added while flattening and there is also a test to ensure
that it works.
Change-Id: I8f8740c8d9132d10fb09053a322633eb29e8bcf8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278372
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Existing spans defined within gopls are leveraged to add runtime/trace
tasks, regions, and logging.
This made it easier to understand gopls' execution, though we still have
relatively sparse logging (arguably because we're conscious of the fact
that logs are reflected back to the LSP client). Add a new log package
with the concept of log level to facilitate excluding trace logs from
the LSP.
Add a little bit of additional instrumentation to demonstrate the usage
of the new package.
Change-Id: Id337be806484201103e30bfe2c8c62c7d7c363c7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275252
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Trust: Robert Findley <rfindley@google.com>
As of Go 1.16 the reflect package now supports multiple keys per tag.
For golang/go#40281Fixesgolang/go#43083
Change-Id: I55cdc35c857a5e73dc009c2842d7bd83c63d7712
Reviewed-on: https://go-review.googlesource.com/c/tools/+/277092
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
Now that the correct way to invoke regtests is via withOptions(...).run,
all the 'With' prefixes in option names seem redundant.
Change-Id: Icbbb00e15d034726d1e0cb13ff82b4f832add286
Reviewed-on: https://go-review.googlesource.com/c/tools/+/276974
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This change adds a diagnostic and error message that appears when a user
edits a nested module in legacy mode. At first, I thought a diagnostic
would be enough, but it's actually quite difficult to spot it when you
have a bunch of "undeclared name" diagnostics caused by the nested
module, so I figured a progress bar error message would also be useful.
This error message just indicates to the user that they should open the
nested module as its own workspace folder.
Also, while debugging this, I noticed that command-line-arguments
packages can have test variants, which we were never handling.
So I addressed that in this change.
Fixesgolang/go#42109
Change-Id: Ifa6f6af401a3725835c09b76e35f889ec5cb8901
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275554
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Provide both the current values and default values of Options. These
are in the Sessions tabs.
Display in the debug server, including the Options, needs work.
Change-Id: I970fa65631702b79f6e5f8089a5b1cc5daa8334e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275540
Trust: Peter Weinberger <pjw@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
For every file change, we want to diagnose the resulting snapshots.
However, we also want to diagnose the file in its "best possible" view
(for example, for a nested module, we should use the inner module rather
than the outer module).
Add a bestView function that operates on a set of views, which allows
us to a pick a view out of the *views affected* by a file modification,
not out of *all* of the views in the session. This means that we can
pick the best view, if any, for each file change and then only return
the snapshots that we should diagnose, as well as the changed URIs for
those snapshots.
Fixesgolang/go#42890
Change-Id: Iad23d5ed4832dfd857f1424a7244cf3bd8900e3b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274235
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
The "you are neither in a module nor your GOPATH" warning doesn't fit
our current notification style, so adjust it to appear as a progress
report and clean up the associated tests.
Change-Id: I32b96f17f3b9715403e465e3e0f9705f5d859147
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275537
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Certain builders have been failing consistently due to regtests timing
out. Attempt to clean-up the tools build dashboard by skipping the
regtests on these builders when -short is set.
Change-Id: Id359eb30cc5e0125e7568b972495a0599c3ccbc8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/276255
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Skip the runtime package as it does lots of stack switching that
causes false positives.
Change-Id: I001c5750db9f53b270073a05b4ae322141f4c49a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275518
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
`go get -u all` can have unexpected behavior for some users, since
upgrades all transitive dependencies as well as direct ones. Offer users
the ability to upgrade only direct dependencies via a code lens.
Also, change the placement of the upgrade code lenses. The module
declaration was getting cluttered, and they make more sense above the
requires anyway.
Updates golang/go#38339
Change-Id: I6790a02f2a334f3f4d1d89934b2c4dc4f11845ce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275432
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Users working in large repositories may want to include only selected
directories in their workspace to avoid memory usage and performance
slowdowns. Add support for inclusion/exclusion filters that control what
directories are searched for workspace packages and modules. Packages
that are excluded by the filter may still be loaded as non-workspace
packages if other things depend on them.
For a description of the option's syntax, see the documentation.
Note that because we don't have any way to communicate the filters to
packages.Load, we still run go list on the unfiltered workspace scope,
then throw away the irrelevant packages. That may cost us, especially in
workspaces with many files.
Comments on the naming welcome. Also, if you know any places I may have
missed applying the filter, please do tell. One thing I thought of is
file watching, but that's covered because allKnownSubdirs works off of
workspace files and those are already filtered.
Possible enhancements:
- Support glob patterns.
- Apply filters during the goimports scan.
- Figure out how to apply the filters to packages.Load. I don't know
how to do it while still being build system neutral though.
Closesgolang/go#42473, assuming none of the enhancements are required.
Change-Id: I9006a7a361dc3bb3c11f78b05ff84981813035a0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275253
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
When GO111MODULE=auto and the workspace is outside of $GOPATH/src, we
should still show diagnostics about how to correctly configure
multi-module workspaces. We should not show these warnings for
workspaces outside of a module within GOPATH.
This adds an extra piece to the WorkspacePackages error logic--we may
still need to show the errors even if WorkspacePackages returned
results. We should eventually consolidate all of this logic to be more
cohesive, but for now I think it's more important to cover all of the
different cases and add tests.
Updates golang/go#42109
Change-Id: I673a03c9840cdaaf7f058de1cda3bf36b96fa7d3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275553
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
In CL 268157, I tried to be careful about only deleting workspace
packages when we were certain they had been deleted. After investigating
this issue a little bit more in practice, I think we can afford to just
delete any package ID that has had a file change package names. We don't
always have valid metadata to use from the previous snapshot, and we
will pick up the new workspace package on the next reload.
Also, hardcode GO111MODULE=off for a test that was failing on my
machine at master.
Change-Id: I43a9d50821c90ad4b4560a6ff27d37bd572dbcd3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275536
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Rebecca Stambler <rstambler@golang.org>
When generating a default param name based on a type name, we want to
ignore any package qualifier. For example, if the type is "ast.Node"
we want to generate the variable name "n", so we must ignore the
"ast." qualifier. To do this we use a types.Qualifier that always
returns empty, but qualifyExpr wasn't respecting an empty qualifier
because it is doing manual ast manipulation. However, it seems like
things "just work" if you set a SelectorExpr's "X" to empty
string (i.e. only "Sel" is output when formatting).
Fixesgolang/go#42794.
Change-Id: Ied86b9511e4a9550590417c5a506fe35d561d4f9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275519
Run-TryBot: Muir Manders <muir@mnd.rs>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Robert Findley <rfindley@google.com>
While evaluating workspace symbols, we avoid duplicate packages per
package path in an effort to save computing time and eliminate duplicate
results. But for simplicity, we later guard to ensure that we don't ever
walk files twice.
We can just rely on this guard to prevent duplication, and walk all
known packages. This ensures we don't miss symbols, at minimal
additional cost, and simplies the code.
This is a roll-forward of CL 272686, which was accidentally submitted
too early.
Fixesgolang/go#42791
Change-Id: I8c39b7afe6c38fedb0e21831d88c28d13d51f102
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274243
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
When running with -mod=readonly, we need a go.sum to be present for go
command invocations. Achieve this by merging the go.sum of tracked
modules.
Fixesgolang/go#42509
Change-Id: I36dd084f865ebcee0ba6e1e542fdf51031b1487e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/272886
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Given package f containing f.go and f_test.go, the test variant for f
will have both in its list of go files. But the variant is deleted as
soon as f_test.go is deleted, and we should stop trying to load it.
Adjust the workspace package logic in (*snapshot).clone to consider only
_test files when checking whether to remove a test variant.
External tests don't need this logic, since they don't include the
normal files, but it doesn't hurt so there wasn't any point in being
picky.
Change-Id: Id0060ad4593545a85df74c3d1997338005ceb736
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275273
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
In Go 1.16 error codes as well as start and end positions are added for
go/types errors. This information is temporarily stored in unexported
fields, until we're more confident in the correctness of both the API
and the underlying data.
Read this information using reflection and, if available, use it to set
the corresponding field in compiler diagnostics. This establishes a
positive feedback loop: in most cases this should improve the gopls
diagnostic, and wherever it doesn't we can make a note and fall back on
the old heuristics for that error code.
For golang/go#42290
Change-Id: I37475189cbd14a0a5bcfde163f599c9a7b957372
Reviewed-on: https://go-review.googlesource.com/c/tools/+/268539
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Links to godoc.org pages are changed to link to pkg.go.dev.
CL 253017 and CL 234678 are also backported.
For golang/go#36106
Change-Id: I6a875f5b43e456f11d8eeccfc5ef647a5501c4d3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275235
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Executing the "go test" command did pass Package.PkgPath() as first
argument to the go invokation before. That failed when using test
packages with _test suffix.
The "go test" command now use Package.ForTest() instead.
Fixesgolang/go#43037
Change-Id: Iea1a0e0c949a53770c1d3e1126a16a9c4952a53f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275496
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Two changes are made to speed up the regtests (from 150s->100s on my
desktop):
+ Eliminate WithoutExperiments in favor of just Singleton mode, now
that we're not running other tests in Forwarded mode by default.
+ Reduce the diagnostics delay to 10s, which should still be enough to
exercise bugs related to debouncing but is not so much that it slows
down the tests significantly.
Change-Id: Ia12c8417aee7bb50baccce27e1e1752315900b76
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275450
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
There was a race to the background context that allowed work for earlier
snapshots to run on the background context of later snapshots. For
example, the following sequence is possible and has been observed in
tests (admittedly at unrealistic time scales):
- snapshot N is created
- view.cancelBackground() is called
- snapshot N+1 is created
- snapshot N+1 is diagnosed
- snapshot N is diagnosed
- snapshot N is destroyed
Fix this by pinning the background context to the snapshot. This also
makes more sense; I'm guessing the background context being on view is a
vestige of when more work was done on the view.
For golang/go#42837
Change-Id: If9cbad7361de823da9bfd2f55cb2f8b3aed95075
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275239
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
These options were added in CL 274532, but it's not possible for users
to actually set them.
Change-Id: I85642ada017f225d4d77e4dfc97fe13847f4091a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275442
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
As part of the earlier changes, I didn't realize that multiple //-style
comments would be grouped as one *ast.Comment, even though they are
multiple comment tokens. Handle the possibility of multiple consecutive
comment tokens.
Fixesgolang/go#42923
Change-Id: I6bc6cbdfb28a8e60c699288528566e406f27514c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275012
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
We've been aiming to enable diagnostic debouncing by default, and now
that CL 269197 is merged, I think it's time to do that.
I know that the experimental setting had it at 200ms, but the 250ms was
specified in golang/go#42693, so I'm not sure which is preferable.
Also, fix a bug I introduced in CL 269197, which set alwaysAnalyze to
true for diagnoseChangedFiles. This should only be used for testing.
Add a requirement for 1.13 to one test that relies on good overlay
support (loading the file directly produced a different response from
the full workspace load).
Fixesgolang/go#42693
Change-Id: I49b764a8d473a66a01ef0f2c6f4cbe2d512fd64e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274445
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
difftest using output of GNU diff, which will be translated based on
LANG settings.
Fixesgolang/go#42962
Change-Id: Id4ae22da04077eb7cda7faace306fdbe1836ec60
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274992
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>