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

1040 Commits

Author SHA1 Message Date
Daisuke Suzuki
6e8b36d2c7 internal/lsp: add support for workspace symbol
This change adds support for the LSP workspace/symbol. Unlike
documentSymbol, the target is symbols that exist not only in a specific
file, but also in the current or imported packages. It returns symbols
whose name contains the query string of the request(case-insensitive),
or all symbols if the query string is empty.

However, the following is not implemented:
- Setting of deprecated and containerName fields in SymbolInformation
- Consideration of WorkspaceClientCapabilities
- Progress support
- CLI support

Updates golang/go#33844

Change-Id: Id2a8d3c468084b9d44228cc6ed2ad37c4b52c405
Reviewed-on: https://go-review.googlesource.com/c/tools/+/213317
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-02-05 19:03:17 +00:00
Rohan Challa
9e60d4e5b9 internal/lsp: continue diagnostics if diagnosing go.mod fails
This change ensures that diagnostics for .go files get calculated and published regardless of whether or not the go.mod file diagnostics fail. This change also updates lsp_test.SuggestedFix to make use of the snapshot.Diagnose function vs the source.FileDiagnostics.

Change-Id: I54c35106b1701b54cca9a413edfb253f3c4c5ab7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217839
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-05 19:02:14 +00:00
Rebecca Stambler
67a4523381 internal/lsp: determine parse mode based on workspace packages
Our current invariant is that all workspace packages are parsed in full
mode, and all dependencies are parsed in exported mode. We can rely on
this, as well as the fact that workspace packages are set during
metadata loads, to reduce the amount of plumbing the mode requires.W

Change-Id: Ib9406ca3c0dc2c81c7ee3158407f28022924d4d0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217139
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-02-04 23:03:16 +00:00
Rohan Challa
7124308813 internal/lsp/tests: add severity parameter to @diag markers
This change will add another parameter to the diagnostic markers (@diag).

Change-Id: I69f4672e7d5417099c11d1a46d9bc45a4d1e5ecc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217719
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-04 19:24:00 +00:00
Rohan Verma
1cc6d1ef6c tools/gopls: add cmd support for prepare_rename
This change adds command line support for prepare_rename.

Updates golang/go#32875

Change-Id: I7f155b9c8329c0faa26a320abab162730a7916ad
GitHub-Last-Rev: 118e846420d7c56fbf0e4f416c8fd6a52e9638a8
GitHub-Pull-Request: golang/tools#188
Reviewed-on: https://go-review.googlesource.com/c/tools/+/207579
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-04 07:42:04 +00:00
Rebecca Stambler
59e246924e internal/lsp/cache: use snapshot ID and view folder in ModTidyHandle key
Just to be safe, the snapshot ID and view's folder should be enough to
uniquely identify the ModTidyHandle.

Change-Id: Ie3a0dc64bf16bcc8e4eb75af107481c07de81967
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217657
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-02-04 06:02:07 +00:00
Rebecca Stambler
35ac94b00d internal/span, internal/lsp: fix URI escaping
We had previously worked around a VS Code URI bug by unescaping URIs.
This is incorrect, so stop doing it and then add a specific workaround
just for that one bug.

Fixes golang/go#36999

Change-Id: I92f1a5f71749af7a6b1020eee1272586515f7084
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217599
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-02-04 00:54:49 +00:00
Heschi Kreinick
49e540660c internal/lsp/debug: serve cache entry counts
We seem to be leaking cache entries. A simple status page will help us
confirm that.

Change-Id: I485bfff6ebfb5d30655554487583e15a3f49f9a4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217597
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-02-03 22:21:18 +00:00
Rebecca Stambler
ab391d50b5 internal/lsp: don't show links in hover for test functions
source.Identifier previously was used for references and rename, so it
needed to take a package policy. Now, it's only used for definition and
hover, so it should always be the narrowest package handle. We can use
this fact to determine if the identifier is located in its declaring
package, and if that package is a test variant, we don't link to the
documentation on pkg.go.dev, since it doesn't exist.

Change-Id: I5686828858a3feafb8ff2e4c5964b562f66db9fa
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217137
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-02-03 21:56:10 +00:00
Rohan Challa
33212cd6a0 internal/lsp: aggregate diagnostics before publishing them
This change aggregates all the diagnostics before publishing them to the client. This also updates the lsp_test to use lsp.Diagnose vs source.FileDiagnostics, unless lsp.Diagnose doesn't return any results.

