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

3328 Commits

Author SHA1 Message Date
Michael Matloob
1a7b4747f5 go/packages: work around go list behavior for missing dependencies
If go/packages.Load tries to load a package with a missing dependency, it
should not return an error, but a package with an error set on it.  This is a
workaround for go list -e -compiled (or even just go list -e) returning a
non-zero exit status for packages with missing dependencies.

Change-Id: I2d7d848ae5133235f595baf7b30296077e891ee3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170891
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-28 14:28:31 +00:00
Brad Fitzpatrick
7be61e1b0e cmd/splitdwarf: fix skip on Windows
Unify the two files rather than have to maintain two copies of the
+build line.

Fixes golang/go#32212

Change-Id: I1f9ee4956183aa6248a5a2e83b5760d02532bacb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178699
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2019-05-25 14:57:41 +00:00
Rebecca Stambler
3d17549cdc internal/lsp: add modfile, sumfile structs, require Go files for diagnostics
This change adds a stub modFile struct for use in the future. It also
moves the singleDiagnostic function out into the lsp package, so that
the source package does not make decisions about what to show to the
user as a diagnostic.

Fixes golang/go#32221

Change-Id: I577c66fcd3c1daadaa221b52ff36bfa0fe07fb53
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178681
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-24 21:02:28 +00:00
Rebecca Stambler
d532c0723d internal/lsp: fix race condition in type-checking
Change-Id: Idff7cc3a28b4a03ce0d374c6c5035b51330143b1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178724
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-24 20:33:21 +00:00
Heschi Kreinick
d487f80763 all: GOSUMDB=off for tests that use fake modules
Users of packagestest will create modules that don't exist on the
Internet and can change. There's no point in checking sum.golang.org for
them under any circumstances.

Similarly for the various goimports tests.

Fixes golang/go#32216.

Change-Id: Id9a6b660564cb744530bf9d209fca19008fb9c4f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178722
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-24 18:48:02 +00:00
Ian Cottrell
2c0ae70061 internal/lsp: add file watching and use it to trigger invalidations
Change-Id: I6148539509364655e7d42044b73789870d30fbb6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178161
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-24 14:03:12 +00:00
Ian Cottrell
75713da896 internal/lsp: add a file system abstraction
Change-Id: Ie42835b835ed22fddbba187ab10d8c31019ff008
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178097
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-24 13:48:47 +00:00
Peter Weinberger
991f294999 internal/lsp: remove SelectionRange and textDocument/selectionRange
These are the latest changes to vscode-languageserver-node brought to Go.

Change-Id: I88d0b384356964c358cb2c51ea3b79cb6b51b434
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178357
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-24 12:55:31 +00:00
Rebecca Stambler
38d8bcfa38 internal/lsp: don't show diagnostics for mod files
The Go file changes didn't actually check the file extensions for the
files the Go extension is receiving. This error was not noticed because
the VSCode extension doesn't yet actually send mod files to gopls yet,
but it will in its next release.

Fixes golang/go#32178

Change-Id: Ia04d0a92ce7df13fcf4c601421bc000d69855f6d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178679
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-23 17:46:34 +00:00
Rebecca Stambler
521d6ed310 internal/lsp: re-run go/packages.Load when the package name changes
Fixes golang/go#32149

Change-Id: Ic02af6fd4fb19aae0d38a4d51ec4462abdc4f446
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178162
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-21 20:35:40 +00:00
Ian Cottrell
7927dbab1b internal/lsp: build the packages config on demand from proper configuration
This moves the fileset down to the base cache, the overlays down to the session
and stores the environment on the view.
packages.Config is no longer part of any public API, and the config is build on
demand by combining all the layers of cache.
Also added some documentation to the main source pacakge interfaces.

Change-Id: I058092ad2275d433864d1f58576fc55e194607a6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178017
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-21 17:12:43 +00:00
Rebecca Stambler
2c78df6d2c internal/lsp: log when we fail to type-check a package
Change-Id: I07a0a224359b698e50da8496b21634d8bd947aa9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178277
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-21 15:28:58 +00:00
Heschi Kreinick
26647e34d3 imports: allow nil Options in Process
Forgot this case in CL 175437.

