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

73 Commits

Author SHA1 Message Date
Ian Cottrell
80b1e8742c internal/lsp: support dynamic workspace folder changes
This also required us to change the way we map files to a view, as it may change
over time.

Fixes golang/go#31635

Change-Id: Ic82467a1185717081487389f4c25ad69df1af290
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175477
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 21:22:50 +00:00
Ian Cottrell
490d13020f internal/lsp: switch golden files to use txtar
I was about to add some more tests and it caused a huge number of golden files,
which was hard to deal with. Now all the golden files are packed into a single
.golden archive in the txtar format.
I also changed the tagging key for hover results to use the marker name rather
than the line and column, as it makes it more stable against test data changes.

Change-Id: Iaa1f54ab55a41d380db67b9f6f928fa7a52d9a5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174877
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-08 14:59:27 +00:00
Ian Cottrell
3b6f9c0030 internal/lsp: add document link handling for import paths to godoc
Change-Id: Ib2eef50047dfcc64110c264e77d648f959613b88
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173698
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-03 18:56:57 +00:00
Ian Cottrell
2d28432af7 internal/lsp: first pass at some hover tests
This uses golden files to hold the hover text as they are no more fragile than
hard coding the text in the tests, and much easier to update.
We need a lot more tests, and ones with actual comments, but this is a start and
at least adds the machienery it would take.

Change-Id: Ia2f79257642759e4c2f972d4037f258134e0fb33
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174380
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-30 19:42:29 +00:00
Muir Manders
c6e1543aba internal/lsp: add struct literal field snippets
Now when you accept a struct literal field name completion, you will
get a snippet that includes the colon, a tab stop, and a comma if
the literal is multi-line. If you have "gopls.usePlaceholders"
enabled, you will get a placeholder with the field's type as well.

I pushed snippet generation into the "source" package so ast and type
info is available. This allows for smarter, more context aware snippet
generation. For example, this let me fix an issue with the function
snippets where "foo<>()" was completing to "foo(<>)()". Now we don't
add the function call snippet if the position is already in a CallExpr.

I also added a new "Insert" field to CompletionItem to store the plain
object name. This way, we don't have to undo label decorations when
generating the insert text for the completion response. I also changed
"filterText" to use this "Insert" field since you don't want the
filter text to include the extra label decorations.

Fixes golang/go#31556

Change-Id: I75266b2a4c0fe4036c44b315582f51738e464a39
GitHub-Last-Rev: 1ec28b2395c7bbe748940befe8c38579f5d75f61
GitHub-Pull-Request: golang/tools#89
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173577
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-29 17:59:36 +00:00
Rebecca Stambler
550556f78a internal/lsp/source: refactor completion
This change separates the completion formatting functions from the
completion logic. It also simplifies the completion logic by necessary
values per-request into a struct that is used throughout.

Change-Id: Ieb6b09b7076ecf89c8b76ec12c1f1c9b10618cfe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173779
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-28 02:47:24 +00:00
Muir Manders
49ba83114e internal/lsp: improve composite literal completion
When the value of a composite literal key/value pair was unparsable,
you were getting completions for the composite literal keys instead of
values. For example "struct { foo int }{foo: []<>" was completing to
the field name "foo". This was because the leaf ast.Node at the cursor
was the composite literal itself, and our go-back-one-character logic
was not happening because the preceding character's node
was *ast.BadExpr, not *ast.Ident. Fix by always generating the ast
path for the character before the cursor's position. I couldn't find
any cases where this broke completion.

I also added expected type detection for the following composite
literal cases:
- array/slice literals
- struct literals (both implicit and explicit field names)
- map keys and values

Fixes golang/go#29153