Change-Id: I39959b50af3f65fce5d8e15fb138ccc019ce8073
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217338
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-03 19:35:11 +00:00
Rohan Challa
a014e0aa6a internal/lsp: skip packages load for auxilary go.mod changes
This change will skip packages.load calls when a go.mod file changes if that go.mod file is not the go.mod file associated with the view.

Change-Id: I23a214a89203dd58417f3e2f69725ce3b669a5ca
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217238
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-02-03 17:58:37 +00:00
Rohan Challa
c4cbd3b08f internal/lsp: add diagnostics in .go files for missing deps in go.mod
This change adds diagnostics to imports in .go files that are missing the dependency in the go.mod file. The quick fix that adds the appropriate require statement is coming in a follow up CL.

Updates golang/go#31999

Change-Id: I314cdbe8e3dd27da744ca0391e7a6e5dc1ebaa77
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216277
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-03 17:57:15 +00:00
Rebecca Stambler
2de6fe5e3e internal/lsp: return error if there is no builtin package
When we stopped returning an error from awaitInitialized, we didn't
handle this case in LookupBuiltin.

Fixes golang/go#36975.

Change-Id: I9668a7148f60ca1f9cad953d46caf6ec5500541e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217399
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2020-02-03 17:52:18 +00:00
Peter Weinberger
6682176fbb internal/lsp: remove useless check
err must be nil, as the code checks in line 117.

Change-Id: I23d87bdc9489c9ed249bfa1ac61b1ed722121c6a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217402
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-03 17:13:28 +00:00
Muir Manders
6f24f261da internal/lsp/cache: refactor a few small things
In preparation for some meaningful changes, rework a few things:

- rename "fix" to "fixAST"
- separate "parseExpr" into "parseStmt" and "parseExpr"
- pull out "walkASTWithParent" function

Change-Id: If6c8a249441feda95704f37bc9bde3ef2b64cbd2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216481
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-03 02:30:11 +00:00
Muir Manders
bc0b458b10 internal/lsp/source: improve completion for "make()" args
Fix type inference to expect a type name for the first "make()"
parameter and an integer for later parameters. For example:

   // Previously we expected "[]int{}", now we expect "[]int".
   var _ []int = make(<>)

Note that we don't currently support actually completing to unnamed
type names like "[]int", but this improvement at least eliminates
nonsensical completion suggestions.

   // Previously we had no expectation, now we expect an int.
   var _ []int = make([]int, <>)

Change-Id: Ifd349767662ab6902d3a3ea9e52de7df70cb37c7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217310
Run-TryBot: Muir Manders <muir@mnd.rs>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ingo Oeser <nightlyone@googlemail.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-02 23:20:50 +00:00
Rob Findley
ecb101ed65 internal/lsp/debug: support dropping sessions and views
These functions were unimplemented.

Change-Id: Ie95ee4e99511e1e00689eefe6d97df0780b72d2f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217090
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-31 21:12:09 +00:00
Rob Findley
1baf5b43f6 internal/lsp/cache: add Env to debugView
Env is used in the debug template, but not available.

Change-Id: I8e270464aecd927bc553bfbf9e7c85a477833890
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217085
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-31 20:48:24 +00:00
Daisuke Suzuki
5dffee2a89 internal/lsp: change to helper.go to output a formatted file
Use format.Source before output.

Change-Id: I8504fc80defa77aeaab748b9dc65d6382da500a3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217177
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-31 20:35:38 +00:00
Rohan Challa
d6d1b0d853 internal/lsp/cache: add context cancellation check inside importerFunc
This change adds a check inside of the types.ImporterFunc to see if the context has been cancelled.

Updates golang/go#34683

Change-Id: I0f12da0f8158ecda0eec00150ed6ff772c2f89c3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217257
Run-TryBot: Rohan Challa <rohan@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-31 18:31:50 +00:00
Rob Findley
b4fe758a9b internal/lsp/source: don't allow mutating DefaultOptions
DefaultOptions was a value type, but held map values. This CL changes it
to a function that returns an Options value that has new instances of
all reference types. It would be better if this function returned a
pointer, but that change ended up being too large. I will need to
refactor handling of options later anyway, in order to support sessions
with differing options for golang.org/issues/34111.

