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

3143 Commits

Author SHA1 Message Date
Ian Cottrell
0c752f569a internal/lsp: fix utf16 conversion for end of file cursor
Also remove error case that can no longer happen and the related test.

Fixes golang/go#31341

Change-Id: I534956f6e835dea4334b68d0ad0297cf93920af2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173960
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:14:49 +00:00
Ian Cottrell
b5495a5ed7 internal/lsp: extensive utf16 tests
Based on the work Paul Jolly did in https://go-review.googlesource.com/c/tools/+/173797
but not as internal tests and with a mildly obsessive attention to coverage.
Also has a failing test for golang/go#31341 that you can enable with -b31341

Change-Id: I528eee5304cd7191eafd3bcddb2f636c8722846f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173978
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:14:35 +00:00
Rebecca Stambler
079ac3a490 internal/lsp: handle error from runAnalyses
Change-Id: I73062bd3b4db8f238f009b8c8f3786c39c5d0d54
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173957
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-25 22:07:02 +00:00
Jay Conrod
2d660fb8a0 go/packages/packagestest: fix GOPROXY file URLs for Windows
Amends prematurely submitted CL 173918. We now use file:/// URLs for
go1.13 and later and file:// URLs for go1.12 and earlier.

Fixes golang/go#31675

Change-Id: I009c63a900bdfd091bf46def5cea5a0843639b47
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173919
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-25 21:41:24 +00:00
Muir Manders
e54115a062 internal/lsp: fix stuck diagnostic messages
The "analyses" cache in lsp/cache.(*Package).GetActionGraph was not
getting cleared on errors. This could result in future calls to
GetActionGraph waiting on the "ready" channel indefinitely. This in
turn caused the goroutine in cacheAndDiagnose to block indefinitely
and never send the diagnostic results back.

Now we use a defer statement to always close the channel. If we did
not succeed, we also clear out the cache entry and set a "succeeded =
false" flag to signal waiters that they need to retry. If in the
future errors other than context.Canceled/Timeout are possible, this
retry behavior may need to be revisited.

Fixes golang/go#30786

Change-Id: Icacc9188f1500b00f2178521ce373a2c1363f932
GitHub-Last-Rev: 7c43afd4286a69b0d35a625716e6934c72c4cef5
GitHub-Pull-Request: golang/tools#91
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173977
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-04-25 21:19:06 +00:00
Rebecca Stambler
bb8aefc696 internal/lsp: return errors when we can't find a package
This will allow us to surface these errors as diagnostics.

Change-Id: Ic8ad11ba43c08be6f391c0e2aa95015183461133
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173780
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-04-25 18:52:35 +00:00
Muir Manders
45abd40133 internal/lsp: introduce snippet builder object
*snippet.Builder helps you construct lsp completion snippet strings.
It handles escaping for you, and it gives a convenient interface for
writing nested placeholders.