Change-Id: I9825cf010611fed9f47b1a87fc793bf3a5a36f68
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178257
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-20 22:08:59 +00:00
Muir Manders
eda2c2f1ae internal/lsp: fix completion insertion with non-identifier suffix
Completions like "foo.Bar(baz.<>)" were replacing one too many
characters resulting in "foo.Bar(baz.Qux()". This is because the go
parser adds a phantom "_" identifier when parsing "foo.". We thought
the "_" was really there, so we were issuing text edits to replace
it. Fix by ignoring "_" selectors when the cursor is positioned to
their left.

Fixes microsoft/vscode-go#2525

Change-Id: I1233a9d6275e2a79b666ca0230862238160b4aab
GitHub-Last-Rev: de9a3f00187b1b9bfcc4e497461f4602ae6f8923
GitHub-Pull-Request: golang/tools#104
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178217
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-20 21:53:15 +00:00
Heschi Kreinick
0133cac317 cmd/goimports: reuse cached state
The internal imports API allows the user to control the lifetime of
caches, via the ProcessEnv object. Change the goimports command to use
the same cache for its lifetime. This should speed up goimports -w *.go
dramatically in cases where imports need to be added.

Change-Id: I01e3531ad53b038896435474ac9a8be97d5f3c10
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175448
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-20 21:49:40 +00:00
Heschi Kreinick
757ca719ca imports: rename to internal/imports
For various reasons we need an internal-facing imports API. Move imports
to internal/imports, leaving behind a small wrapper package. The wrapper
package captures the globals at time of call into the options struct.

Also converts the last goimports tests to use the test helpers, and
fixes go/packages in module mode to work with empty modules, which was
necessary to get those last tests converted.

Change-Id: Ib1212c67908741a1800b992ef1935d563c6ade32
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175437
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-20 21:49:35 +00:00
Rebecca Stambler
7e7c6e5214 internal/lsp: add nil checks for ASTs and token
Fixes golang/go#32120
Updates golang/go#32132

Change-Id: Ib4bb8a4818be7dec468c46b72afc3dd57b35f155
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178158
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-20 20:09:54 +00:00
Ian Cottrell
faf83c64e9 internal/lsp: fix race in delivering diagnostics to the command line client
Fixes golang/go#32091

Change-Id: I1399a596169384f48d9f2409988226708dcd3473
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177937
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-20 19:38:31 +00:00
Rebecca Stambler
9558fe4a78 internal/lsp: update column mapper with content on incremental changes
Fixes golang/go#32114

Change-Id: If2ffade3d8d1e026e3b0aa7f2c9db4dc46d7c8b2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178157
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-20 19:04:59 +00:00
Evan Digby
d88f79806b internal/lsp: fix swallowed package errors
If a package has an error that makes it completely unparseable, such as containing a .go file with no "package" statement, the error was previously unreported. Such errors would manifest as other errors.

Fixes golang/go#31712

Change-Id: I11b8d0e2e4d64b03fbcb4c35e7f0b02fccc83fad
GitHub-Last-Rev: 1581cbe36c269dd964f0b9226dbd63b1650c2a5b
GitHub-Pull-Request: golang/tools#102
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177605
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-17 18:33:31 +00:00
Muir Manders
f217c98fae internal/lsp: fix completion insertion
The insertion range for completion items was not right. The range's
end was 1 before the start. Fix by taking into account the length of
the prefix when generating the range start and end.

Now instead of a "prefix", we track the completion's
"surrounding". This is basically the start and end of the abutting
identifier along with the cursor position. When we insert the
completion text, we overwrite the entire identifier, not just the
prefix. This fixes postfix completion like completing "foo.<>Bar" to
"foo.BarBaz".

Fixes golang/go#32078
Fixes golang/go#32057

Change-Id: I9d065a413ff9a6e20ae662ff93ad0092c2007c1d
GitHub-Last-Rev: af5ab4d60566bf0589d9a712c80d75280178cba9
GitHub-Pull-Request: golang/tools#103
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177757
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-17 18:32:58 +00:00
Dmitri Shuralyov
1da8801a95 godoc: declare small victory over the punched card tyranny
At least inside this one package.