This fixes a race in internal/lsp/tests: internal/hooks/analysis.go
mutates the Analyzers map.

See for example the trybots result at:
https://storage.googleapis.com/go-build-log/0d34f5f0/linux-amd64-race_4ecdf9c8.log

Change-Id: I41be450b590a3f3104ac9a1cb9cb312ea3ff7ff4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217077
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>
2020-01-31 15:48:08 +00:00
Daisuke Suzuki
097c1f2eed internal/lsp: fix typo
Change-Id: I2480725dc20f67bb0427c71dab83a0cbe72832a1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217178
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
2020-01-31 14:37:46 +00:00
Heschi Kreinick
b4207ef493 internal/lsp: use span.URI constructor everywhere
We should never be converting to a URI directly, in case it's encoded or
needs Windows-specific fixes.

Change-Id: I8af272f878e2e4faf428bd7b74b7cba4f65093a3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217086
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-31 00:08:51 +00:00
Rebecca Stambler
4e65565728 internal/lsp: set workspace packages during (*snapshot).load
We can assume that any package we load directly will be a package in the
workspace, so it's reasonable to set workspace packages at that point.
We're guaranteed not to directly load dependencies, or we may end up
with indirect dependencies in the go.mod file.

Change-Id: I5d406e54da2bc3278b139c75b436d111b5564418
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216726
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-30 00:17:45 +00:00
Rohan Challa
c8253cffe2 internal/lsp/mod: fix test that checks for unchanged go.mod
The test that checks to make sure a user's go.mod file does not change if tempModfile=true is not doing anything. At some point, the go.mod file to test added a go directive. This change removes the go directive from the go.mod file.

Change-Id: I1c4b6b326e99d8fec5c21ac779dcdcd73610f48c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216840
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-29 23:28:05 +00:00
Rebecca Stambler
8a05c59e79 internal/lsp/cache: move shouldLoad function to snapshot.go
Some housekeeping. The shouldLoad function doesn't actually make sense
in load.go.

Change-Id: Idcfade57ab853cdae809c688fa21026a0a432c60
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216727
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-29 22:51:48 +00:00
Heschi Kreinick
716555639d internal/lsp/cache: use telemetry logging for imports refresh
Any context that came in through the lsp protocol package will work, live or dead.

Change-Id: I7566ec07b09e1c8e54a5255ebda8553843cfe974
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216846
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-29 22:22:23 +00:00
Heschi Kreinick
ec2e11d257 internal/lsp/source: check cancellation before analysis
We check cancellation pretty early on in analysis, but not before we
read Options. Checking earlier avoids a race in the command tests.

Fixes golang/go#36699.

Change-Id: I557c0441d70c80e122655be00a03b47080ddb7f6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216844
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-29 21:19:39 +00:00
Rebecca Stambler
11f6c2ac6d internal/lsp/cache: delete a few unused functions
Change-Id: I723ae6d2676bdbb4cfc0fec339e87604a032e807
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216725
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-29 21:03:00 +00:00
Heschi Kreinick
e1fd5825ff internal/lsp/cache: handle invalid analysis Pos
The nilness analysis gives us diagnostics with invalid start Pos. We can
just ignore those and log them.

Add a missing error check while I'm in here.

Change-Id: I4a205f253a9e47ec1513ff6299479f52e414a48c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216724
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-29 01:28:57 +00:00
Rebecca Stambler
ae42f3cd5c internal/lsp: recover from a view initialization failure
If an orphaned file is used to recover a workspace package, we should
remove the initialization error and treat the view as correctly
initialized.

Also, stop caching metadata for packages with no files. We have no way
to invalidate it, and it's useless, so just re-load those files as
needed.

Fixes golang/go#36795.
Fixes golang/go#36671.
Fixes golang/go#36772.

Change-Id: I0aee5a43401517b6073d27136cca533160effef2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216637
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-28 22:02:46 +00:00
Rebecca Stambler
345141a368 internal/lsp: provide arguments deterministically to packages.Load
This is just to ensure that arguments are always ordered when passed to
packages.Load.

