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

4322 Commits

Author SHA1 Message Date
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
Michael Matloob
73c4c875f0 go/packages: only run TestCgoNoSyntax when cgo is available
Fixes golang/go#36799

Change-Id: I3f2013891465bef1ef9a15097b3d4614b9856035
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216538
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-01-27 18:37:02 +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
Ainar Garipov
d33eef8e68 gopls/doc: document updating to an unstable version
Fixes golang/go#36751

Change-Id: Ib5036bcc1f8ee0ab11d9978eea597222e86cc085
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216437
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-25 22:37:03 +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
Peter Weinberger
3f4d10fc73 internal/lsp: small change to helper.go to use ast.IsExported
Use ast.IsExported instead of explicit code.

Change-Id: I1bfabb3c575debb699a51e38f502fcb99a081203
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216297
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-24 17:05:13 +00:00
Joel Sing
628e9aa307 go/analysis/passes/asmdecl: add support for riscv64
Updates golang/go#27532

Change-Id: I9598b610c0b6710644988e5cea7661b2681a0314
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216337
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-24 16:21:11 +00:00
Rebecca Stambler
e0a7ba33ca internal/lsp/cache: move mod-related functions and file
This is a pure move with no code changes.
Rename parse_mod.go to mod_tidy.go since it's changed a bit.
Move the modfile.go functions into view.go since (1) Heschi doesn't
like spreading methods into multiple files and (2) it only has 2
functions in it anyway.

Change-Id: If0d7e4b50ac22c57302d90d68c2181dbb3ca8b87
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216142
Reviewed-by: Rohan Challa <rohan@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-24 14:45:41 +00:00
Peter Weinberger
9778d966fa internal/lsp: generate boilerplate stubs for type Server
go generate server.go generates server_gen.go which contains 44 boilerplate
stubs implementing the LSP protocol. The Server methods are defined
in protocol/tsserver.go and implemented in the lsp package. server_gen.go
ties the two together.

The generator is in helper/helper.go, and described in helper/README.md.

Change-Id: I120bc658e55a91ec5b07c0c0cf8c188882f0be66
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215979
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-24 14:41:51 +00:00
Rebecca Stambler
5c352bb417 internal/lsp: stop returning errors when we can't find a snapshot
Change-Id: I319021a3339971809b6096b3271aa6b0d94ae336
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216139
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-24 02:10:10 +00:00
Rebecca Stambler
a4b4a6733a internal/lsp/cache: check go.mod even if tempModFile is false
Missed a pretty key case in CL 216138. Also, I accidentally made it pass
-modfile even when it's not supported.

Change-Id: Ia0d04be7e82b77e1ec3f57ee2fee04e8c14a7c90
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216140
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-24 01:37:08 +00:00
Heschi Kreinick
5ecc1643ff internal/lsp/cache: fix GOPATH vendoring
We treat package IDs and import paths as semi-interchangeable, which is
wrong when GOPATH vendoring is in use. The only place it hurts us is
during import resolution, which is fixed here. We should always have the
package loaded, so it's just a matter of finding it by searching each
possible vendor location.

Fixes golang/go#36155.

Change-Id: If789092d16fa3d3294b6d8a2bcb980264506c161
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215904
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-24 00:03:48 +00:00
Heschi Kreinick
ce9bf563f5 go/packages: fix GOPATH vendoring with overlays
When GOPATH vendoring is in effect, go list on an import path doesn't
work -- we have to find the right vendor directory and list that
instead.

Updates #36155.

Change-Id: If04f5bc15498a8f195fb3eb76c5a9f2f53c91804
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215903
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-24 00:03:16 +00:00
Rebecca Stambler
24841a4f5f internal/lsp: eliminate redundant view.ModFile function
view.ModFiles used to not return the real mod file, even if one existed.
Now, we construct view.moduleInformation even if -modfile isn't
supported.

Change-Id: I03faf2ea521c2f404d4e1ba47f71ae48f3cb08d9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216138
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rohan Challa <rohan@golang.org>
2020-01-23 22:07:07 +00:00
Rebecca Stambler
59ae353e8e internal/lsp: recreate the view when needed
If the initial workspace load fails (due to a lack of a go.mod file or
an invalid go.mod file), we should try to re-load as changes to the
go.mod come in. Rather than retrying within the view, we just drop the
view entirely and try to recreate it. This shouldn't lead to any
noticeable lag, as anything that has been cached can still be reused.

