1
0
mirror of https://github.com/golang/go synced 2024-10-01 11:18:32 -06:00
Commit Graph

30 Commits

Author SHA1 Message Date
Ian Cottrell
e88138204b internal/span: change URI.Filename so it just returns the filename
We panic if the uri was not a valid file uri instead
They always are a valid file URI, and we would fail miserably to cope if they were
not anyway, and there are lots of places where we need to be able to get the filename
and don't want to cope with an error that cannot occur.
If we ever have not file uri's, you will have to check if it is a file before calling
.Filename, which seems reasonable anyway.

Change-Id: Ifb26a165bd43c2d310378314550b5749b09e2ebd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181017
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-10 21:39:43 +00:00
Ian Cottrell
7927dbab1b internal/lsp: build the packages config on demand from proper configuration
This moves the fileset down to the base cache, the overlays down to the session
and stores the environment on the view.
packages.Config is no longer part of any public API, and the config is build on
demand by combining all the layers of cache.
Also added some documentation to the main source pacakge interfaces.

Change-Id: I058092ad2275d433864d1f58576fc55e194607a6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178017
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-21 17:12:43 +00:00
Ian Cottrell
faf83c64e9 internal/lsp: fix race in delivering diagnostics to the command line client
Fixes golang/go#32091

Change-Id: I1399a596169384f48d9f2409988226708dcd3473
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177937
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-20 19:38:31 +00:00
Evan Digby
d88f79806b internal/lsp: fix swallowed package errors
If a package has an error that makes it completely unparseable, such as containing a .go file with no "package" statement, the error was previously unreported. Such errors would manifest as other errors.

Fixes golang/go#31712

Change-Id: I11b8d0e2e4d64b03fbcb4c35e7f0b02fccc83fad
GitHub-Last-Rev: 1581cbe36c269dd964f0b9226dbd63b1650c2a5b
GitHub-Pull-Request: golang/tools#102
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177605
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-17 18:33:31 +00:00
Ian Cottrell
b9584148ef internal/lsp: add structured layers to the cache
This is primarily to separate the levels because they have different cache
lifetimes and sharability.
This will allow us to share results between views and even between servers.

Change-Id: I280ca19d17a6ea8a15e48637d4445e2b6cf04769
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177518
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-16 21:30:38 +00:00
Rebecca Stambler
abbb706b23 internal/lsp: enable enhanced hover by default
This change removes the explicit configuration for improved
documentation on hover. We use a comment's synopsis rather than the full
comment.

However, we also add a "noDocsOnHover" setting that is used by the cmd
tests. Ultimately, no one should use this setting and we should remove
it. We leave it temporarily because the cmd tests still need work.

Change-Id: I5488eca96a729ed7edad8f59b95af163903740d6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174378
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-16 17:30:22 +00:00
Ian Cottrell
0e55654012 internal/lsp: add shutdown handling
We correcly cancel all background tasks and drop all active views when
the server is asked to shut down now.
This was mostly to support the command line being able to exit cleanly

Change-Id: Iff9f5ab51572aad5e3245dc01aa87b00dcd47963
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174940
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-15 23:16:32 +00:00
Ian Cottrell
44dd571771 internal/lsp: add version and bug commands
Also log gopls version information on startup in server mode.

Change-Id: If7bf85d19f993430709b1fae83083e6fdfe1b2ca
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175199
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-11 04:16:02 +00:00
Ian Cottrell
90441677ad internal/lsp: suppress info and default logging unless a verbose flag is supplied
Change-Id: Ib4bf2a47cad4151b4b64d922855013b22b4fbb15
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176641
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-11 04:13:52 +00:00
Ian Cottrell
d4e30f1c22 internal/lsp: making cmd tests fast and small
This required extensive changes to the "internal" server handling and also to
the way we wait for diagnostics in the "check" verb.
It improves both memory and time by over an order of magnitude, hopefully
allowing us to renable the tests on the builders

Change-Id: I84e84ca4c449e9970ebf1d922a0a2ce0a8a49c72
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175878
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 20:14:07 +00:00
Peter Weinberger
08ecc9edd9 internal/lsp: generate RPC interface from Typescript source
The generated code adds some server methods that are unsupported, but were
prviously unimplemented, and makes small adjusments to some parameter types.

Change-Id: I3dd32cafa3e457193f0771e0f8e150c88b381c82
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173420
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-30 16:16:08 +00:00
Ian Cottrell
4eab536980 internal/lsp: add the format command line
Change-Id: If7c4135b6b81b4f691d0f5eae8b49a1aca028346
Reviewed-on: https://go-review.googlesource.com/c/tools/+/171031
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-25 22:22:32 +00:00
micnncim
15d5d381ff internal/lsp: fix error handling in cmd
Found unnecessary error handling so removed.

Change-Id: I1a48e73186425291fdb0ede963b92ef6c9ce0ed8
GitHub-Last-Rev: d5cf67cb4a418bdc81dbd32eef9afb567ae4ff15
GitHub-Pull-Request: golang/tools#84
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173097
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-22 18:06:12 +00:00
Rebecca Stambler
f6abc2cac8 internal/lsp: check content format instead of assuming markdown
Fixes golang/go#31078

Change-Id: I2227f64d839d65d7b46d43e1b90f5b1dc298bf6f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172601
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-17 21:38:10 +00:00
Peter Weinberger
04e50493df cmd/gopls: fix incomplete ClientCapabilities struct
go.ts, the program that generates Go types for the LSP protocol, now
handles Typescript type merging for ClientCapabilites, so fields are no
longer missing. Also, to silence go lint and go vet there are changes
in the comments generated in tsprotocol.go. All the *structs were changed
to structs in ClientCapabilities as it was absurdly complex to write literals
of the type. Finally, several otherwise unused types are no longer
generated.

