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

3629 Commits

Author SHA1 Message Date
Rebecca Stambler
252024b829 internal/lsp: separate refactorings out of memoization CL
This change just separates minor changes made along the course of the
memoization CL out into their own change. This will clean up the diffs
in the memoization CL.

Change-Id: I7d59e05ba6472af5f1bf516b1e5b879a5815b9a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183250
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-25 16:04:30 +00:00
Daniela Petruzalek
a101b041de cmd/present: use unique key for destSlide in local store
We use a 'destSlide' entry in the local storage to keep presentation
and notes in sync while using '-notes' flag. This caused a name
collision if we had different presentations open at the same time.

This changes the 'destSlide' key in local storage to
'destSlide:<presentation-url>' to avoid collisions between different
presentations.

Fixes golang/go#24688

Change-Id: I4833fa83856a96b5978c09ed7e4360484ba4f109
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178659
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-06-24 22:21:33 +00:00
Dmitri Shuralyov
7f22187876 go/loader: document that package is deprecated
By now, go/packages is ready for widespread use and has obsoleted
go/loader. CL 141684 and CL 155237 removed warnings from go/packages
documentation. Add a deprecation notice to go/loader for visibility.

Modify the deprecation notice in other packages to be consistent with
the deprecation convention as documented at golang.org/wiki/Deprecated.

Change-Id: Iaa93205a6e5beb3ec95f87a6d9d42f0b8ffe8e80
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183418
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-06-24 19:02:45 +00:00
Rebecca Stambler
663943adaa go/packages: fix mistake for ad-hoc packages
Change-Id: I6247e0392a43cf4c4f4ded8446e045dfcd8e423d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183620
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-06-24 18:24:39 +00:00
Ian Cottrell
64633d5e86 internal/lsp: add telemetry stubs
This is designed to provide a compatible API to opencensus libraries while we
still cannot directly depend on it.
Most of this will be deleted again when we move the code over into the
sub-module.

Change-Id: I42b561f4f403c18cd22fb909b037f584ea90ad1b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183247
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-24 18:10:36 +00:00
Suzy Mueller
70d37148ca internal/lsp: update doc comments on rename
Replace doc comment text for the declaration of an identifier with the
new name.

This implementation is taken from golang.org/x/tools/refactor/rename.

Change-Id: Id1b80fad456646a46c8ae2caa4e8febf05aaf798
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183261
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-24 18:02:13 +00:00
Agniva De Sarker
8ea4f8e3e5 refactor/rename: remove extraneous space
Fixes golang/go#27573

Change-Id: I484878c612c50009316bc7d03e4157b455421236
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183577
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-24 15:07:48 +00:00
Rebecca Stambler
6e04913cbb internal/lsp: fix bug in creating token.Files
Change-Id: Ib133762b6848d78fd3d264b211b44b36316a551d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183260
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-21 19:58:16 +00:00
Suzy Mueller
1fa568393b internal/lsp: check for conflicts on rename
Before renaming a variable, check the package to make sure that this
renaming would not result in a conflict that could break the program.

All of the implementation is taken from "refactor/rename" with the
dependency on "go/loader" removed.

Change-Id: Ib0782ec8f247a6df1750f2c8213f69186699ce1a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183257
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-20 19:17:50 +00:00
Suzy Mueller
494e18b268 internal/lsp: send client expected rename provider
This change sends the expected boolean value for 'renameProvider'
to the client.

When a client does not send 'prepareSupport' in its initial
'initialize' request, the client expects to get a boolean value for
'renameProvider'. Since we do not yet provide prepare support, we just
set 'renameProvider' to true regardless of the value of prepareSupport.

Fixes golang/go#32703

Change-Id: I1103e51e1a2927b98aaedf2839996e9cd7f7cbcc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183259
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-06-20 18:21:41 +00:00
Muir Manders
431033348d internal/lsp: fix function value completions
Previously we would always expand *types.Func completion candidates to
function calls, even if the expected type matched the function itself,
not its return value. Now we check the function itself before we check
its return value. This fixes cases like this:

func foo() int { return 0 }
var f func() int
f = <foo> // now completes to "foo" instead of "foo()"

Also, *types.Var function values were never getting expanded to calls.
I fixed the completion formatting to know that both *types.Func
and *types.Var objects might need to be invoked in the completion
item. This fixes cases like this:

foo := func() int { return 0 }
var i int
i = <foo()> // now completes to "foo()" instead of "foo"

Change-Id: I8d0e9e2774f92866a3dd881092c13019fb3f3fd5
GitHub-Last-Rev: 7442bc84b5bbb86296289bbc745ec56a5f89d901
GitHub-Pull-Request: golang/tools#122
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182879
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-20 15:43:39 +00:00
Michael Matloob
e0e20f22c0 go/packages: trim errors returned by go list
go list sometimes sticks a leading newline in its error messages
have go/packages trim them until go list does the right thing

(of course, no one should depend on this behavior)

Fixes golang/go#32363

Change-Id: I6e145fb85bfc9d710c5f06146a64ec6919f59e36
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183258
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dominik Honnef <dominik@honnef.co>
2019-06-20 15:36:11 +00:00
Suzy Mueller
4adf7a708c internal/lsp: add identifier renaming
This change provides support to rename identifiers within a single
package.

The renaming is performed by finding all references to an identifier,
and then creating text edits to replace the existing text with the
new identifier.

Editing an import spec is not supported.

Fixes #27571

Change-Id: I0881b65a1b3c72d7c53d7d6ab1ea386160dc00fb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182585
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-19 21:54:42 +00:00
Muir Manders
22e91af008 internal/lsp: apply type modifiers to completion candidate
In situations like:

var buf bytes.Buffer
var w io.Writer = &b<>

if we want to complete to "buf" properly we need to apply the "&" type
modifier to buf's type of bytes.Buffer to see that it is assignable
to type io.Writer. Previously we applied type modifiers in reverse to
the "expected" type (io.Writer in this case), but that is obviously
incorrect in this situation since it is nonsensical to
dereference (the reverse of "&") io.Writer.

Change-Id: Ib7ab5761f625217e023286384c23b8c60e677aac
GitHub-Last-Rev: 4be528f2572c9c987334552e3f8a31d4eddce81a
GitHub-Pull-Request: golang/tools#121
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182598
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-19 20:27:14 +00:00
Suzy Mueller
b76e30ffa0 internal/lsp: fix references for type switch vars
Implicit local variables for type switches do not appear in the Uses
map and do not have objects associated with them.  This change
associates all of the different types objects for the same local type
switch declaration with one another in the declaration.

The identifier for the implicit local variable does not have a type but
does have declaration objects.

Find references for type switch vars will return references to all the
identifiers in all of the case clauses and the declaration.

Fixes golang/go#32584

Change-Id: I5563a2a48d31ca615c1e4e73b46eabca0f5dd72a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182462
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-19 18:18:01 +00:00
Michael Matloob
8b2b8cf54a internal/lsp: add a field on the package to store diagnostics
So we can surface their code actions later.

Change-Id: I735e5d025a1250861d49db227f5a79453f599140
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182837
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-19 16:20:43 +00:00
Michael Matloob
c152035a7b go/packages: support test files in overlays
Fixes golang/go#31542

Change-Id: I4dd303a43e16d301142010db5633e80e20cd2e76
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182583
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-19 16:19:40 +00:00
Henry Wong
bf5f34bf87 internal/lsp: remove the redundant Server.Run() call.
`go s.Run(ctx)` repeats `h(s)`.

Change-Id: I03ae6df64ad34194b8f46aabd0cf67e5a9e8c777
GitHub-Last-Rev: 3669875d72a196a8c84fb1709a7cf9f84fdbb688
GitHub-Pull-Request: golang/tools#105
Reviewed-on: https://go-review.googlesource.com/c/tools/+/179297
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-19 15:21:02 +00:00
Rebecca Stambler
04b924abaa internal/lsp: enable textDocument/didSave notifications
The previous change to handle didSave never actually was turned on
because you need to specify it in the server capabilities.