It's because golang.org/x/tools/cmd/godoc no longer has CLI support
as of golang/go#25443, it is now only a web server. Luckily, browsers
that display HTML pages are not constrained to the fixed width of
punched cards. On the contrary, they seem to embrace a wide variety of
arbitrary page widths, ranging from narrow to wide. This is in part due
to the proliferation of internet access on device form factors such as
the mobile phone, tablet, laptop, and desktop.

So the punchCardWidth constant is now unused and can be removed. This
is a followup to CL 141397 that removed most of the CLI support code,
including the function comment_textFunc, which was its only user. Same
goes for containsOnlySpace.

Updates golang/go#25443

Change-Id: I61fabe6ea801c88758fb2c6aefa70b53d52e2cb5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172975
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-17 16:27:34 +00:00
Rebecca Stambler
bffc5affc6 internal/lsp: support definitions and hover for builtins
This change adds support for definitions and hover for builtin types and
functions. It also includes some small (non-logic) changes to the import
spec definition function.

Additionally, there are some resulting changes in diagnostics to ignore
the builtin file but also use it for definitions (Ian, you were right
with your comment on my earlier review...).

Fixes golang/go#31696

Change-Id: I52d43d010a5ca8359b539c33e40782877eb730d0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177517
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-17 00:35:10 +00:00
Rebecca Stambler
1a8f2608bd internal/lsp: use ranges instead of positions in completion items
Fixes golang/go#32078

Change-Id: If33cc6f7a914e6ef17d06a34c39dceb61cfa16d4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177657
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-17 00:27:32 +00:00
Ian Cottrell
b9584148ef internal/lsp: add structured layers to the cache
This is primarily to separate the levels because they have different cache
lifetimes and sharability.
This will allow us to share results between views and even between servers.

Change-Id: I280ca19d17a6ea8a15e48637d4445e2b6cf04769
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177518
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-16 21:30:38 +00:00
Rebecca Stambler
abbb706b23 internal/lsp: enable enhanced hover by default
This change removes the explicit configuration for improved
documentation on hover. We use a comment's synopsis rather than the full
comment.

However, we also add a "noDocsOnHover" setting that is used by the cmd
tests. Ultimately, no one should use this setting and we should remove
it. We leave it temporarily because the cmd tests still need work.

Change-Id: I5488eca96a729ed7edad8f59b95af163903740d6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174378
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-16 17:30:22 +00:00
Muir Manders
e5f21acdc3 internal/lsp: handle more expected type cases
Calculate expected type in the following cases:

- switch case statements
- index expressions (e.g. []int{}[<>] or map[string]int{}[<>])
- slice expressions (e.g. []int{}[1:<>])
- channel send statements
- channel receive expression

We now also prefer type names in type switch clauses and type asserts.

Change-Id: Iff8c317a9116868b36701d931c802d9147f962d8
GitHub-Last-Rev: e039a45aebe1c6aa9b2011cad67ddaa5e4ed4d77
GitHub-Pull-Request: golang/tools#97
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176941
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-16 16:26:11 +00:00
Andrew Bonventre
d1a3278ee7 godoc/util: serve SVG files raw
When a godoc Presentation is serving a file, it will sniff its
contents to determine if it contains "human-readable" text. If
it does, then it serves the contents of the file with surrounding
HTML. SVG files should not be served with any additional HTML even
though their contents are not a binary format (just like CSS or JS
files).

Updates golang/go#9936

Change-Id: Id3dd3b6cda4f103b08f6e924923426a86bd46ec8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177498
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-16 01:51:32 +00:00
Ian Cottrell
4f9510c6a1 internal/lsp: prepare for non go files
This abstracts out the concrete file type so that we can support non go files.

Change-Id: I7447daa2ce076ec2867de9e59a0dedfe1a0553f5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175217
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-15 23:59:46 +00:00
Ian Cottrell
0e55654012 internal/lsp: add shutdown handling
We correcly cancel all background tasks and drop all active views when
the server is asked to shut down now.
This was mostly to support the command line being able to exit cleanly

