Now that it's the default link target.
Change-Id: Ic90700168711a16fc0c98f980c6d449ca1328669
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221498
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Some initial documentation is added describing how to use a shared gopls
daemon, following the work in golang.org/issues/34111.
Updates golang/go#34111
Change-Id: I8ee07d7415ae799bb867973c34bda53f9a35126d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221138
Reviewed-by: Heschi Kreinick <heschi@google.com>
This change updates staticcheck to 2020.1.3.
It fixes two bugs involving //lint:ignore directives:
- When ignoring U1000 and checking a package that contains tests, Staticcheck would incorrectly complain that the linter directive didn't match any problems, even when it did.
- On repeated runs, the position information for a this linter directive didn't match anything report would either be missing, or be wildly incorrect.
Change-Id: I98bc57d290393d77af1ab8acf486239a8f125fac
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220597
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
I was checking on the status of the known issues, and I noticed that some are already fixed. I checked each one and culled the list.
Change-Id: I178cb5fdc3aa21e658c3ffd8bf558d5c48c5528f
GitHub-Last-Rev: b0135c2c6e95395026641ce8214f08a2aa623d92
GitHub-Pull-Request: golang/tools#211
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220681
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
In the ideal future, users will have one or more gopls instances, each
serving potentially many LSP clients. In order to have any hope of
navigating this web, clients and servers must know about eachother.
To allow for such an exchange of information, this CL adds an additional
handler layer to the serving configured in the lsprpc package. For now,
forwarders just use this layer to execute a handshake with the LSP
server, communicating the location of their logs and debug addresses.
Updates golang/go#34111
Change-Id: Ic7432062c01a8bbd52fb4a058a95bbf5dc26baa3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220081
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
For testability, and to support the exchange of debug information across
Forwarder and server, it is helpful to encapsulate all debug information
on the instance object.
This CL moves all state in the debug package into a new 'State' type,
that is added as a field on the debug.Instance. While doing so, common
functionality for object collections is factored out into the objset
helper type.
Also add two new debug object types: Client and Server. These aren't yet
used, but will be in a later CL (and frankly it was easier to leave them
in this CL than to more carefully rewrite history...).
Updates golang/go#34111
Change-Id: Ib809cd14cb957b41a9bcbd94a991f804531a76ea
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220078
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This change updates Staticcheck to the newly released 2020.1.2.
Change-Id: I80606b9c993de2f504c0ca3ee68f695ec8bd50e9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220477
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Update the servertest package to support connecting to a jsonrpc2 server
using either TCP or io.Pipes. The latter is provided so that regtests
can more accurately mimic the current gopls execution mode, where gopls
is run as a sidecar and communicated with via a pipe.
Updates golang/go#36879
Change-Id: I0e14ed0e628333ba2cc7b088009f1887fcaa82a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/218777
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Create a real type for protocol.DocumentURIs. Remove span.NewURI in
favor of path/URI-specific constructors. Remove span.Parse's ability to
parse URI-based spans, which appears to be totally unused.
As a consequence, we no longer mangle non-file URIs to start with
file://, and crash all over the place when one is opened.
Updates golang/go#33699.
Change-Id: Ic7347c9768e38002b4ad9c84471329d0af7d2e05
Reviewed-on: https://go-review.googlesource.com/c/tools/+/219482
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
The nilness analyzer requires SSA, which is very expensive to build and
uses a lot of RAM. It also seems to really shoot up memory usage when it
hits certain cases, which is causing a lot of problems for users.
Disable this analysis - we'll leave SSA to staticcheck.
Updates golang/go#36639
Change-Id: I46e67a6fd7828a5fddcd42d1aa00876f17c79e3d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/219203
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Users with staticcheck enabled will be more tolerant of increased RAM
usage. We might be able to disable this check entirely once the next
version of staticcheck is released with a similar analysis (https://staticcheck.io/docs/checks#SA5011).
Change-Id: I1a844cc226e34e0f62222f12912797a6cc9d06e2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/219018
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Previously, the process of instantiating and running the LSP server was
sharded across the lsp, protocol, and cmd packages, and this resulted in
some APIs that are hard to work with. For example, it's hard to guess
the difference between lsp.NewClientServer, lsp.NewServer,
protocol.NewServer (which returns a client), and protocol.NewClient
(which returns a server).
This change reorganizes Server instantiation as follows:
+ The lsp.Server is now purely an implementation of the protocol.Server
interface. It is no longer responsible for installing itself into the
jsonrpc2 Stream, nor for running itself.
+ A new package 'lsprpc' is added, to implement the logic of binding an
incoming connection to an LSP server session. This is put in a
separate package for lack of a clear home: it didn't really
philosophically belong in any of the lsp, cmd, or protocol packages.
We can perhaps move it to cmd in the future, but I'd like to keep it
as a separate package while I develop request forwarding.
simplified import graph:
jsonrpc2 ⭠ lsprpc ⭠ cmd
⭩ ⭦
lsp (t.b.d. client tests)
⭩ ⭨
protocol source
+ The jsonrpc2 package is extended to have a minimal API for running a
'StreamServer': something analogous to an HTTP server that listens
for new connections and delegates to a handler (but we couldn't use
the word 'Handler' for this delegate as it was already taken).
After these changes, I hope that the concerns of "serving the LSP",
"serving jsonrpc2", and "installing the LSP on jsonrpc2" are more
logically organized, though one legitimate criticism is that the word
'Server' is still heavily overloaded.
This change prepares a subsequent change which hijacks the jsonrpc2
connection when forwarding messages to a shared gopls instance.
To test this change, the following improvements are made:
+ A servertest package is added to make it easier to run a test against
an in-process jsonrpc2 server. For now, this uses TCP but it could
easily be modified to use io.Pipe.
+ cmd tests are updated to use the servertest package. Unfortunately it
wasn't yet possible to eliminate the concept of `remote=internal` in
favor of just using multiple sessions, because view initialization
involves calling both `go env` and `packages.Load`, which slow down
session startup significantly. See also golang.org/issue/35968.
Instead, the syntax for `-remote=internal` is modified to be
`-remote=internal@127.0.0.1:12345`.
+ An additional test for request cancellation is added for the
sessionserver package. This test uncovered a bug: when calling
Canceller.Cancel, we were using id rather than &id, which resulted in
incorrect json serialization (as only the pointer receiver implements
the json.Marshaller interface).
Updates golang/go#34111
Change-Id: I75c219df634348cdf53a9e57839b98588311a9ef
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215742
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This change standardizes the folder structure for testdata that are used for testing the lsp. In particular, it uses the following format:
- dir
- primarymod
- .go files
- packages
- go.mod (optional)
- modules
- repoa
- mod1
- .go files
- packages
- go.mod (optional)
As we can see, any folder inside of testdata should be of this format, where the primary test files with the markers are all located inside the primarymod folder. The modules folder is used to hold any potential dependencies that are used for testing.
A consequence of this change is that we can have one directory separated by folders, where each folder is it's own module, this allows us to use internal/lsp/tests with go.mod files. Now, tests.Load() will return an array of Data objects, where each object corresponds to one of the directories structured above.
Updates golang/go#36091
Change-Id: I437cc2a2a9fc1bac93779845737aa74383fbf9c3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217541
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Now that there is a tagged version of govim containing the `-gopls` test
flag, we can just use latest to pick up a relatively stable govim, and
not have to maintain the govim version.
Doing this required changing the way we fetch govim into our test
harness: there is now the assumption that /src/govim is a git
repository, so we clone using git.
Along the way, clean up some unnecessary artifacts and add a script for
downloading artifacts from GCS.
Change-Id: I6ef4dd468d6b9baf66d3adae3f1fb80c12ac9578
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217730
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Govim integration tests are now passing at govim HEAD + gopls HEAD, so
we should be able to start actively investigating any regressions on the
gopls side after this change.
Change-Id: Ibf50d7e42e19cfc80779691e2c42f643028b2e39
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215897
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Hardcoded for now. Will need a better approach if more of these come up.
Fixesgolang/go#34494
Change-Id: Id442d68fa16d81e747ad5ec951fb6b80fdb65f94
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215118
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Add the exact VS Code settings that users need to capture valuable logs.
Change-Id: If6b4874d1d3beab2fa6da054615dd7973b6e3fa9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/214940
Reviewed-by: Heschi Kreinick <heschi@google.com>
Govim integration tests generate a number of artifacts, including both
the govim and gopls logs, that can be useful in debugging failures. This
change updates our cloud build configuration to capture these artifacts,
along with several other minor improvements.
Notably artifacts are uploaded to GCS as a separate build step, so that
we have the potential to use its granular permission model for sharing
these artifacts. Right now, this requires temporarily swallowing the
exit code of `go test` so that the build can proceed.
Also:
- Update govim to a newer version; we still can't use latest as there
isn't a tagged version that contains the requisite flag change.
- Alter the test harness to run tests from the github.com/govim/govim
module root.
- Switch use a major version label when referring to the test harness
build step, to allow for breaking changes (such as the one made
here).
- Add a missing copyright header to run_local.sh.
- Update run_local.sh to work with the modified harness.
- Update documentation accordingly.
Change-Id: Ie5ddaf54e775371a36163f98c1beb90c217be931
Reviewed-on: https://go-review.googlesource.com/c/tools/+/214577
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
A couple sentences are clarified in design.md, and a broken link is
fixed in implementation.md.
Change-Id: Ibbb4c2f74ce9e46c565a7e90798047e7168b076e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/214798
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
These are changes to treat errors more like responses. They are
important for the forthcoming log viewer.
Change-Id: Ief8de6ecea716673d4aee417de205842ceab4fc8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/213124
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Some ergonomic and cosmetic updates are made to the integration/replay
and integration/parse packages, following a pass through the code:
+ In the README, a some typos are corrected.
+ A few symbols are renamed:
- Direction->MsgType, since this type is more than a client-server
direction
- logRec->scanLogs, to be more consistent with the naming convention
SplitFuncs in the bufio package
- CamelCase is applied in a few places.
+ Context is plumbed through, rather than use a package local ctx.
+ In a few cases, returning an error is preferred over log.Fatal.
+ Some duplicated code is deleted, and types from the parse package are
reused. (this was probably cruft from the repo migration)
+ The logfile is made an argument rather than a flag to the replay
tool.
Change-Id: Ie72e6e8a4d7020d8cf708f6791353897791bcc86
Reviewed-on: https://go-review.googlesource.com/c/tools/+/211057
Reviewed-by: Peter Weinberger <pjw@google.com>
Our current implementation isn't robust, and it doesn't seem worth it to
invest significant effort in improving it when this library exists.
Also, make the protocol part of the default URL regex non-optional, as
the alternative is that any string of the format "foo.bar" will appear
to be a link.
Updates golang/go#33505
Change-Id: Ia430a1c193eded394f8af12050bdd4dc2a9ccc94
Reviewed-on: https://go-review.googlesource.com/c/tools/+/212517
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The EOL setting is no longer needed, as the issue it was correcting
has been fixed. The file watching setting is not really being respected
correctly in the current version of gopls, as we are currently reworking
it.
Change-Id: I0aa9546f0c806bcf326eb83b515bee4bce4c6864
Reviewed-on: https://go-review.googlesource.com/c/tools/+/212497
Reviewed-by: Heschi Kreinick <heschi@google.com>
Govim has integration tests that we can leverage to help guard gopls
against regressions. Changes have been submitted upstream to facilitate
running these tests against a locally built gopls binary
(https://github.com/govim/govim/pull/629)
This CL adds a Dockerfile to build an image that has a version of govim
available and ready for testing. This is then used to create a custom
build step in a separate Cloud Build configuration, that builds gopls
from source and runs the govim integration tests.
A script (run_local.sh) is also added to facilitate running these tests
locally.
Change-Id: If68eabf9863a1689e29d9d744ff953d94a2b7681
Reviewed-on: https://go-review.googlesource.com/c/tools/+/212018
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Fix the link to the IDE specific usage documentation (now under /doc/ folder).
Change-Id: Ib0efb8a107195317c7a4a535fc9f624fe277840e
GitHub-Last-Rev: 66f771f799c1e93fd9337040f0b1166061f6419e
GitHub-Pull-Request: golang/tools#192
Reviewed-on: https://go-review.googlesource.com/c/tools/+/211561
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Created an analogous data structure for go.mod files when we parse them
using the golang.org/x/mod package. Gopls can now access the data
within a go.mod file using a parseModHandle and the corresponding
parseModData object. This will help down the road when it is time
to implement the lsp functions for go.mod files.
Updates golang/go#31999
Change-Id: Ibd4d64569bbe3df61b203490b63399d479e7d794
Reviewed-on: https://go-review.googlesource.com/c/tools/+/211303
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
The early return logic for didOpen events in
(*snapshot).invalidateContent was preventing the creation of a new
snapshot, which was in turn stopping the versions from being updated.
This exposed a fundamental issue in the way we were calculating
workspace diagnostics. Since we weren't waiting for diagnostics to be
completed for an entire snapshot before replying that the server had
been initialized, snapshots were being cloned without any type
information. For quickfix code actions, we assume that we have all
information cached (since we need to have sent the diagnostics that the
quickfix is mapped to), so we were not finding the cached analysis
results.
To handle this in the short-term, we key analyses by their names, and
then regenerate results as-needed for code actions. This is technically
more correct than simply assuming that we have the analyses cached. In a
follow-up CL, I will send a follow-up that will make sure that
snapshots "wait" on each other to be fully constructed before being
cloned.
Change-Id: Ie89fcdb438b6b8b675f87335561bf47b768641ac
Reviewed-on: https://go-review.googlesource.com/c/tools/+/208265
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
A general mechanism for modifying the features in command line tests
Use it to turn of go-diff for now
Fixesgolang/go#35392
Change-Id: Ie79723e94fb14fcde1e98709a63f44046e101bc4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/205739
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
It's been a while since we updated, and this will make things easier for
users who want to try new features.
Change-Id: I3accd77e23bf2d0bbafaba16dcab8179e6a14253
Reviewed-on: https://go-review.googlesource.com/c/tools/+/201638
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This allows them to be run from the gopls module as well to test
the code with the hooks installed.
Change-Id: I3079a04ffe3bd221ccc2523e746cbed384e05e2f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/196321
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This allows us to hook functionality from the main tools repository with
alternate or extended implementations.
Change-Id: Ibc66cdd15ee80f1104a8464f1e28763a41d5765a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/196319
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
By default, github.com/natebosch/vim-lsc shows messages from stderr in
vim's :messages, which may cause problems and is generally annoying.
Suggest disabling that by setting suppress_stderr to v:true.
Change-Id: If997b8f8fd036a1ac08ba74a3886f33ff71413c2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194137
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Fixes this problem when trying to use the documented installation command:
```
$ GO111MODULE=on go get golang.org/x/tools gopls@latest
go: finding golang.org/x/tools latest
go: downloading golang.org/x/tools v0.0.0-20190911230505-6bfd74cf029c
go: extracting golang.org/x/tools v0.0.0-20190911230505-6bfd74cf029c
go get gopls@latest: malformed module path "gopls": missing dot in first path element
```
Change-Id: Ifdd13ec85eca5a069c17ae89486efe1abf4016f4
GitHub-Last-Rev: a4ddc02e3b8e6ccce12dfa711a8e7af5edb1302c
GitHub-Pull-Request: golang/tools#158
Reviewed-on: https://go-review.googlesource.com/c/tools/+/195037
Reviewed-by: Ian Cottrell <iancottrell@google.com>
The fix for golang/go#29313 just went in, so update so people can fetch
it more easily.
Change-Id: I60fda011dfdd62d5de429834a6692f6b21074f0d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194377
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Much of this documentation has been collated from other sources,
but this pulls it all into one coherent and public structure in
a way that allows us to peer review changes.
Change-Id: Ic24a59bb92b27ec85d2f57affcf2eb396c9de3c0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/191741
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
this shuffles things so there a single exporter API rather than an observer
It also removes most of the globals.
per telemetry type.
Change-Id: Iaa82abe2ded1fff9df8e067ed4a55bcbd9d9591f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/190405
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
If a user runs a file= query for a source that doesn't exist,
and they are outside of a module, fill in the GoSources for the
empty package that go list returns, so the overlay can be applied.
Also add a hack for the case where go list can't determine the compiler
(gc or gccgo) a user is using because
go list -f "{{context.Compiler}}" -- unsafe
doesn't work. If go list complains that a user is outside a module,
we'll give ourselves flexibility to guess things because there's
no right answer. So we'll guess that the compiler is gc.
Fixesgolang/go#33482
Change-Id: I6a8aa0c617c4d803558389fb4272854245f59c5a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/189322
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This is used by all the telemetry packages that come next
Change-Id: Ic84d91da2a792b53ee8839aae207ae5767ab17e0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184940
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
CL 183264 accidentally introduced a circular modular reference from
golang.org/x/tools -> golang.org/x/tools/gopls.
Fixed by running go mod tidy on all modules under the x/tools repo for
good measure.
Change-Id: Ib09b111315cb107bc4e34015b74266d2522f33fd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184018
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>