Change-Id: I5ce40b4270eda125e0af6accf144d2a96070238c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182777
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-18 23:32:49 +00:00
Ian Cottrell
ab136c9d47 internal/lsp: switching debug pages to not use the default mux
Change-Id: I270fd1d4d44986aed6655da93e7388628f7b8b9c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182467
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-18 23:29:48 +00:00
Rebecca Stambler
fdf1049a94 internal/lsp: determine diagnostics to show per-file, not per-package
Previously, if any one file in a package had a parse error, we would not
send type errors for any of the other files. Now we make this decision
per-file, so that, even if a file has parse errors, type errors in the
other files will be shown.

Fixes golang/go#32596

Change-Id: I086c04f0ec37cd1b33845153328faf368232d834
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182466
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-18 16:30:18 +00:00
Muir Manders
da514acc47 internal/lsp: suggest completions that satisfy interfaces
When checking if a completion candidate matches the expected type at
the cursor position, we now use types.AssignableTo instead of
types.Identical. This properly handles cases like using a concrete
type to satisfy an interface type.

Calling AssignableTo triggered some crashes related to the fake
"resolved" types we create. Their underlying type was nil, which is
not allowed. We now set their underlying type to the invalid type.

I've also rearranged things so expected type information lives in a
dedicated typeInference struct. For now there is no new information added,
but in subsequent commits there will be more metadata about the
expected type.

Change-Id: I14e537c548960c30e444cf512a4413d75bb3ee45
GitHub-Last-Rev: 7e64ebe32938562648938d7a480195d954b018f2
GitHub-Pull-Request: golang/tools#116
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182358
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-17 19:08:20 +00:00
Rebecca Stambler
1d40570c5c go/packages: fix support for ad-hoc packages to handle errors
This change retries the query even if go/packages returns an error, not
just an empty response.

This also fixes support for ad-hoc packages in gopls.

Change-Id: I7bc07c225568efd18f4e5759f7eb3c23cd12bfa4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182580
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-06-17 18:54:35 +00:00
Michael Matloob
6fea9ef05e go/analysis: add SuggestedFix to Diagnostic
This change is uploaded for discussion.

This adds a SuggestedFix field to Diagnostic that can be used
to prepare refactorings or to surface fixes for diagnostics
when they're shown by the LSP.

Change-Id: Icad3bb78540b55df1707955139c889f612d1084f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181941
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-17 17:13:25 +00:00
Michael Matloob
4bb205a206 go/packages: add support for file= queries on ad-hoc packages
This will do a go list using a filename directly if listing using
the directory failed.

Fixes golang/go#32587

Change-Id: Id9993968f0ebc18a455132e0f1468356416a66dd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182465
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-17 16:53:00 +00:00
Edward Muller
7653e6d3d5 internal/lsp/cache: fix ineffectual err assignment
The `if err :=` block creates a shadow err value that is then discarded
after the block.

Change-Id: I78f6a7298ac5d3d86ece056a9e328bcee9fdc683

Change-Id: I78f6a7298ac5d3d86ece056a9e328bcee9fdc683
GitHub-Last-Rev: 4bac8fb982fa3a0724206422b1a4dbc5e41c34a9
GitHub-Pull-Request: golang/tools#114
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181777
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-17 16:34:45 +00:00
linguohua
97de5656fd internal/lsp/diff: remove redundant memory allocate and copy operations in function 'shortestEditSequence'.
These redundant operations can cause more memory and cpu consumption.

Change-Id: I54e0e23a8d1079c7991f55c897c441566c5fb2d8
GitHub-Last-Rev: 13162aa1e88ff272738c6a6675010edd2140c8a4
GitHub-Pull-Request: golang/tools#120
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182478
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-17 16:22:25 +00:00
Rebecca Stambler
5aca471b1d internal/lsp: clear diagnostics when all files from a package are closed
This change clears diagnostics for a package when all files from that
package have been closed in the editor. This prevents the user from
seeing irrelevant diagnostics.