Change-Id: Iff9f5ab51572aad5e3245dc01aa87b00dcd47963
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174940
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-15 23:16:32 +00:00
Rebecca Stambler
7c3f65130f internal/lsp: remove constant value from label and add tests
Fixes golang/go#29816
Fixes golang/go#31923

Change-Id: I4f0ff7941a5d26994ef6bbd10346eafe31160a21
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177357
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-15 19:19:14 +00:00
Rebecca Stambler
473d3dc1d7 internal/lsp: handle additional snippet cases
This change handles the case when a function that has already been
written out is being completed.

Change-Id: I0c4e9ec9bb5a8428526f00a4e62e020bcc30f0bf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176923
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-15 17:48:15 +00:00
Ian Cottrell
ce09bef8aa internal/lsp: reduce the api surface of the cache package
The cache now exposes only one symbol, NewView
This is preparing the cache for a re-write

Change-Id: I411c2cd7a7edc2e7c774218c6786f9fd4fcc53cb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176924
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-15 16:36:46 +00:00
Rebecca Stambler
707862fa78 internal/lsp: use builtin package for signature help
This change uses the builtin package to derive the signature help for
builtin functions.

Updates golang/go#31696

Change-Id: I458b3a89bdf143e7018e8be7cb6a5e8c068a47c2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176922
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-15 13:46:40 +00:00
Rebecca Stambler
2196cb7019 internal/lsp: make snippets private fields
Change-Id: I35d883196c7c3b35e14b49c0f5c779a91e72ce42
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177177
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-15 03:55:09 +00:00
Muir Manders
7d7faa4812 internal/lsp: fix missing parens in function call snippet
We were omitting the parens in function completions like "(foo<>)()"
because our check thought "foo" was the Fun in the outer CallExpr so
it already had parens. Fix by tightening up logic to only omit parens
for cases like "foo<>()" and "foo.bar<>()".

Change-Id: Ia602b80275f72baa6cdf6d61c22d3f3a6cfc3019
GitHub-Last-Rev: 41fecf92617e0812ee6552d8c43789eae83889bd
GitHub-Pull-Request: golang/tools#98
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176944
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-15 01:24:06 +00:00
Rebecca Stambler
921b34c7d0 internal/lsp: ignore files in the builtin package
This change stops diagnostics from running in files making up the "fake"
builtin package.

Fixes golang/go#31962

Change-Id: Ic54e1587e3ad54f0c1f5e82f1a6f3522b4c6bee9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177218
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-14 23:09:02 +00:00
Koichi Shiraishi
faff00d7e7 internal/lsp: fix typo on license year
Change-Id: I5643ce049bad0dfb45405c06adc7c2eb46a394ac
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177017
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-14 17:17:24 +00:00
Rebecca Stambler
2d081dbd58 internal/lsp: fix nil pointer when propagating diagnostics
Fixes golang/go#32030

Change-Id: I5ae7f2dc68c68c1a4851c637dcb75f312b0b35f5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177057
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-14 14:35:49 +00:00
Russ Cox
4789ca9922 go/analysis/internal/analysisflags: call gob.Register on deleted analyzers
Otherwise the specific set of gob registrations varies
according to the command line, which makes it impossible
for a narrow analysis run (for example, just one analyzer)
to read fact files written by less narrow runs (for example, all the analyzers).

This will start mattering in the standard repo vet.

For golang/go#31916.