Fixes golang/go#36531

Change-Id: I6e157075e8b3665f0ceef35e051e56ac3c29f286
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216037
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-23 21:53:29 +00:00
Rebecca Stambler
e873952e15 internal/lsp: check that a file handle is unmodified before read
Address a lingering TODO. A FileHandle read should return errors if the
file has been modified on disk while in use.

Change-Id: I540de9bef575a9ca838f49500665a24b05b4f54c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215981
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rohan Challa <rohan@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-23 20:52:07 +00:00
Rebecca Stambler
219d3418f5 internal/lsp: batch file changes in didChangeWatchedFiles
Remove the special handling for go.mod file saves. This was only really
added to be extra careful, but our cancellation logic should cope with
this.

Fixes golang/go#31553

Change-Id: I0a69bcdeaf6369697e79aba4689a7b714484ccc2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215908
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-23 20:51:52 +00:00
Rebecca Stambler
e54d0edf47 internal/lsp: support batched on-disk changes in source.DidModifyFiles
We don't yet propagate these batched changes in text_synchronization.go,
but this is the next step in moving towards a batched approach.

Updates golang/go#31553

Change-Id: Id6496af9d5422cc50ccb995f81c71ec1886f965a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215907
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-23 20:28:28 +00:00
Rebecca Stambler
a356fb7f16 internal/lsp: support multiple URIs in (*view).invalidateContent
Caught a number of unused parameters along the way. Hopefully we can
eliminate the containsFileSave boolean soon, since it's a bit annoying
to have to send that through.

Updates golang/go#31553.

Change-Id: I94319d902d329c84cb1c0676322ac04541ad53a0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215906
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-23 20:19:14 +00:00
Rohan Challa
0043dadf92 internal/lsp: use x/mod to get edits for go.mod quick fixes
This change uses the wonderful functions from x/mod to get the proper edits for the quick fixes on a go.mod diagnostic. It also creates a goModData structure to hold the data thats gets passed into the various parse functions, this will help reduce the large function prototypes that can occur when we decompose the logic. It also refactors the Modfiles() function to return span.URIs vs FileHandles.

Change-Id: Ifa0896442650f2ddbd8fe98d8f231a9e94c3d042
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215097
Run-TryBot: Rohan Challa <rohan@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-23 20:18:34 +00:00
Rohan Challa
2b7b26d7b0 internal/imports: add buildflags to ProcessEnv
This change adds a buildflags variable to the ProcessEnv inside internal/imports. When you run go list with GO111MODULE=on to get information about the package you are in, it will add a go directive to your go.mod file if there is not one. With the tempModfile=on flag, there should be no changes to a user's go.mod file.

Updates golang/go#36247