Change-Id: I2c74673eff31efc31854dc0d306809890f633789
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216600
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-28 00:22:43 +00:00
Heschi Kreinick
9ab2d800b2 internal/lsp/cache: handle go.mod conflicts in go list
The go command gets mad if go.mod has changed since it started, e.g.
because a new dependency was added by a concurrent go list call. Retry
loads if they hit a concurrency problem. See the comment for more
details.

Testing this is awkward. I ran a background script that constantly
modified the go.mod file and observed that gopls waited until it was
killed and then recovered.

Updates golang/go#36772.

Change-Id: I5636c99a5a94b415c4a6fbb71869b07e31d3fed0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216543
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-27 22:30:56 +00:00
Rohan Challa
dd312ab63b internal/lsp: surface missing dependencies for imports not in go.mod
This change sets up the infrastructure to surface the dependencies that are missing in a go.mod file. In a follow up CL, we will use these to add diagnostics to the imports of .go files telling the user to add the dependency to their go.mod file.

Updates golang/go#31999

Change-Id: I697df0d7c6eabfdc2f0c75cb36aa35794647fd13
Reviewed-on: https://go-review.googlesource.com/c/tools/+/214700
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-27 22:30:17 +00:00
Rebecca Stambler
0ac6790fc6 internal/lsp: only reload orphaned files that belong to the workspace
We were reloading all known files, which resulted in modifications to
user's go.mod files.

Change-Id: I14e86af896d1e75f3fdaaa00b9af8d7fb1d1e9e5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216542
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-27 21:51:55 +00:00
Rebecca Stambler
7736277c76 internal/lsp: remove shadow analysis from default suite
Mostly because I find it very annoying.
But I imagine lots of people shadow variables intentionally, and it's
very noisy.

Also, fix an error caught by the nilness check while I'm thinkng about
analyses.

Change-Id: I1867c8613194028815666efd879899bb5065c9d7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216541
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-27 21:40:33 +00:00
Heschi Kreinick
2b5094fbea internal/lsp/cmd: fix gopls check
The command line tool doesn't go through JSON RPC, so it retains type
information that's stripped in the tests. Cut the parameters down to
basic types manually for now. But I don't know why the command line
tests send RPCs if the real thing doesn't.

Fixes golang/go#36769.

Change-Id: I428b40478557ca35a7dae8d02bbcd990411f714f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216539
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-27 20:51:20 +00:00
Rebecca Stambler
ed30b9180d internal/lsp: don't show list errors unless necessary
The go/packages workaround to hide errors for overlay packages doesn't
seem to work well. It's easier to just hide list errors in gopls
diagnostics unless the package genuinely failed to type-check. Check if
the package has missing dependencies as an approximation of if it is
well-typed.

This required some additional special casing for the import cycle error
detection, which now causes them to have duplicate diagnostics. It's a
rare enough case that this doesn't concern me, but we should clean this
up at some point.

Fixes golang/go#36754.

Change-Id: If12c92fb9a0e0b69b711ae9a509ecb1b2a32255c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216310
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-27 19:59:09 +00:00
Rebecca Stambler
a644f81d5e internal/lsp: handle metadata reloads for ad-hoc packages
Now that we are reloading metadata for workspace packages by package
path, ad-hoc packages get their metadata reloaded incorrectly. If an
ad-hoc package has no metadata, reload it by reloading the entire
directory.

Fixes golang/go#36753

Change-Id: Ie440f6f76a220009d487b7ceadcf40594643e969
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216307
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-27 19:36:31 +00:00
Rebecca Stambler
ab094738a9 internal/lsp: fix active parameter for incomplete parentheses
I had originally thought I might be able to use exprAtPos for this,
which is why I ended up eliminating that function when I saw it only had
one use.

One test also had to change in order to fit better with the spec.
Specifically: "If [the active parameter is] omitted or the value
lies outside the range of `signatures[activeSignature].parameters`
it defaults to 0 if the active signature has parameters."

Fixes golang/go#36766.

Change-Id: I400d5b2db2985bfaa5efbcd91225151ca8b5f46a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216309
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-27 19:24:44 +00:00
Rebecca Stambler
0576458154 internal/lsp: log snapshot IDs, don't log context cancellation
Updates golang/go#36772