Change-Id: I6fa90b3dfdf28ede6f995db3904211b6be68bb73
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176357
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-05-14 13:51:23 +00:00
Rebecca Stambler
7d589f28aa internal/lsp: stop trimming prefix from InsertText
After some discussion about how to handle insert and filter text
(https://github.com/microsoft/vscode-languageserver-node/issues/488), it
seems that it is better practice to overwrite the prefix in completion
items, rather than trimming the prefix from the insert text.

Change-Id: I7c794b4b1d4518af31e7318a283aa3681a0cf66a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176958
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-13 23:30:21 +00:00
Muir Manders
de15caf068 internal/lsp: fix composite literal completion
Fix the following issues:

- We were trying to complete struct literal field names for
  selector expressions (e.g. "Foo{a.B<>}"). Now we only complete field
  names in this case if the expression is an *ast.Ident.
- We weren't including lexical completions in cases where you might be
  completing a field name or a variable name (e.g. "Foo{A<>}").

I refactored composite literal logic to live mostly in one place. Now
enclosingCompositeLiteral computes all the bits of information related
to composite literals. The expected type, completion, and snippet code
make use of those precalculated facts instead of redoing the work.

Change-Id: I29fc808544382c3c77f0bba1843520e04f38e79b
GitHub-Last-Rev: 3489062be342ab0f00325d3b3ae9ce681df7cf2e
GitHub-Pull-Request: golang/tools#96
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176601
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-13 22:24:33 +00:00
Brad Fitzpatrick
2a413a02cc godoc/static: let client use vet check returned by /compile endpoint
(Forked off Yury Smolsky's CL 176618)

With this change, the playground.js client now asks the server to do a
vet check in the same HTTP request as the /compile (and run) step. If
the server replies that it understands the request (VetErrors or VetOK
in the repsonse), then the client can avoid the latency of a second
HTTP roundtrip. We'll remove the /vet handler after we see it fall out
of use from older clients.

Updates golang/go#31970

Change-Id: I5b123883e19cbc6a8ec30c50705e6b945a4d322d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176939
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-05-13 21:41:31 +00:00
Russ Cox
d81a07b7e5 go/analysis/passes/bools: eliminate quadratic runtime, output
If you have x == 1 || x == 2 || x == 3 || x == 4, the pass considered the set

	{x==1, x==2, x==3, x==4}

and then also

	{x==2, x==3, x==4}
	{x==3, x==4}

Since the comparison is itself linear in the size of the set, this was overall
taking time quadratic in the length of the || or && sequence.
Worse, if it found duplicates, they'd be reported a quadratic number of times.

This CL cuts the time and output to linear by avoiding already-checked
subexpressions. This cuts the time spent analyzing cmd/compile/internal/ssa
(with all passes enabled, not just this one) by 20%.

Fixes golang/go#28086.

Change-Id: I812f64bd5a44fea995c9ab0c4fa2fbefb44037ce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176457
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-05-13 18:47:35 +00:00
Peter Weinberger
8696927a28 internal/lsp: respond to shutdown requests and add DO NOT EDITs
Partly fixes golang/go#31333 (responds to shutdown request, but does
not reject later requests)
Fixes: golang/go#31375 by adding DO NOT EDIT comments to tsclient.go,
tsserver.go, and further details in the package doc in tsprotocol.go,
following the rule in golang/go#13560

Change-Id: I412e3dc6661373b8b70cdd15a385ad7bbd55a897
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176921
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-13 17:21:55 +00:00
Ian Cottrell
99f201b680 internal/lsp: add some missing copyright notices
Change-Id: Ieba43cfb3637bb50959801ce1226431f77e16e05
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176642
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-11 04:16:17 +00:00
Ian Cottrell
44dd571771 internal/lsp: add version and bug commands
Also log gopls version information on startup in server mode.

Change-Id: If7bf85d19f993430709b1fae83083e6fdfe1b2ca
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175199
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-11 04:16:02 +00:00
Ian Cottrell
90441677ad internal/lsp: suppress info and default logging unless a verbose flag is supplied
Change-Id: Ib4bf2a47cad4151b4b64d922855013b22b4fbb15
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176641
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-11 04:13:52 +00:00
Ian Cottrell
80b1e8742c internal/lsp: support dynamic workspace folder changes
This also required us to change the way we map files to a view, as it may change
over time.

Fixes golang/go#31635

Change-Id: Ic82467a1185717081487389f4c25ad69df1af290
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175477
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 21:22:50 +00:00
Ian Cottrell
4ca280b5bd internal/lsp: fix definition tests to use golden files
specifically it uses them for the guru compatability tests
This change radically increases the test coverage of the godef tests as it now
works for all the jump to definition tests not just the specialized ones.

Change-Id: I63547138566ac3de56344dcfddb758ed5f362a06
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174937
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 21:06:55 +00:00