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

3449 Commits

Author SHA1 Message Date
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
Ian Cottrell
45e43b2cb4 go/packages/packagestest: fix MustCopyFileTree so that file fragments are always slash form
Change-Id: I866384c2b382cbf3e839f0ef826eea654319fa5d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176219
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 20:25:38 +00:00
Ian Cottrell
0522b6e926 internal/lsp: adding the test suite to the source package
Change-Id: Ia287d84186bccca9e74050528daf809cb0e88c46
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176117
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 20:20:41 +00:00
Ian Cottrell
d4e30f1c22 internal/lsp: making cmd tests fast and small
This required extensive changes to the "internal" server handling and also to
the way we wait for diagnostics in the "check" verb.
It improves both memory and time by over an order of magnitude, hopefully
allowing us to renable the tests on the builders

Change-Id: I84e84ca4c449e9970ebf1d922a0a2ce0a8a49c72
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175878
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 20:14:07 +00:00
Muir Manders
775b7fe395 internal/lsp: improve expected type determination
Improve expected type determination for the following cases:

- search back further through ast path to handle cases where the
  position's node is more than two nodes from the ancestor node with
  type information
- generate expected type for return statements
- wrap and unwrap pointerness from expected type when position is
  preceded by "*" (dereference) or "&" (reference) operators,
  respectively
- fix some false positive expected types when completing the "Fun"
  (left) side of a CallExpr

Change-Id: I907ee3e405bd8420031a7b03329de5df1c3493b9
GitHub-Last-Rev: 20a0ac9bf2b5350494c6738f5960676cc50fb454
GitHub-Pull-Request: golang/tools#93
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174477
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 20:11:04 +00:00
Muir Manders
63859f3815 internal/lsp: add definition support for packages
Now the "type" of a *ast.PkgName is the package it points to. Of
course, a package is not a real types.Type, but we can still jump you
there. We have to pick one of the package's files, so we choose the
longest one, hoping it is the most interesting.

Similarly, the "definition" of an *ast.ImportSpec is the package being
imported.

I also added a nil check for the package in SignatureHelp. This panics
for me occasionally.

Change-Id: Ide4640530a28bcec9da6de36723eb7f0e4cc941c
GitHub-Last-Rev: 8190baa0b908065db5b53f236de03d2f3bff39b5
GitHub-Pull-Request: golang/tools#92
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174081
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 15:10:30 +00:00
Yury Smolsky
35884eef20 cmd/vet: print help to stdout only
Previously help for flags was printed to stderr.
This CL makes all the output to be printed to stdout.

Updates golang/go#31885

Change-Id: If95edeccd79581326502dd5c7fc2b49d8f160be7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175900
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-10 14:40:52 +00:00
Rebecca Stambler
3eedecdc80 internal/lsp: propagate diagnostics for reverse dependencies
Prior to this change, if a package was rendered invalid by a change in
one of its dependencies, diagnostics would not be propagated until the
user typed in one of the package's files. Now, these updated diagnostics
are sent along with the diagnostics for the dependency.

Fixes golang/go#29817

Change-Id: I4761de31c4bdee820e024005f6112b3b3d2e1da6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174977
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-10 13:52:23 +00:00
Rebecca Stambler
a1c92a4ac6 internal/lsp: add additional error handling for builtin packages
Change-Id: I1a084a47d2f171c6b94bde6fece008cddd547833
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175937
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-10 13:52:03 +00:00
Russ Cox
73554e0f78 go/analysis/passes: fix bugs discovered in std
asmdecl:
- MOVW $x+0(FP) is OK if x is big, because $x is an address
  (happens in internal/cpu, golang.org/x/sys/cpu, runtime)
- ignore TEXT lines in comments
  (happens in runtime/internal/atomic)
- wasm's CallImport instruction writes return results
  (happens in syscall)
- allow write out-of-bounds (SP) references in NOFRAME functions
  (happens in runtime)
- recognize "NOP SP" as an SP "write" to disable SP bounds checking
- 'go test' in passes/asmdecl was not testing all architectures; fix that