Change-Id: If8cf678cbd743a970f52893fcf4a9b83ea06d7e9
GitHub-Last-Rev: f385705cc05eb98132e20561451dbb8c39b68519
GitHub-Pull-Request: golang/tools#86
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173099
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-23 22:28:03 +00:00
Ian Cottrell
18110c573c internal/lsp: delay the running of gofmt until the test is running
Change-Id: I222c83313a6366367fbeb7ce7d08058968d3a08e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173340
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-23 21:55:36 +00:00
Ian Cottrell
7f54bd5c70 internal/lsp: extract the common test logic
Change-Id: I0a3e8a2837cdeefb3dbbe7b86ed75a32b321797e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172778
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-22 16:50:02 +00:00
Muir Manders
aa740d4807 internal/lsp: handle embedded struct pointer definitions
When jumping to definition of an embedded struct pointer, be sure to
unwrap the pointer type so you properly jump to the pointee type.

Also, fix jumping to definition of an embedded struct inside an
anonymous struct inside a struct. The embedded struct detection was
continuing too far and thinking it wasn't an embedded struct when it
saw the anonymous struct.

Fixes golang/go#31451

Change-Id: I96017764270712a2ae02a85306605495075d12e7
GitHub-Last-Rev: 9997f60855ebe37bcca2fecc1ba2a7b871f393d4
GitHub-Pull-Request: golang/tools#83
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172583
Run-TryBot: Paul Jolly <paul@myitcv.org.uk>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-20 18:18:00 +00:00
Ian Cottrell
afc68fbc60 internal/lsp: a cleaner way of doing overlays
Change-Id: I3ee053cfc4b63f54b9bf43d0ce6a2bae713e3a0d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172638
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-17 21:35:05 +00:00
Muir Manders
7e40e1726e internal/lsp: improve signatureHelp in various cases
- show signature for function calls whose function expression is not
  an object (e.g. the second call in foo()()). since the function name
  is not available, we use the generic "func"
- only provide signature help when the position is on or within the
  call expression parens. this is consistent with the one other lsp
  server i tried (java). this improves the gopls experience in emacs
  where lsp-mode is constantly calling "hover" and
  "signatureHelp" ("hover" should be preferred unless you are inside
  the function params list)
- use the entire signature type string as the label since that includes
  the return values, which are useful to see
- don't qualify the function name with its package. it looks funny to
  see "bytes.Cap()" as the help when you are in a call
  to (*bytes.Buffer).Cap(). it could be useful to include invocant
  type info, but leave it out for now since signature help is meant to
  focus on the function parameters.
- don't turn variadic args "foo ...int" into "foo []int" for the
  parameter information (i.e. maintain it as "foo ...int")
- when determining active parameter, count the space before a
  parameter name as being part of that parameter (e.g. the space
  before "b" in "func(a int, b int)")