Change-Id: I63d337805835dc45086cfba684d810f86ade5655
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182463
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-14 20:56:25 +00:00
Edward Muller
6f0482744c internal/lsp/cache: fix nil check by adding missing "continue"
Without this accessing gof.ast.file.Pos() will panic if gof.ast.file is nil

Change-Id: I829f3667d201f026fcf0475f4fdabce0aced58f8

Change-Id: I829f3667d201f026fcf0475f4fdabce0aced58f8
GitHub-Last-Rev: 777c015d691bf0d14cab5bb0bca6749cc9bdf605
GitHub-Pull-Request: golang/tools#119
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182420
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-14 20:25:48 +00:00
Rebecca Stambler
9a3b5d688f internal/lsp: parse filenames only out of go list errors
This changes the packageErrorSpan function into the listErrorSpan.
Previously, this was causing the gopls-generated errors to get parsed,
which would result in attempts to send diagnostics for invalid filenames.

Fixes golang/go#32603

Change-Id: I7a54ed8884b78beb3f894598f18a24ed232f7412
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182460
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-14 19:27:58 +00:00
Rebecca Stambler
61e0f78580 internal/lsp: use the memoize package to get *token.Files
This change does not actually use the token handle for GetToken right
now, but implements the approach for memoizing *token.Files.

Change-Id: I75919f4e97abd6893b202c021adecd2c9dbfc2be
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182277
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-14 19:20:18 +00:00
Ian Cottrell
a82f0323a4 internal/lsp: block rather than reject when the message queue is full
Change-Id: Ic8d4a0a4abfed71fe9290e9aae4efd6ab55124d5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182458
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-14 18:56:17 +00:00
Rebecca Stambler
d1d6cdd8a6 internal/lsp: clear out missing imports set when we re-load package
This change ensures that we always populate a new set of missing imports
when we re-load a package. Otherwise, we might keep stale missing
imports around.

Change-Id: Id9b6b8201e3ed093a7b9ece97a81e298de612a5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182459
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-14 18:46:33 +00:00
Ian Cottrell
1edc8e83c8 internal/lsp: update analysis runner for new features
This adds support for the AllObjectFacts and AllPackageFacts features that were
added to the analysis library.
It also moves the list of analyzers to an exported global so it can be added to
easily.

Change-Id: Ibbe81b17b190d04a0e49510c23558430bc03ca70
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182177
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-06-14 15:20:01 +00:00
Tai
ed0dc45079 go/analysis/passes/composite: whitelist unicode.Range32
We already whitelist unicode.Range16. This CL whitelists unicode.Range32
also, to be more consistent.

Fixes golang/go#32507

Change-Id: I72a8cf7c63845510e51c7e6ebbd3b627ecb7e0da
Reviewed-on: https://go-review.googlesource.com/c/tools/+/180922
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
2019-06-13 20:42:42 +00:00
Ian Cottrell
149740340b internal/span: improve invalid uri message
Change-Id: Iaf4de4f3a3494868db130fe5fb6885fd28f2a4ea
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181684
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-13 16:13:34 +00:00
Peter Weinberger
027b3b4d7b internal/lsp/protocol: bring the code generating programs up to date
This is the typescript code that generates the current versions of
tsprotocol.go, tsserver.go, and tsclient.go.

Change-Id: If40cd7a46e5e7d646d99670da5e04831b6ddc222
Reviewed-on: https://go-review.googlesource.com/c/tools/+/180477
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-13 13:40:55 +00:00
Ian Cottrell
d4e310b4a8 gopls: adding the gopls module
Change-Id: I521ff33f8733a7d636b8ebc611715cb19e41bc83
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181946
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-12 23:27:58 +00:00
Ian Cottrell
10539ce303 cmd/gopls: preparing for v0.1.0
Change-Id: I6b749858cbba0ec300caa77426ba0ae69a97677d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181997
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-12 23:17:17 +00:00
Rebecca Stambler
59534d075a internal/lsp: use ids instead of package paths as map keys
This adds an IDs map to the metadata cache, which maps package paths to
IDs. This is only ever used by the Import function in the type checker.