stdmethods:
- ignore WriteTo if obviously not io.WriterTo (as in go/types and runtime/pprof)

errorsas:
- don't complain about package errors testing invalid calls

structtag:
- don't complain about encoding/json and encoding/xml testing invalid tags

unmarshal:
- don't complain about encoding/gob, encoding/json, encoding/xml testing invalid calls

For golang/go#31916.
Fixes golang/go#25822.

Change-Id: I322c08b5991ffc4995112b8ea945161a4c5193ce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176097
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-05-09 15:32:22 +00:00
Dan Kortschak
d996b19ee7 go/analysis/analysistest: fix word usage
Change-Id: Iec304e44375b0740b8bc594cfe6ce35637284555
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175939
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-09 01:47:25 +00:00
Austin Clements
e31d36578a compilebench: handle missing MemStats more gracefully
Reporting MemStats requires the legacy profile format (see golang/go#18641).
This CL detects when it couldn't get the MemStats from the profile and
reports this, rather than reporting 0 allocs.

Change-Id: Ib621ad975290cf05835fafa81e8e47762d82a519
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175802
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-05-09 00:13:10 +00:00
Austin Clements
60140f0909 compilebench: add a linker benchmark
This links cmd/compile, which is the largest binary in GOROOT.

Unfortunately, this can't measure the linker's allocation metrics
prior to CL 176057 because the fix for golang/go#18641 was applied to
the compiler but not the linker.

Change-Id: Ia44d80f1d727c1608cedaa4b8ad2a05903774875
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175801
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-05-09 00:13:08 +00:00
Austin Clements
eeb76a0c47 compilebench: factor running build tool commands
We do a lot of sophisticated things around running the compile command
to gather benchmark metrics from it. We're about to add a benchmark
for the linker and will want all of the same mechanism. This CL
factors this out into a function.

Change-Id: I499d15d30417618f372982404ceb3e0f9c762e5c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175800
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-05-09 00:13:07 +00:00
Austin Clements
8a42e17289 compilebench: clean up different benchmark types
compilebench contains three different types of benchmarks and we're
about to add a fourth. Currently we dispatch based on name. This CL
cleans this up so the list of benchmarks points to how to run each
benchmark. It also joins together common error-reporting paths.

Change-Id: Icd4f77bdda9776863792dcd85f27b17829a833e6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175799
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-05-09 00:13:06 +00:00
Ian Cottrell
cf84161cff internal/lsp: fix incremental updates and turn them on
Updates that only add text have a start and end that are the same, we were
erroring on those and failing to apply the changes.

Fixes golang/go#31800

Change-Id: Ia31b90f108742e5532d2da35137c347c26090a6a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174949
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-08 15:02:11 +00:00
Ian Cottrell
490d13020f internal/lsp: switch golden files to use txtar
I was about to add some more tests and it caused a huge number of golden files,
which was hard to deal with. Now all the golden files are packed into a single
.golden archive in the txtar format.
I also changed the tagging key for hover results to use the marker name rather
than the line and column, as it makes it more stable against test data changes.

Change-Id: Iaa1f54ab55a41d380db67b9f6f928fa7a52d9a5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174877
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-08 14:59:27 +00:00
Rebecca Stambler
5658f888b3 internal/lsp: disable rangeFormatting temporarily
RangeFormatting was broken with the introduction of the diff library,
but not noticed until golang/go#31150. Temporarily disable this behavior
until we fix it.

Change-Id: Ie3e50a763e0c0e8672ad20c3a2e37d901325d356
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175938
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-08 13:53:17 +00:00
Shengyu Zhang
9529901698 lostcancel: do not analyze cancel variable which defined outside current function scope
See golang/go#31856.

Change-Id: I229a7f4a48e7806df62941f801302b6da8a0c12b
GitHub-Last-Rev: 33f85236bb79e325112866ee555950a4479ad7a7
GitHub-Pull-Request: golang/tools#95
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175617
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-08 02:57:53 +00:00
Dmitri Shuralyov
2d16b83fe9 go/vcs: ignore "mod" VCS type
golang.org/x/tools/go/vcs is significantly behind the upstream
cmd/go/internal/get code, and has no support for modules. It continues
to implement mechanics for GOPATH mode only.

This change is a minimal fix to get it to continue to work
in the presence of the module mode-only "mod" VCS type
(documented at https://golang.org/cmd/go/#hdr-Remote_import_paths)
by effectively implementing IgnoreMod ModuleMode behavior.

It is similar to issue golang/go#24751 and a small subset of CL 109340
that fixed it.

This helps with module adoption by reducing the harm of adding the
"mod" VCS type for vanity import paths, something that was meant to
be backwards compatible.

While here, also backport CL 14482 (the Token to RawToken change).

Fixes golang/go#31845
Updates golang/go#24751

Change-Id: I0852f52cb9bda56879f923337c7f361df8412845
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175219
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-05-06 14:53:03 +00:00
Ian Cottrell
3b6f9c0030 internal/lsp: add document link handling for import paths to godoc
Change-Id: Ib2eef50047dfcc64110c264e77d648f959613b88
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173698
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-03 18:56:57 +00:00
Ian Cottrell
9cb3dcf692 internal/span: update the offset if the end offset should be valid but is not
It used to be that when the start offset was valid, it was presumed the end was
as well.
This was not true in the case where the start offset was not supplied but could
be inferred (at the very start of the file).

Fixes golang/go#31797

Change-Id: Ie5a079796fa0f77cef5571a4e5b309c798e1e06b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174943
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-03 18:46:43 +00:00
Michael Matloob
5cec639030 go/analysis: proposed fact enumeration API
Updates golang/go#29616

Change-Id: Ibaf10526ea35f06b853ad55451a50750c764fab4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174379
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-03 03:01:57 +00:00
Ian Cottrell
83df196e57 internal/span: add a filename only print for spans
This prints the base of the path rather than the whole path when printing a
span.
This is useful for places where you are printing for the user rather than for
machines.
The format is %f

Change-Id: I6d1a52e4583099ff298c1fb645272578a49472eb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174942
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-03 02:58:08 +00:00
Rebecca Stambler
2346320968 internal/lsp: support builtin types without hardcoding
This change uses an *ast.Package built from the file
go/src/builtin/builtin.go. Completion (and ultimately other features)
will be resolved using this AST instead of being hardcoded.

Change-Id: I3e34030b3236994faa484cf17cf75da511165133
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174381
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-01 04:50:30 +00:00
Ian Cottrell
2d28432af7 internal/lsp: first pass at some hover tests
This uses golden files to hold the hover text as they are no more fragile than
hard coding the text in the tests, and much easier to update.
We need a lot more tests, and ones with actual comments, but this is a start and
at least adds the machienery it would take.

Change-Id: Ia2f79257642759e4c2f972d4037f258134e0fb33
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174380
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-30 19:42:29 +00:00
Peter Weinberger
08ecc9edd9 internal/lsp: generate RPC interface from Typescript source
The generated code adds some server methods that are unsupported, but were
prviously unimplemented, and makes small adjusments to some parameter types.

Change-Id: I3dd32cafa3e457193f0771e0f8e150c88b381c82
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173420
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-30 16:16:08 +00:00
Rebecca Stambler
b9fed7929f internal/lsp: change some comments and variable names in completion code
Also, return diagnostics instead of errors from source.Diagnostics (to
avoid stuck diagnostics).

Change-Id: I56b067273982fd086ed74185e50eda5b72b5fba1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174400
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-30 00:41:04 +00:00
Brad Fitzpatrick
9d4d845e86 cmd/goimports: add -format-only flag
Fixes golang/go#31745

Change-Id: I127ca4140c9db7df224b1892c43c457ac6edd646
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174326
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-29 23:13:29 +00:00
Ian Cottrell
35c670923e internal/lsp: clean up formatting header handling
This is mostly to set things up to use golden files the same way for other commands.

Change-Id: I7fcc7165706763e655b0e46f0790b367fe5d3d59
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174018
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-04-29 18:49:09 +00:00