- handle variadic params when determining the active param (i.e.
  highlight "foo(a int, *b ...string*)" on signature help for final
  param in `foo(123, "a", "b", "c")`
- don't generate an extra space in formatParams() for unnamed
  arguments

I also tweaked the signatureHelp server log message to include the
error message itself, and populated the server's logger in lsp_test.go
to aid in development.

Fixes golang/go#31448

Change-Id: Iefe0e1e3c531d17197c0fa997b949174475a276c
GitHub-Last-Rev: 5c0b8ebd87a8c05d5d8f519ea096f94e89c77e2c
GitHub-Pull-Request: golang/tools#82
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172439
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-17 18:10:49 +00:00
Ian Cottrell
7b3e515a8c internal/lsp: switch completion item tests to using the enum strings
Also change the enum values to match the prior string conversion routine.

Change-Id: I23ac6a72c8e116c5ee05e9324356481e519781e9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172410
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-17 17:57:43 +00:00
Rebecca Stambler
aa385af2d9 go/packages: add support for entire packages defined in overlays
This change adds support in go/packages for defining an entire package
in an overlay. We also add corresponding tests for this in gopls, to
confirm that it works as expected.

Fixes golang/go#31467

Change-Id: Iead203ab2964a7ac4f571be97624b725ac5de7e0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172409
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-17 17:55:51 +00:00
Ian Cottrell
4ca4b55e20 internal/lsp: make the symbols tests use the enum names rather than hard coding the values
this makes them less fragile, more portable and also more understandable.

Change-Id: Ife8a7ed76b7517eaae37bd3896fee87740ffb22a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172405
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-17 00:57:54 +00:00
Ian Cottrell
49a1609436 internal/lsp: cleanup the diagnostic and completion tests
this make the same kinds of changes I already made to the symbol tests,
to make the messages more detailed and remove the goto

Change-Id: I7cb27839b2ab696ad4e3d6537d91152e34fb1d89
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172477
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-17 00:57:32 +00:00
Ian Cottrell
e2848a0e7d internal/lsp: minor clean up of symbol tests
remove the goto and make it print more information about why the failed.

Change-Id: I2f5f3c7fe88eae6fe5de61c5d9b401797b6933b2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172404
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-16 21:24:14 +00:00
Rebecca Stambler
2e9de471eb internal/lsp: handle definitions for variables with error types
Fixes golang/go#31465

Change-Id: I2f79fe2167bab79b497125995efc938f2b63d274
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172117
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-15 20:59:51 +00:00
Ian Cottrell
744a51dd88 internal/lsp: normalise and make public diff<->edit conversions
This allows us to use the diff.ApplyEdits in tests, saving us from a different
implementation.
It also prepares for command lines that need to use diff features based on the
results of a protocol message.

Splitting content into lines is too easy to get wrong, and needs to be done
correctly or the diff results make no sense. This adds the SplitLines function
to the diff pacakge to do it right and then uses it everwhere we we already
doing it wrong.

It also makes all the diff tests external black box tests.

Change-Id: I698227d5769a2bfbfd22a64ea42906b1df9268d9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/171027
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-15 20:31:36 +00:00
Ian Cottrell
2b5498619e internal/lsp: Remove 1.10 compatability in tests
Change-Id: I6e136d8b3292c1bedfdbb294c0465689ad1ffafb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/171239
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-15 15:47:27 +00:00
Zac Bergquist
2538eef759 internal/lsp: enhance document symbols support
Make methods children of their receiver's type symbol.
Add struct fields as children of the struct's type symbol.
Also identify numeric, boolean, and string types.

Updates golang/go#30915
Fixes golang/go#31202

Change-Id: I33c4ea7b953e981ea1e858505b77c7a3ba6ee399
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170198
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-10 21:12:19 +00:00
Ian Cottrell
1bac838f5b internal/lsp: support multiple views
This uses the workspace folders to build multiple views, and then tries to pick
the right view to send each incomming request to.

Change-Id: I0cc896dbbc67eb0a88225ddeca6c518f4258bbba
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170179
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-01 20:12:29 +00:00
Rebecca Stambler
bf99c0974b internal/lsp: create the undelivered map
(for real, this time)

Change-Id: I563b7b34a1849914e9b922b07a86916bac7be30d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170183
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-01 19:21:32 +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
8889bfc21e internal/lsp: wire up configuration
This connects up the configuration message, and uses it to allow the client to set the environment
in the config passed to packages.Load

Change-Id: I75e03c01c74e9b11c8b4c47b9cbdd0574cddf778
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169704
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-28 21:16:46 +00:00
Zac Bergquist
8f05a32dce internal/lsp: correctly report interface symbols
Updates golang/go#30915

Change-Id: I9c5faa615df506cf1d015a9eb48196fa9b0387ee
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169682
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-28 03:05:05 +00:00
Zac Bergquist
ca36ab2721 internal/lsp: add support for document highlight
Change-Id: I232dbb0b66d690e45079808fd0dbf026c4459400
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169277
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-26 19:08:20 +00:00
Elias Naur
f0bfdbff1f internal/lsp,internal/lsp/cmd: skip tests on android
Change-Id: Idd9ddd32742a9f85096b71509511492b54538190
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167818
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-15 21:40:10 +00:00
Ian Cottrell
2f43c6d1a2 internal/span: change to private fields
Change span to hide its fields and have validating accessors
This catches the cases where either the offset or the position is being used
when it was not set.
It also normalizes the forms as the API now controls them, and allows us to
simplify some of the logic.
The converters are now allowed to return an error, which lets us cleanly
propagate bad cases.
The lsp was then converted to the new format, and also had some error checking
of its own added on the top.
All this allowed me to find and fix a few issues, most notably a case where the
wrong column mapper was being used during the conversion of definition results.

Change-Id: Iebdf8901e8269b28aaef60caf76574baa25c46d4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167858
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-15 18:05:47 +00:00
Marwan Sulaiman
f59e586bb3 cmd/lsp: skip completion in string literals
This CL ensures that a "." inside a string literal will return an empty
completion list.

Fixes golang/go#30477

Change-Id: I1442d0acab4c12a829047805f745c4729d69c208
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167857
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-03-15 16:51:35 +00:00
Rebecca Stambler
8781451fe3 internal/lsp: propagate errors from in diagnostics
An ignored error in toProtocolDiagnostics could result in empty
diagnostics being (incorrectly) sent to the user.

Change-Id: I34c86a1f5bbf28888bedad094f596cc27a52b86d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167714
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-15 04:33:14 +00:00
Ian Cottrell
dbad8e90c9 internal/lsp: convert to the new location library
This rationalises all the position handling and conversion code out.
Fixes golang/go#29149

Change-Id: I2814f3e8ba769924bc70f35df9e5bf4d97d064de
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166884
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-13 19:34:21 +00:00
Peter Weinberger
6a988fd03a tools/cmd/gopls: modify gopls to use automatcally generated types
Gopls presently uses hand-coded data types (in internal/lsp/protocol)
for communicating with LSP clients. Instead, modify it to use the
automatically generated file (internal/lsp/protocol/tsprotocol.go).

Replaced files have been put (temporarily) in a directory 'preserve'
so readers can compare the old data types with the new ones.

Change-Id: Idfa53a5783e2d6a47e03b20641dd76fbc2c32677
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166757
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-12 15:13:52 +00:00
Ian Cottrell
6eedde5c1d internal/lsp: using a non line based applyEdits in tests
Change-Id: Ibbef0a74b53a95d0b08fae6e8ef24be8b0f78273
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166881
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-11 21:20:53 +00:00
Ian Cottrell
de4a0b36f1 internal/lsp: allow end of file byte offsets
Change-Id: I46d7e07a4603f19f615fed2e37e733573ea0fe08
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166880
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-11 21:20:38 +00:00
Rebecca Stambler
00c44ba9c1 internal/lsp: add cache for type information
This change adds an additional cache for type information, which here is
just a *packages.Package for each package. The metadata cache maintains
the import graph, which allows us to easily determine when a package X
(and therefore any other package that imports X) should be invalidated.

Additionally, rather than performing content changes as they happen, we
queue up content changes and apply them the next time that any type
information is requested.

Updates golang/go#30309

Change-Id: Iaf569f641f84ce69b0c0d5bdabbaa85635eeb8bf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/165438
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-08 17:45:44 +00:00
Rebecca Stambler
d56157ae75 internal/lsp: remove handling for circular imports
Also, separate type-checking logic into its own file.
go/packages returns import cycle errors anyway, so we just return them instead.

Change-Id: I1f524cdf81e1f9655c1b0afd50dd2aeaa167bb2f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/165021
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-03-04 22:34:19 +00:00
Rebecca Stambler
f0a709d59f internal/lsp: set severity levels for compiler errors and vet checks
This change adds severity levels to source.Diagnostics, allowing us to
pass this information along to the LSP. This allows compiler errors to
show up in red, while vet results show up in green.

Change-Id: I2bc0b27ed6629f987c05affe00fdbe4b9bfb3b3e
Reviewed-on: https://go-review.googlesource.com/c/164299
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-02-27 23:25:17 +00:00
Yasuhiro Matsumoto
a24c58a209 internal/lsp: implement incremental updates to document
gopls return Incremental for TextDocumentSyncKind.

Change-Id: I7b302a540a4d2ef9eaa079cea5155859febb9a95
Reviewed-on: https://go-review.googlesource.com/c/162921
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-02-21 17:53:26 +00:00
Ian Cottrell
508f945e1a internal/lsp: change File.Read to a File.GetContent accessor
Like the previous change to the FIle interface, we treat Read as if it were an
accessor, we remember the content part but not the error part, and we may fill
it in asynchronously, so this change makes it explicit.
In the future we should probably trap the error in the read and push it back
through another channel though, it will be the root cause of later errors.

Change-Id: I3d374dd557178b4e8c5544813cd77f5c0faefe5b
Reviewed-on: https://go-review.googlesource.com/c/162403
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-02-14 04:36:41 +00:00
Rebecca Stambler
0e66cc6fab internal/lsp/diff: fix bug that adds extra line to files on format
Small changes to handle the last line in the diff library, LSP tests,
and diff to text edits conversion.

Fixes golang/go#30137

Change-Id: Iff0e53a04c2dabf6f54eb7c738b4c0837f16efba
Reviewed-on: https://go-review.googlesource.com/c/162217
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:28:36 +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
Michael Matloob
340a1cdb50 internal/lsp: copy fact support from go/analysis/internal/checker.go
This changes the analysis code from that which was in unitchecker.go
to that in checker.go, so we can run actions that get facts for dependencies
concurrently.

Adds the rest of the traditional vet suite to the LSP.

TODO(matloob): test that facts are actually propagated between packages

Change-Id: I946082159777943af81bcf10e503fecc99da521e
Reviewed-on: https://go-review.googlesource.com/c/161671
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-02-12 19:58:15 +00:00
Rebecca Stambler
3744606dbb internal/lsp: type-check packages from source
This change moves gopls from type-checking packages using the
go/packages API to type-checking from source. This is the first step in
adding caching to gopls.

Change-Id: I2a7dcfd8c9c0bfc6c35c86eadcdc6f9ce53d9be7
Reviewed-on: https://go-review.googlesource.com/c/161497
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-02-08 22:27:37 +00:00
Michael Matloob
a3f91d6be4 internal/lsp: add support for analyzers with dependencies on other analyzers
Steal alan's parallel analysis-graph-running code from multichecker.
Facts are still not supported.

Change-Id: I22f83375d7a314b49d4f458d6dd40c33febc795b
Reviewed-on: https://go-review.googlesource.com/c/161659
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-02-08 18:55:13 +00:00
Michael Matloob
a8576e2603 internal/lsp: connect basic analysis functionality
This starts hooking up the analysis framework into the LSP. It runs
the Tests analysis (which I think might be the only one that doesn't
need facts or results) and reports its diagnostics if there are
no parse or typecheck failures.

Next step: figure out how to pass through results.

Change-Id: I21702d1cf5d54da399df54437f556b9351caa864
Reviewed-on: https://go-review.googlesource.com/c/161358
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-02-06 21:48:25 +00:00
Rebecca Stambler
279ab8e001 internal/lsp, go/packages/packagestest: support testing test files
This change allows testdata files to be *_test.go files.

Change-Id: Ic771ea7c89ff2d2aabd1af8be56f9c7286da9053
Reviewed-on: https://go-review.googlesource.com/c/161317
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-02-06 04:07:32 +00:00
Rebecca Stambler
021ffbf1e9 internal/lsp: do not return nil identifiers without errors
Change-Id: I9ffc37dc07f46536a44f7173277d0374fdda1fb8
Reviewed-on: https://go-review.googlesource.com/c/160698
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-02-04 17:30:59 +00:00
Andzej Maciusovic
7414d4c1f7 internal/lsp: rank types higher when completing in return of a function
Completion now ranks type names higher for func receiver, type params and type results (e.g. func (<>) foo(<>) (<>) {}).

Fixes golang/go#29152

Change-Id: Icdd18b1b344c1cd617a4f45a7b071e53c1345478
GitHub-Last-Rev: e6acb1f2d2a7e571ffcecc500e407fdefd118fed
GitHub-Pull-Request: golang/tools#73
Reviewed-on: https://go-review.googlesource.com/c/159797
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-02-02 23:51:57 +00:00