Change-Id: I8677d9439895bc6cbca5072e3fa9fddad4e165d5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181683
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-12 18:00:59 +00:00
Koichi Shiraishi
028e009f40 internal/lsp: fix typo on license year
Change-Id: I3cd4a55c633fd7a154d35fd3669e13562295242b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181897
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-06-12 17:47:02 +00:00
Rebecca Stambler
7db4ac6d26 internal/lsp/debug: add newlines to debug messages
Change-Id: Ie8232bf857b8a277abb789e3788a6b6e12048731
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181938
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-12 17:36:44 +00:00
Rebecca Stambler
ecc01b7716 internal/memoize: document the complicated parts of the memoize package
This change is more of an exercise for myself to better understand the
implementation of the memoize package. It adds detailed documentation
for the get function in particular.

I also modified the tests to use a table-driven test format. I'm not
certain if this was the right approach (in case we want to add a
different type of test case in the future), but for now, it seems to
work fine.

Change-Id: I191a3b65af230e0af54b221c9f671582adec6c79
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181685
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-12 16:51:35 +00:00
Muir Manders
d73e1c7e25 internal/lsp: fix errors when adding new file to existing package
Previously when you added a new file to an existing package, the new
file would get stuck with the "no package for file" error until you
saved the file and then made changed a different file in the
package. There were two changes required to fix the errors:

First, we need to invalidate the package cache when a new file is
added to a package so that the package will actually re-parse and
re-type check. We now notice if file names changed when updating a
package's metadata and invalidate the package cache accordingly.

Second, when dealing with overlay (unsaved) files, we need to map
the *goFile to the package even if we fail to parse the
file (e.g. the new file fails to parse when it is empty). If we don't
map it to the package, the package won't get refreshed as the file is
changed.

Fixes golang/go#32341

Change-Id: I1a728fbedc79da7d5fe69554a5893efcd1e1d902
GitHub-Last-Rev: e7c3d4c1f8f73b12c87ee76d868cc04893e55808
GitHub-Pull-Request: golang/tools#111
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181417
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-11 22:22:05 +00:00
Rebecca Stambler
3c1b0c2805 internal/lsp: fix panic when file deleted
Change-Id: I6eb7e5ae7fb9de74d5a3fb42031adb4e933d99d8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181680
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-11 22:01:47 +00:00
Rebecca Stambler
6050b95026 internal/lsp: create types for package paths and IDs
This change replaces the strings that were previously used for both the
ID and package path fields. This is a precursor to the change that will
replace the uses of package path with package ID.

Change-Id: I353e98aedede9b85c7a183fdd49048ff43b1e26d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181757
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-11 21:58:02 +00:00
Ian Cottrell
d303ba255a internal/lsp: move the fixup and parallel limits into the main parse function
Previously these were only applied from inside parseFiles, which also made it
harder to refactor the remaining parse logic.
This theoretically means fixup is now called in more places than it was before,
but should cause no change in behaviour.

Change-Id: Ic6d006c1d36daca7514626653aaedf90d76e1d0f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181544
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-11 20:13:05 +00:00
Ian Cottrell
346706fc3d internal/lsp: memoize all the parsing
Change-Id: Ic7864a564f88b3fe0a421bb825b01d750610dee9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181119
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-11 20:12:58 +00:00
Ian Cottrell
ce2cddb08b internal/lsp: using memoize for all file contents
Change-Id: I7293bbcfea33c0df90f7b6df8e991aae9a03f2ab
Reviewed-on: https://go-review.googlesource.com/c/tools/+/180846
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-11 20:12:47 +00:00
Rebecca Stambler
5b939d657d internal/lsp: fix type checking for unsafe package
Change-Id: I229a9329f38b8fc7f38e964652c582858c4edb5b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181678
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-11 19:41:53 +00:00