Change-Id: I817e4c46b4f433d0665fcb7585fcdf4f87049a38
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215978
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-23 19:46:59 +00:00
Michael Matloob
45e69182d1 go/packages: fix doc for NeedExportsFile
It actually adds the ExportFile field on Package, not the ExportsFile
field. (The ExportsFile field, with an "s" doesn't exist).

Fixes golang/go#36302

Change-Id: I7f4d82f4d536078d2fa383e9a893a463c1926488
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215980
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-23 16:25:37 +00:00
Rebecca Stambler
593de60622 go/packages: handle an overlay edge case with test variants
As usual, in debugging the creation of a new file with gopls, I've
encountered a go/packages overlay bug. The issue is:

A file b/b.go with package name "b" exists on disk. A package
b/b_test.go with no content exists on disk. There is an overlay for
b/b_test.go that contains the package name "b". Running packages.Load
for file=b/b_test.go will result in a failure to load package b
[b.test]. This change adds this test to the go/packages tests.

This case is fixed by restricting the fallback logic in
runContainsQueries. We only attempt to construct an ad-hoc package if
the original package was returned with no GoFiles.

Also, a minor change to the gopls error parsing code that fixes a case
in which diagnostics were being sent without corresponding files.

Updates golang/go#36635.

Change-Id: I38680a2cc65ae9c3252294db6b942d031189faf5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215743
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-01-23 02:22:18 +00:00
Rebecca Stambler
ba161d9e22 internal/lsp: add tests for references includeDeclaration setting
Make sure to test both modes, as this is the second time we've
accidentally broken this.

Fixes golang/go#36598.

Change-Id: I3993af3d106b18c76c44ada558b2c6cd9cbfcf17
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215777
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-23 01:39:50 +00:00
Rebecca Stambler
18389cb1f4 internal/lsp: refactor (*snapshot).clone to handle multiple URIs
This is the first in a series of changes to batch file changes. First,
we have to support invalidating a snaphot with multiple files.

Updates golang/go#31553

Change-Id: I7cd83d9280e3274549a72393bb9010c47eb5dd1e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215902
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-23 01:31:03 +00:00
Heschi Kreinick
e0f1ed8c47 go/packages: refactor list driver
Many functions in the list driver took the Config and goInfo functions.
Consolidate into a state object and move most functions to methods on
it.

Rework asynchronous go command calls -- rather than always running them
and waiting for them to finish, run on demand and attach them all to a
Context that is cancelled when the function returns. This does risk
letting them run a tiny bit over, but it should be harmless, and it's a
lot easier to pass the right Context around than to try and wait for
everything.

Propagate errors that were previously swallowed. All the tests still
pass, and hopefully nobody is hitting the errors cases. If I'm wrong we
can start swallowing them again.

Tweak and reword various comments that I thought could be improved.

Change-Id: I78457dd5493de3e9cb97f17dfe222d7cc9a478e9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215938
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-01-23 00:24:11 +00:00
Daniel Martí
bf1340f18c cmd/stress: use an ellipsis when truncating output
While investigating golang/go#36664, the entire output of a failure
could get pretty long - past fifty lines of content. I was getting
confused as to why the output was being cut off.

I had to discard a number of theories (the test being buggy, my expected
output being wrong, etc) before I realised that something was truncating
the output for the sake of the reader.

Since that's what stress is doing, make it add an ellipsis character
too, to further hint to the user that the output is being truncated for
readability. Separate it with a newline to make it easier to notice.

Change-Id: Ie052c13bb48d6fd842d6054848161266d9ea17e6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215597
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-01-22 22:00:14 +00:00
Rob Findley
fb353ca402 internal/lsp/cmd: add a test for client logging
A new test is added to verify that contextual logs are reflected back to
the LSP client. In the future when we are considering servers with
multiple clients, this test will be used to verify that client log
exporting is scoped to the specific client session.

Updates golang/go#34111.

Change-Id: I29044e5355e25b81a759d064929520345230ea82
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215739
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-22 21:55:43 +00:00
Muir Manders
9bae6688e3 internal/lsp/source: support dereferencing for completion
In cases like:

    var j *int
    var i int = <>

We will now provide "*j" as a completion candidate.

Change-Id: I1d35c2dca4864f13f7534e15b17450d784985557
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215358
Run-TryBot: Muir Manders <muir@mnd.rs>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-22 21:43:17 +00:00
Heschi Kreinick
7b0c362a2f go/packages: remove named query
I removed the usage of this from goimports.

Change-Id: If10a5d6265e412e77f7b0a2671ee2106ee4abbf6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215937
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-01-22 21:16:38 +00:00
Rob Findley
0a06c69952 gopls/integration/govim: update to latest govim
Govim integration tests are now passing at govim HEAD + gopls HEAD, so
we should be able to start actively investigating any regressions on the
gopls side after this change.

Change-Id: Ibf50d7e42e19cfc80779691e2c42f643028b2e39
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215897
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-22 19:49:06 +00:00
vovapi
213b5e130a go/ssa: replace DefaultType with go/types.Default
Remove duplicate DefaultType and use go/types.Default instead.
DefaultTypes was moved to std repo in golang.org/cl/8530
and exposed in golang.org/cl/30715 .

The use of types.Default improves the package
by resolving UntypedRune to proper 'rune' named type instead of int32.

Removes TODO left by adonovan.

Change-Id: Ie1066ef5276115662c7f5cc4e8cfc20519358fde
GitHub-Last-Rev: 2ea227133440c831f11e1335a051cabbd9eff8f6
GitHub-Pull-Request: golang/tools#200
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215517
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-22 19:27:10 +00:00
Muir Manders
dc16b66866 go/ast/inspector: fix misnomer in callback signature
Invert callback return value name from "prune" to "proceed". As
documented, returning true from the callback causes Nodes and
WithStack to continue searching children, not to prune.

Change-Id: I4c10b0edfec507dcf947d47076e537ffa7f1a3f5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/212222
Run-TryBot: Muir Manders <muir@mnd.rs>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2020-01-22 04:22:41 +00:00
Emmanuel T Odeke
f88bd70502 analysis/passes: consolidate imports helper
Completes a TODO from CL 212920 to consolidate
all the sites that used a custom "imports" helper.

Change-Id: I4ad11a1d90d616102085dfe6f10578da22164e7c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/214857
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2020-01-22 00:26:20 +00:00
Rob Findley
78d067421b internal/lsp: remove the Context argument from NewSession
The passed-in Context is not used, and creates the illusion of a startup
dependency problem: existing code is careful to pass in the context
containing the correct Client instance.

This allows passing in a source.Session, rather than a source.Cache,
into lsp server constructors.

Updates golang/go#34111

Change-Id: I081ad6fa800b846b63e04d7164577e3a32966704
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215740
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2020-01-21 23:07:03 +00:00
Rob Findley
29f64efd55 internal/telemetry/log: correct the docstring for Error
Change-Id: I8077bbdd6f011087f7988fbf04c97c13575afec0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215741
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-21 22:25:47 +00:00
Heschi Kreinick
b3205ff6ff internal/lsp/protocol: handle cancellation delivery
$/cancelRequest is handled out of band in the Request flow, but was
allowed to continue down the Deliver chain. There's no sense in letting
downstream Handlers see it and try to reply like it was a normal
request.

Fixes golang/go#36662.

Change-Id: I8471ac0fdd4f2a08acd87d6e4b83c1f077eb8600
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215738
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-21 21:04:57 +00:00
Rebecca Stambler
fc669b13a2 internal/lsp: eliminate getFileLocked function
Apparently, the convention is to name something "Locked" if the
implementation is mutex is already locked when the function is called.

Turns out there were no callers of getFileLocked anyway, so just delete
that function and rename to getFile.

Change-Id: Ia7a9a620c3eb8eb0ce6b0a44ddb2ed62a604484d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215737
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-21 20:56:39 +00:00
Muir Manders
3e306b7b28 internal/lsp/source: rename "typeInference" to "candidateInference"
This is in preparation for inferring stuff beyond just the expected
candidate type.

Change-Id: I31be9c1e4c82d82b1ff848858042a5edf46594e3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215340
Run-TryBot: Muir Manders <muir@mnd.rs>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-21 20:43:48 +00:00
Heschi Kreinick
d456b1cd8c internal/imports: pass dummy source for completion functions
The goimports code tries to read source from disk if none is supplied,
but the completion functions don't need source. Pass a dummy slice.

Fixes golang/go#36671.

Change-Id: Ieecc9ee75d39f8f165c7b9764ff49c8334a7fcd2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215681
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-21 20:03:11 +00:00
Rebecca Stambler
62545537a9 internal/lsp: use correct file identities when computing diagnostics
CL 214586 switched to using URIs in error messages instead of file
identities. It wasn't fully correct because the reports were being
allocated for the file identities in the package handle (which may be
outdated).

Fixes golang/go#36601

Change-Id: I4fcfc02df74d94fff49540c784ef816c357e7232
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215680
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-21 20:00:43 +00:00
Rohan Challa
bd79bb77d6 internal/lsp/cache: create infra for caching go.mod diagnostics
This change creates the infrastructure for caching diagnostics. Right now it uses a naive key of the entire snapshot which does not really add any benefit from using the cache. It also moves some code from inside the internal/lsp/mod to internal/lsp/cache.

Updates golang/go#31999

Change-Id: I599ad281baa062448d33ca0ea88ae6e09e10d73e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215021
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-21 19:43:28 +00:00
Heschi Kreinick
9375b12bd8 internal/lsp/cache: fix mod file change check
The modfiles function only works with Go 1.14. When it is enabled,
it reenters the view, causing a deadlock. Stop using it, and move the
process env under a separate lock so to break the deadlock.

Change-Id: I34c528c2be1f32c06b423ead44e90155f60c2214
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215679
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-21 19:24:08 +00:00
Rob Findley
13c74800b9 internal/lsp/protocol: remove unused DocumentUri type
Change-Id: I8fbc8cbbb4e62c1eca4de767d054f5d098f27edd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215497
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-21 14:52:36 +00:00