Change-Id: Id6f1be9511f37865d5c6efcff10230e03724b27d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216497
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-27 19:20:44 +00:00
Michael Matloob
f3a16861ae internal/lsp/source: add more go/analysis/passes analyzers to LSP's suite
The LSP already supports a bunch of analyses we have less confidence in
than the vet suite so we should add these too.

Updates golang/go#36639

Change-Id: Ifc37d09e3acd73de021be7b45b3d80fe8c00e0d7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215677
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-27 19:05:40 +00:00
Rebecca Stambler
4320446551 internal/lsp: permit renaming symbols declared in other packages
Also, add a test for it.

Fixes golang/go#36743

Change-Id: I750ea36189a4ec5c9dc8553e4739b0238c2b29c8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216306
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-27 18:56:10 +00:00
Rebecca Stambler
bcecb1fcc1 internal/lsp: return context cancellation from LookupBuiltin
Change-Id: If90d111fbe89d2be445b15ec3721d48280540de9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216305
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-27 18:55:29 +00:00
Peter Weinberger
91d59a9776 internal/lsp: upgrade to current version of LSP
There are a number of new RPCs, for CallHeirarchy, SemanticTokens, and
WorkDoneProgress. Some of the messages now have two slashes, like
'textDocument/semanticTokens/edits'. A few unused RegistrationOptions
are no longer present.

Only generated code has changed. There are no changes any other .go
code.

The typescript code needed a new heuristic for finding the RPCs

Change-Id: Ie6942abac3a0cd60e86afe3fdbc6f6b0e9b30cb0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216537
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-27 18:31:17 +00:00
Heschi Kreinick
8fe064f891 internal/lsp/protocol: actually handle cancellation delivery
CL 215738 didn't work because the canceller was embedded in the
serverHandler, which already had a Deliver method. Add it as an actual
handler instead.

Change-Id: I0c79f1bee67aa3b4da53d92547804de859f1938c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216303
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-24 22:04:29 +00:00
Rebecca Stambler
bdfa187a52 internal/lsp: remove the checkErrors command in internal/lsp/source
Now that the view can report its own validity, we no longer need to have
an extra function to handle that.

Change-Id: Icd22f9b08601bd0fe18be064c43d21be2d6782e7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216144
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-24 21:19:55 +00:00
Rebecca Stambler
e0332898b9 internal/lsp: push more build-specific logic into the view
The view should really be able to determine if it's valid, not the
source package. Expand moduleInformation to be buildInfo, and use it to
collect additional details.

Use this information to determine if we should load a view's
subdirectories as part of the initial workspace load. If a module is
initialized, we will recreate the view, so we should be fine. Not sure
what will happen if the directory is moved into GOPATH, but that should
be less of a concern (I think).

Fixes golang/go#35818.

Change-Id: Ic8ceedd37386b1653b8965c64d9ba8953778ab78
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216143
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-24 21:10:25 +00:00
Rebecca Stambler
e23f2f3ad7 internal/lsp: reload metadata for orphaned files
go/packages overlay handling only really works for contains queries
(file=), so our approach of reloading packages by package path (for
workspace packages) wasn't handling newly created packages that need to
be handled through overlays. Workaround this by reloading metadata for
individual files that are missing it by running extra contains queries
(only after the first metadata load for package paths). Be careful not
to reload the same file multiple times if the first load did not succeed.

Somewhat related, clear out `go list` errors in packages that go
through overlay handling, since they will often be rendered irrelevant.
I'm not sure if this is the right move, but if it's not, then we will
have to do extra work to disregard those errors in gopls.

Fixes golang/go#36661.
Fixes golang/go#36635.

Change-Id: Ib83cffcdf8a3e07da0f30e734d5e2c89691e1aba
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216141
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-24 20:59:04 +00:00
Rebecca Stambler
1b668f2091 internal/lsp: disable literal completion candidates for some clients
If a client doesn't support the snippet format in completion insert
text, they can't take full advantage of the literal completion
candidates. Disable it in those cases, and remove the setting in
internal/lsp/source/options.go.

Fixes golang/go#36655.

Change-Id: Ibc045a0f2945aab753b0187194a03d0c0398dba5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216299
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-24 20:07:20 +00:00