Change-Id: If414a32bc4d733adb2cf8befda9d8a0703c568a6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/171026
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-09 15:09:02 +00:00
Ian Cottrell
f558378bf8 internal/lsp: make definition use the lsp protocol
instead of driving the source pacakge directly, it indirects through the lsp
protocol (the same way check does)
We are normalizing on all the command lines doing this, so that server mode
is more viable in the future.

Change-Id: Ib5f2a059a44a5c60a53129c554e3cc14ca72c4a8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170577
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-05 17:02:55 +00:00
Ian Cottrell
5bca5db4cb internal/lsp: check the client capabilities before calling workspace/configuration
Change-Id: I88d1142f4737cb74f5d6c9409218dde674dc1834
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170184
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-01 20:27:58 +00:00
Ian Cottrell
5d16bdd7b5 internal/lsp: add the ability to log back to the client
Also use it for errors that were otherwise silently dropped
This makes it much easier to debug problems.

Also added command line control over whether the rpc trace messages are printed, which allows you to read the
log, otherwise the file edit messages swamp the log.

Change-Id: I7b70fd18034a87b2964e6d6d5f6f33dcaf7d8ea8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170178
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-01 16:22:08 +00:00
Ian Cottrell
a8f40b3f4d internal/jsonrpc2: split main loop from construction to fix race
This changes the basic API of a jsonrpc2 connection to run the
read loop as a method rather than in a go routine launched in
the NewConn. This allows the handler to be created and bound
between construction and the read loop starting, which fixes
the race.

Fixes golang/go#30091

Change-Id: I8201175affe431819cf473e5194d70c019f58425
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170003
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-29 19:31:51 +00:00
Ian Cottrell
4471d52094 internal/lsp: allow command line tests to connect through a pipe
With this change (finally, after a lot of detours) if you run the lsp tests with `-race -pipe` then you
can reliably reproduce the race in golang/go#30091

Change-Id: Ibd9fda5e07409a15d1bc8d14cb46fde41155aa6e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169999
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-29 15:12:06 +00:00
Ian Cottrell
ab21143f23 internal/lsp: adding command line access to diagnostics
Change-Id: I011e337ec2bce93199cf762c09e002442ca1bd0d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167697
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-28 21:17:00 +00:00
Rebecca Stambler
a21eef959b internal/lsp: use parallel parse files function
This change adds a copy of the parseFiles function from go/packages for
file parsing. Also fix crash caused by lack of TypeSizes from
go/packages.Load when using LoadImports mode.

Change-Id: Ie8c3c653679ab81da45905c6839de7e63966d84c
Reviewed-on: https://go-review.googlesource.com/c/161670
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-02-13 04:21:09 +00:00
Rebecca Stambler
f7e1b50d22 internal/lsp/cmd: set Serve.app when running with remote
Change-Id: Idf299a0b28b77a3372db20ccb0f80512422e601a
Reviewed-on: https://go-review.googlesource.com/c/162138
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-02-13 01:59:56 +00:00
Ian Cottrell
44bee7e801 internal/lsp: changing server noun to serve verb
Also adding in --remote support and using it to implement the equivalent
functionality of the external forward command
Also adding in --listen as a replacement for --port as it is more flexible,
specifically it allows localhost:port which
is helpful in environments where opening remotely accesible ports is
problematic.

Change-Id: I5de1cea7dd6f1ee46e7423f3be2a4caca6f040b2
Reviewed-on: https://go-review.googlesource.com/c/161658
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-02-11 22:49:14 +00:00
Rebecca Stambler
40960b6deb internal/lsp/cmd: fix a nil pointer and some minor clean-up
This change fixes a nil error, in addition to cleaning up a spacing
error and a typo. It also fixes the golint errors in internal/lsp/cmd.

Updates golang/go#30091

Change-Id: I24867bb878fda4e341f87d31bbec701a3814a341
Reviewed-on: https://go-review.googlesource.com/c/161220
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-06 04:15:39 +00:00
Ian Cottrell
067a2f313b internal/lsp/cmd: add the definition mode
Change-Id: Ib171016fb1bb063a6424677458b554a08144465c
Reviewed-on: https://go-review.googlesource.com/c/159438
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-31 16:39:42 +00:00
Rebecca Stambler
b258f6da23 cmd/gopls: rename "golsp" to "gopls", as in "Go Please"
Change-Id: Ie5688759ce21bffa6745eb86ef3606639e3ce335
Reviewed-on: https://go-review.googlesource.com/c/158197
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-16 23:16:16 +00:00
Rebecca Stambler
fc1d57b08d cmd/golsp: add a debugging tool to connect with golsp on a port
This change allows golsp to be run on a port, with an intermediary
command passing the data through. This allows for improved logging.
Also, add necessary changes to VSCode integration to allow changing the
name of the command for golsp.

Change-Id: I20dca1a50296636e57e022342ee70f0610ad1531
Reviewed-on: https://go-review.googlesource.com/c/157497
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-11 21:44:48 +00:00
Emil Hessman
d345f29b0d internal/lsp: fix typo
Change-Id: I04164ea5b57ebb828ecb837caa397c9e736f4d57
Reviewed-on: https://go-review.googlesource.com/c/156457
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-07 03:02:06 +00:00
Ian Cottrell
a072e66104 internal/lsp: refactor the command line handling
This switched the golsp binary to support a sub-command model so it can grow
some guru like command line query capabilites

Change-Id: I1a7a49bb17701e62004bba636d6bee9de2481ffd
Reviewed-on: https://go-review.googlesource.com/c/154559
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2018-12-17 23:08:30 +00:00