Note that the builder does not support snippet "variables" or
associated features. They add a lot of complexity and don't seem very
useful at this point (plus they aren't supported in many editors).

Change-Id: I492ab2f6f0e08ed952154cbc0a17c86f32abf40a
GitHub-Last-Rev: 35a3f5d1cd0b6fda81b2c942a02aa1bd25c90acd
GitHub-Pull-Request: golang/tools#90
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173661
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-25 18:37:29 +00:00
Jay Conrod
31fd60d6bf x/tools/go/packages/packagestest: fix GOPROXY file URLs for Windows
On Windows, file URLs should look like file:///C:/foo/bar instead of
file://C:/foo/bar. In the latter case, the "C:" is parsed as the host.

Updates golang/go#31675

Change-Id: I7f75be44dd5d289de3ffdbd20a78130ed03cd233
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173918
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-25 16:32:42 +00:00
Reilly Watson
36563e24a2 cmd/vet: verify potentially-recursive Stringers are actually Stringers
The printf recursiveStringer check was checking for a function called String(),
but wasn't checking that it matched the actual function signature of Stringer.

Fixes golang/go#30441

Change-Id: I09d5fba035bb717036f7edf57efc63e2e3fe51d5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/164217
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-04-25 15:00:28 +00:00
Than McIntosh
9e44c1c403 go/internal/gccgoimporter: update package to match std lib version
Import changes from std lib version, specifically

      https://golang.org/cl/173440

which rolls out a more robust fix for issue 31540.

Updates golang/go#31540.

Change-Id: Ibeeb00ffd0ee6456d50fd4a243a1162f3940ad68
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173777
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-25 00:10:55 +00:00
Rebecca Stambler
1e8e1cfdf9 internal/lsp: handle completion after defer, go statements
This change adds support for completion of incomplete selectors after a
defer or go statement. We modify the AST before type-checking it with a
fake *ast.CallExpr.

Updates golang/go#29313

Change-Id: Ic9e8c9c49aa569cd7874791692c70a28c3146251
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172974
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-24 22:01:01 +00:00
Muir Manders
3e93b52866 internal/lsp: suppress more completions in comments and literals
Completion suppression in comments wasn't working for comments in
switch case statements, select case statements, and decl statements.
Rather than adding those to the list of leaf ast.Node types to look
for, we now always check if the position is in a comment. This fix
broke some completion tests that were using re"$" since "$" matches
after the comment "//" characters.

We now also don't complete within any literal values. Previously we
only excluded string literals.

Change-Id: If02f39f79fe2cd7417e39dbac2c6f84a484391ec
GitHub-Last-Rev: 7ab3f526b6752a8f74413dcd268382d359e1beba
GitHub-Pull-Request: golang/tools#88
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173518
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-04-24 20:52:08 +00:00
Dominik Honnef
cb2dda6eab go/packages: deduplicate file parsing
When loading packages from source, many files are being parsed
repeatedly, for example due to test variants. While the median number of
times a file gets parsed is 2, it is significantly higher (up to 28
times) when parsing the standard library, because of test variant
shenanigans.

By caching file contents and their parsed representations we can cut
down on processing time and garbage produced. When loading individual
packages or 3rd party projects, the effect is rather small. However when
loading the entire standard library, the effect is substantial.

name       old time/op    new time/op    delta
Jaeger-8      2.95s ± 7%     2.84s ± 8%     ~     (p=0.089 n=10+10)
Std-8         4.96s ± 7%     4.23s ± 3%  -14.62%  (p=0.000 n=9+9)
Strconv-8     892ms ±34%     877ms ±21%     ~     (p=0.853 n=10+10)

name       old alloc/op   new alloc/op   delta
Jaeger-8     1.22GB ± 0%    1.21GB ± 0%   -0.84%  (p=0.000 n=10+10)
Std-8        2.57GB ± 0%    2.20GB ± 0%  -14.61%  (p=0.000 n=10+8)
Strconv-8     201MB ± 1%     200MB ± 1%     ~     (p=0.105 n=10+10)

name       old allocs/op  new allocs/op  delta
Jaeger-8      12.7M ± 0%     12.4M ± 0%   -1.82%  (p=0.000 n=9+10)
Std-8         26.4M ± 0%     17.3M ± 0%  -34.62%  (p=0.000 n=9+9)
Strconv-8     1.94M ± 0%     1.91M ± 0%   -1.50%  (p=0.000 n=10+10)

When loading std, peak RSS decreases from 1.96 GB to 1.57 GB.

While we're here, we simplify our ParseFile implementation. The contract
of ParseFile specifies that implementations must use src for parsing,
and use filename only for display purposes. As such, we mustn't ever
call it with a nil src, making the check for a nil src in our own
implementation superfluous.

Change-Id: I33daac20fc52ccdb3187a336633f712d01b71d86
Reviewed-on: https://go-review.googlesource.com/c/tools/+/171377
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-04-24 03:11:03 +00:00
Zac Bergquist
f62e16ca41 internal/lsp: make interface methods children of the interface symbol
Change-Id: I8dbb1400a228ea077f63c2c48f8dba0ac93990d2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173237
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-04-24 02:46:01 +00:00
Rebecca Stambler
4bf14f7f06 internal/span: fix off-by-one in ToUTF16Column
Change-Id: I8c8344046b13f2606d7257ef8632e0426e15a85b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173498
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-24 02:45:18 +00:00
Rebecca Stambler
e58f34171d internal/lsp: add more error propagation and logging for analyses
This change propagates more errors from analyses, instead of just saving
them in act.err, we actually return immediately. Ultimately, we'd want
to return to the previous behavior, but this will help us figure out
what's going wrong.

Updates golang/go#30786

Change-Id: I9d3288fd113c43775140e5c008e3e300b6d28c2a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173497
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-24 02:44:48 +00:00
Rebecca Stambler
bb3b3ca95a go/packages: add some documentation for extractPackage
Change-Id: I68d4824157d389c0f08e871eec2b594f52717bae
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173478
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-04-24 02:43:44 +00:00
Jay Conrod
15bbd99efc all: run go mod tidy
This adds golang.org/x/sync.
Needed by golang.org/x/tools/internal/lsp/source.

Change-Id: Id42e597be74ed6cb1b7c30c172c5efb3f1c0f2b1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173481
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-23 23:23:28 +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
2acd0f4c51 internal/lsp: adding golden file support to the test harness
Also convert the format tests to use it. This means that the build bots no
longer need to run gofmt.

Change-Id: I5cb9d239183b17d81fdb00b38e9099d224c07e6a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172973
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-23 21:54:59 +00:00
Jonathan Amsterdam
fe54fb3517 apidiff: represent a Report as a list of Changes
Modify the Report representation to be a list of Change values,
instead of two string slices.

This will enable adding more information to each change, like source
location.

Change-Id: Ia7389d7bc552479ea5e06efd7fdefe004058e66f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172777
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-04-22 23:39:26 +00:00
Rebecca Stambler
c6b416e8a4 internal/lsp: add more error handling to analysis
Updates golang/go#30786

Change-Id: Icf054b9bcd62b36e3aa55288946a9f0d1c845300
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172972
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-22 21:49:46 +00:00
Rebecca Stambler
3ff669b183 internal/lsp: add check for nil package
Fixes golang/go#31604

Change-Id: I60ec000d505c64783e5f51f62d168dc31c2fbe19
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172968
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-22 21:23:51 +00:00
Rebecca Stambler
1e2181f3f4 internal/lsp: add additional debug logging for diagnostics
This change adds detailed debug logging for lsp.Diagnostics. This is
necessary for further investigation of cases where diagnostics aren't
propagated after a "didChange" request.

Updates golang/go#30786

Change-Id: I30eabf5a1cb17d4538a8860310b450494626b76f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172971
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-22 21:11:31 +00:00
Koichi Shiraishi
61c0d37527 internal/lsp: fix typo on 'textDocument/foldingRange' method
LSP specification define 'foldingRange', not 'foldingRanges'.
Just trims end of 's' and rename interface method name.

ref: https://github.com/Microsoft/language-server-protocol/blob/gh-pages/specification.md#folding-range-request-leftwards_arrow_with_hook

Change-Id: Ie2a91f6c0bdd99b8ae9000ba87c24118b264b934
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173079
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-22 18:44:13 +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
micnncim
75f23652ec internal/lsp: fix query cmd usage
`query` usage has the following duplicated description.

```
Usage: query [flags] query [flags] <mode> <mode args>
```

```
$ gopls query
query: query must be supplied a mode
answer queries about go source code

Usage: query [flags] query [flags] <mode> <mode args>

The mode argument determines the query to perform:
  definition : show declaration of selected identifier

query flags are:
  -emulate string
        compatibility mode, causes gopls to emulate another tool.
        values depend on the operation being performed
  -json
        emit output in JSON format
```

Change-Id: Ib511b6c77d8b6dc8148ca46f88a1a133d21ba25c
GitHub-Last-Rev: a022377913fec65482a26e61a2b22927de7d4132
GitHub-Pull-Request: golang/tools#85
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173098
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:03 +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
Rebecca Stambler
9eb0fb1732 internal/lsp: support comments on hover for typenames, funcs, fields
This change adds support for showing documentation when hovering over any
named type or function. For now, we show the entire comment associated
with the type; in future CLs, we should refine our approach and perhaps
only show the first line or sentence.

Updates golang/go#29151

Change-Id: Ib33284747b19acba67d79fb55c916574c3dd8073
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172958
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-22 16:38:38 +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
Than McIntosh
685fecacd0 go/internal/gccgoimporter: update package to match std lib version
Import changes from std lib version, specifically

  https://golang.org/cl/172603
  https://golang.org/cl/165739

which contain to a fix for reading of import data as
well as a couple of new test cases.

Updates golang/go#31540.

Change-Id: Iecb1a5a5a7bf100b2ebb871196868e96b1a50611
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173037
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-20 00:05:08 +00:00
Rebecca Stambler
c39e7748f6 internal/lsp: add type to placeholders in completion parameters
Fixes golang/go#31547

Change-Id: Ib6e54ae17c778421a49f34d3c60d56b126419a91
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172666
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-19 19:58:23 +00:00
Rebecca Stambler
f939817187 internal/lsp: add an additional check to ToUTF16Column
This change will at least stop the panic from occurring.

Updates golang/go#31341

Change-Id: I6b06941cfb6c020d2b37813573cb0dc068d54e65
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172667
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-19 19:37:30 +00:00
Rebecca Stambler
4796d4bd3d internal/lsp: use ast.Nodes for hover information
This change associates an ast.Node for some object declarations.
In this case, we only handle type declarations, but future changes will
support other objects as well. This is the first step in adding
documentation on hover.

Updates golang/go#29151

Change-Id: I39ddccf4130ee3b106725286375cd74bc51bcd38
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172661
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-18 23:52:43 +00:00
Rebecca Stambler
6732636ccd internal/lsp: use strings.EqualFold instead of ==
Change-Id: I34dc519f25fa976a959a749d4e1a525f5480b963
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172664
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-18 15:28:51 +00:00
Rebecca Stambler
a5870b4038 internal/lsp/protocol: add a compare function for span.URI
Add an additional check to handle URI comparisons. This fixes Hover on
Windows.

Change-Id: Ibfc816f1ec374144377a873c5b52867fafa3d7e8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172659
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-17 22:30:02 +00:00
Ian Cottrell
183b688ac4 internal/lsp: add compare functions for spans
Needed in order to sort lists of spans for stable tests, also used for span
equality tests.

Change-Id: Id2bedff4d7136494e2302c02bcb9bdc662ccfeb1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172660
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-17 22:21:04 +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
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
Rebecca Stambler
780da32332 internal/lsp: trigger signature help after completing a function
Change-Id: Ib0ee79a11dd828c77bdf22a19a24ed9d883d8393
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172600
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-17 21:12:31 +00:00
Rebecca Stambler
34437f544f internal/lsp: refactor server.go to separate into LSP categories
This change separates the different behaviors of server.go by the
categories defined in the spec. This allows us to differentiate more
easily between the language features and the text synchronization code.

I also renamed the "Symbols" function to "Symbol", which fits with the
specification
(https://microsoft.github.io/language-server-protocol/specification#workspace_symbol),
and makes clearer the distinction between DocumentSymbols and Symbol.

Change-Id: I926b8a772c478f6ae426352fb12dc4403f0e736a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172637
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-17 20:54:51 +00:00
Rebecca Stambler
6149f385e4 internal/lsp: reply to shutdown request
Fixes golang/go#31333

Change-Id: I5cb40baee49c4b1644df5612c977ab1d71942022
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172639
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-17 20:25:44 +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
35716ff3bc internal/lsp: set the diagnostic source earlier
We now set the diagnostic source in the diagnostics call rather than when
converting it to the LSP protocol.

Change-Id: Ic762aaab1b2bf93b75c4c3d78aa84e2f918398fc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172408
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:43 +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
Rebecca Stambler
dd61c98fae internal/lsp: run source.organizeImports on all codeActions
This change addresses the additional information we received in
https://github.com/Microsoft/language-server-protocol/issues/726.

Fixes golang/go#31359

Change-Id: Ied7c97ac1f9e429e28cc44563b93acabd80921a3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172406
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-16 21:54:00 +00:00