1
0
mirror of https://github.com/golang/go synced 2024-11-05 23:36:12 -07:00
Commit Graph

3214 Commits

Author SHA1 Message Date
Rebecca Stambler
bf090417da internal/lsp: fix a few nil pointer exceptions in definition
Jumping to the definition of a builtin function or basic kind would
cause a nil pointer because these have no position.

Change-Id: I043a61a148757b127ff1123c8429ce23858bd13a
Reviewed-on: https://go-review.googlesource.com/c/157597
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-01-14 22:23:45 +00:00
Dmitri Shuralyov
36f37f8f5c go/packages: rename Illtyped to IllTyped in docs
Fix the field name in docs to have the correct case, as seen at
https://godoc.org/golang.org/x/tools/go/packages#Package.IllTyped.

Change-Id: I3184c2fc5f9c4641a61dbd2af6a11309e9f284ea
Reviewed-on: https://go-review.googlesource.com/c/157797
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-14 16:46:48 +00:00
Rebecca Stambler
fc1d57b08d cmd/golsp: add a debugging tool to connect with golsp on a port
This change allows golsp to be run on a port, with an intermediary
command passing the data through. This allows for improved logging.
Also, add necessary changes to VSCode integration to allow changing the
name of the command for golsp.

Change-Id: I20dca1a50296636e57e022342ee70f0610ad1531
Reviewed-on: https://go-review.googlesource.com/c/157497
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-11 21:44:48 +00:00
Dmitri Shuralyov
4b7be70d8a godoc/dl: don't display unstable releases under archive
If a release is unstable, don't consider adding it to archive or stable
lists as well. It should be present in the unstable list only.

Create and use test helper list to make tests more compact and thorough.

Also use a more consistent order of got, want in TestFilesToReleases.

Fixes golang/go#29669

Change-Id: I74cf1fa8ebf05b13a3a4c40b53442c50e0427302
Reviewed-on: https://go-review.googlesource.com/c/157499
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-11 18:10:22 +00:00
Agniva De Sarker
40c2d4768f go/analysis: fix typos and update documentation
Change-Id: I48187fcb1eedd5b94d7b6b2db1ae11009bab23a2
Reviewed-on: https://go-review.googlesource.com/c/157299
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-11 18:03:38 +00:00
Daniel Martí
68c5ac90f5 go/packages: Load with no patterns should load "."
At least on the go list driver, which is the default fallback. Note that
we need to call 'go list' on Load("foo") and Load(), but not
Load("name=bar"). This is what the current logic was trying to
accomplish.

But it didn't take into account the case where there are zero initial
patterns, in which case we should still call 'go list'. Fix that, and
add a test.

Fixes #28767.

Change-Id: I40af9eb7f2407449c5683df1403928e2c57c86a4
Reviewed-on: https://go-review.googlesource.com/c/155898
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-10 21:10:28 +00:00
Yasuhiro Matsumoto
a2c791aa64 internal/lsp/cache: return error when no packages found
Change-Id: Ia11f0c428cffdd42eab5c4322e9ff6f0a38870fc
Reviewed-on: https://go-review.googlesource.com/c/156777
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-10 19:47:25 +00:00
Michael Matloob
51295c7ec1 go/packages: update comment on when golist fallback triggers
It triggers for all go versions before 1.11. We thought we might
be able to backport some of the necessary changes to 1.10.4, but
it was infeasible, so no 1.10.x versions will support the non-fallback
behavior.

Change-Id: Ib22be2715bf504464e4bd09c14453e5d132776f3
Reviewed-on: https://go-review.googlesource.com/c/156898
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-10 16:31:46 +00:00
Agniva De Sarker
158f3dcaf6 go/ast/inspector: fix a small typo
Change-Id: Ifa677f0b0cd1cc345ce65eceacae4413a5644646
Reviewed-on: https://go-review.googlesource.com/c/157300
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-10 14:16:07 +00:00
Dmitri Shuralyov
aa03309574 godoc/redirect: display Gerrit/Rietveld CL disambiguation page when needed
For CL numbers that are determined to be Rietveld CLs, instead of
immediately redirecting, check whether a Gerrit CL with the same
number also exists. Do so by querying the Gerrit API and caching
the existing CLs. If both exist, display a very simple disambiguation
HTML page.

Cache Gerrit CLs that exist, to avoid querying the remote API server
more than once per CL. We can't cache Gerrit CLs that don't exist,
since they might get created in the future.

Fixes golang/go#28836

Change-Id: I08c32dc82a0136788337c5c32028e87428e8d81e
Reviewed-on: https://go-review.googlesource.com/c/157197
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-10 01:58:56 +00:00
David Chase
d30e00c240 splitdwarf: initial working commit
splitdwarf osxMachoFile [ osxDsymFile ]

splitdwarf takes an executable produced by go build as input,
and uncompresses and copies the DWARF segment into a separate
file in the way that is expected by OSX-hosted tools
(lldb and ports of gdb).
If osxDsymFile is not named explicitly, the default of
"<osxMachoFile>.dSYM/Contents/Resources/DWARF/<osxMachoFile>"
is used instead, with directories created as needed.

If the input file contains no UUID, then one is created by
hashing non-DWARF segment contents, and added to the
executable. This is necessary because gdb and lldb both
expect matching UUIDs to be present in the executable
and its debugging symbols.

Includes a modified version of debug/macho, with additional
definitions and the ability to write segments, sections, and
some MachO load commands added.

Change-Id: Ia5b0e289260f72bbca392cdf2c7c0a75e3ca40e5
Reviewed-on: https://go-review.googlesource.com/c/143357
Reviewed-by: Austin Clements <austin@google.com>
2019-01-09 16:56:30 +00:00
David Chase
d674b4ad67 cmd/splitdwarf: copy debug/macho
The splitdwarf command will need a modified version of debug/macho.
This is a verbatim copy from std as of Go 1.11, which we'll modify in
the next CL.

Change-Id: Ia9ded870d1ba91dad21f9f6dc5bb38f9f6cc0e80
Reviewed-on: https://go-review.googlesource.com/c/152240
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
2019-01-09 16:55:59 +00:00
Peter Weinberger
98df4c70be tools/internal/lsp/protocol: add LocationLink type
LocationLink was added in 3.14.0 of lsp.

Change-Id: I388dba5ab43b195cc3965e4199b49155094a2627
Reviewed-on: https://go-review.googlesource.com/c/156617
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-09 16:41:58 +00:00
Michael Matloob
421f03a57a Revert "go/packages: make tests pass with custom GOCACHE"
This reverts commit e7b5a6dfd8.

Reason for revert: merged by mistake

Change-Id: Ibf6ff4aa346b569aaa5e06b58770a93ca3eebdab
Reviewed-on: https://go-review.googlesource.com/c/156900
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-01-08 22:28:58 +00:00
fREW Schmidt
e8d59ebc66 Remove warning stability warning
December 1, 2018 has come and gone.

If the timeframe should change that's fine; feel free to reject this and just update the date.

Change-Id: If6aaee30340ee0bfde7e578e054c5b8bc910a5b9
GitHub-Last-Rev: ec781ca1374a010168bc4a457d2ea5d0c023f8dc
GitHub-Pull-Request: golang/tools#64
Reviewed-on: https://go-review.googlesource.com/c/155237
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-08 19:38:35 +00:00
Steven L
5e40c1c236 go/analysis/internal/checker: don't clobber error when packages.Load fails
Previously, if `packages.Load` failed, it would (sometimes? always?) return an error + no initial packages.
The moved `len(initial)` check was overriding the actual err with a much less useful one.

Example output before:
```
13:03:17.856866 load [./...]
13:03:28.403532 ./... matched no packages
```
And after:
```
13:03:30.942191 load [./...]
13:03:36.999506 go list repeated package [an internal package] with different values
```

Change-Id: I1a821e3855cbbbee904bcec9c29877e091c3e3a0
GitHub-Last-Rev: d1235fc2eceb0d4e947f47be99edc5ac96da5f84
GitHub-Pull-Request: golang/tools#65
Reviewed-on: https://go-review.googlesource.com/c/155745
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-08 19:37:22 +00:00
Daniel Martí
e7b5a6dfd8 go/packages: make tests pass with custom GOCACHE
Before this change, a test would fail:

	$ GOCACHE=$HOME/go/cache go test
	--- FAIL: TestLoadImportsGraph (0.36s)
	    --- FAIL: TestLoadImportsGraph/GOPATH (0.19s)
		packages_test.go:191: golang.org/fake/subdir/d.test.Srcs = [4302876da86a8aae0c1669924daa223cafca60ef49ccaa060ae37e778d18f218-d], want [0.go]
	    --- FAIL: TestLoadImportsGraph/Modules (0.17s)
		packages_test.go:191: golang.org/fake/subdir/d.test.Srcs = [4302876da86a8aae0c1669924daa223cafca60ef49ccaa060ae37e778d18f218-d], want [0.go]
	FAIL

This is because it assumed that the user hadn't set their own GOCACHE,
and thus that all source files in the cache would be under the default
"go-build" cache directory.

We could fix this via os.Getenv("GOCACHE"), but a simpler mechanism is
to see if the source file has an extension. Source files don't have an
extension in GOCACHE, so that's much simpler to detect.

After this change:

	$ GOCACHE=$HOME/go/cache go test
	PASS

While at it, gofmt.

Fixes #29445.

Change-Id: I83c0afc20a527bb50a03f9946e555db36cc85efd
Reviewed-on: https://go-review.googlesource.com/c/155897
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-08 19:35:00 +00:00
Zac Bergquist
1bc491975c go/packages: update doc for name= queries
Change-Id: I2ba387703ae1f31e7dff271007607f377701f7dd
Reviewed-on: https://go-review.googlesource.com/c/155941
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-08 19:25:35 +00:00
Ian Cottrell
7cb465e007 go/package/gopackages: update gopackages to use the new tool library for its main function
Change-Id: I06f13024c021d14e4a759ca9ec24aa54f9d1b97f
Reviewed-on: https://go-review.googlesource.com/c/154558
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-08 19:17:02 +00:00
Daniel Martí
e063def13b go/analysis: fix package doc copy-paste typo
Change-Id: I17495106c76bbf270f621abe2eca367ed818a79b
Reviewed-on: https://go-review.googlesource.com/c/156500
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-07 15:52:54 +00:00
Emil Hessman
d345f29b0d internal/lsp: fix typo
Change-Id: I04164ea5b57ebb828ecb837caa397c9e736f4d57
Reviewed-on: https://go-review.googlesource.com/c/156457
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-07 03:02:06 +00:00
Daniel Martí
3ef6863234 go/analysis: fix ambiguous paths in structtag pass
Now that we support checking for duplicate struct field tags across
anonymous struct fields, we must deal with the fact that the files
involved in such a warning may not be in the same package or directory.

This could lead to errors where a file was mentioned in a package where
it didn't exist. Or even worse, point at a location within an existing
file that doesn't contain the field we want, causing even further
confusion to the user.

To fix this, always make the "also at" positions relative to the current
warning, if possible.

Fixes #29130.

Change-Id: Iaa29b406978f1671bdfb2ddddb7058eeffec92a9
Reviewed-on: https://go-review.googlesource.com/c/155899
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-06 17:17:56 +00:00
Heschi Kreinick
498d954934 go/packages/packagestest: make temp directory writeable
In module mode, the temp dir will contain a mod cache, which needs to be
made writeable before it can be deleted.

Change-Id: Ia979a8b06d1b4db47d25ffdfdf925ba8a0ac67de
Reviewed-on: https://go-review.googlesource.com/c/156078
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-04 18:20:27 +00:00
Dmitri Shuralyov
9ea1c200b2 cmd/godoc: add x/website redirect
Add a redirect for the recently created x/website subrepository.

It's not yet included at https://golang.org/pkg/#subrepo because it's
in development. Once development reaches the point that x/website
is the canonical location of the golang.org server, we can consider
including x/website at https://golang.org/pkg/#subrepo (just like
x/blog, x/tour, x/build are already included there).

Updates golang/go#29206

Change-Id: I6889c1f5e40f11abca944b217a7354f76c08c8eb
Reviewed-on: https://go-review.googlesource.com/c/156337
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-04 17:33:42 +00:00
Heschi Kreinick
8a60511975 imports: don't look for, or find, empty packages
Fix a pair of bugs that combined to cause golang/go#29520. First, don't go
looking for a package if we've only seen unexported identifiers selected
from it. It's probably a typo. Second, don't find packages with no files
in them, e.g. because they're all build tagged out. We can't know what
package they form, so we have no business considering them.

Test only for the first, since without the first bug the second has no
observable effect on behavior, and I don't want to test the private API.

Fixes golang/go#29520

Change-Id: I5b797940bec051be5945b9c5cb4e7bf28527a939
Reviewed-on: https://go-review.googlesource.com/c/156178
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-03 20:59:43 +00:00
Iskander Sharipov
ca9055ed7d cmd/guru: fix incorrect case order in describe.go
Since *ast.CommClause implements ast.Stmt, type switch for
it would never execute in the original code, it will always
execute ast.Stmt branch.

Moving concrete types before interfaces help in this case.

Change-Id: Id84f2f7f3fac859029155d8e6debf4a8ef170b26
Reviewed-on: https://go-review.googlesource.com/c/153397
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-02 21:33:36 +00:00
Steven L
52ae6dee23 go/analysis/internal/checker: fix debug flag docs
The list of recognized values for the `-debug` flag was old / incorrect.

Change-Id: Ic5f260e650e73512cca2f4db8155bb70bc6b6d17
GitHub-Last-Rev: af642385b81da00169ab9700abb26bed54bdf8ac
GitHub-Pull-Request: golang/tools#66
Reviewed-on: https://go-review.googlesource.com/c/155938
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-02 20:01:30 +00:00
Rebecca Stambler
7c850e7ac1 godoc/static: update copyright year in static.go
This change was created with `go generate
golang.org/x/tools/godoc/static` and updates the year in the copyright
notice in the file.

Change-Id: I5916b7a6d1f1ceae84d58c392767ca97b314ebc3
Reviewed-on: https://go-review.googlesource.com/c/156077
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-02 19:58:57 +00:00
Yasuhiro Matsumoto
79186431cf go/internal/packagesdriver: fix crash when GOARCH and Go compiler can't be determined
When run "go list" outside GOPATH, result should be empty

Change-Id: If832c46d3e4c32a2a87338cca95e3169ea3be055
Reviewed-on: https://go-review.googlesource.com/c/155557
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-01-02 18:37:24 +00:00
Rebecca Stambler
d00ac6d273 internal/lsp: remove unnecessary packagestest.RangePosition type
Some cleanup of lsp_test.

Change-Id: I0cf4eb73f223845374c7f7f4939a461ff676bde8
Reviewed-on: https://go-review.googlesource.com/c/155579
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Libor K <aschrak1978@gmail.com>
2018-12-21 23:52:34 +00:00
Zac Bergquist
c446015edc go/packages/packagestest: fix Expect doc
The type is expect.Note, not expect.Comment.

Change-Id: I04338fee3b20a7507bbe2a6a15ea36cf1066fe88
Reviewed-on: https://go-review.googlesource.com/c/154580
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-21 20:46:27 +00:00
Rebecca Stambler
62138107df internal/lsp: fix diagnostics range computation
Diagnostics were failing because of
https://go-review.googlesource.com/c/tools/+/154742, where I was using
the wrong *token.File for the position calculations. This should fix the
problem.

Change-Id: Ic44e7799da56010b5014d56029fb4e0a8a6bb0e8
Reviewed-on: https://go-review.googlesource.com/c/155479
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-21 20:18:27 +00:00
Rebecca Stambler
85a09cd5ed internal/lsp: set file contents through the source.View, not File
Refactor code as a follow-up to
https://go-review.googlesource.com/c/tools/+/154742.
Also, change every instance of "source.URI()" to "fromProtocolURI", so
that we can add a better implementation of that later on (for Windows
support).

Change-Id: Ifa24ffd7e1aebf1f7d05df6f65742769ead0922f
Reviewed-on: https://go-review.googlesource.com/c/154741
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-12-21 19:33:31 +00:00
Peter Weinberger
54d1bacb4e internal/lsp/server: fix typo in name of method foldingRange
It should say "textDocument/foldingRange" even though everyone names
the associated function FoldingRanges.

Change-Id: I79c8449a689dc8c80f745c875d9ec9892d926e9c
Reviewed-on: https://go-review.googlesource.com/c/155578
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-21 18:55:09 +00:00
Peter Weinberger
3ad2d988d5 cmd/golsp: log elapsed times in milliseconds rather than microseconds.
Language servers provided by Microsoft seem to use Date.Now()
for calculating elapsed times. In javascript and typescript Date.Now()
reports milliseconds.

Change-Id: Ic12fc4a1d31f2548d8808b8b22aba80c44f000c3
Reviewed-on: https://go-review.googlesource.com/c/155018
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2018-12-21 15:44:17 +00:00
Heschi Kreinick
537d06c362 imports: use LoadFiles everywhere
Since we don't really need type info, and want everything to be fast,
use LoadFiles and do parsing manually. It would be nice if there were a
mode for that.

Change-Id: I33f8a85ffb87a70048c4775058bd0813cf677061
Reviewed-on: https://go-review.googlesource.com/c/155478
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-21 00:13:48 +00:00
Heschi Kreinick
d12035dfdc go/packages: use -find, add GOPACKAGESDEBUG env var
Pass -find whenever possible to speed up go list calls. Add an
environment variable, GOPACKAGESDEBUG, that controls debug logging
so that we don't have to tell users to recompile goimports to debug it.

Change-Id: If39ff7829279dafa4e066e74a024c27a8235154b
Reviewed-on: https://go-review.googlesource.com/c/155477
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-12-20 22:10:20 +00:00
Rebecca Stambler
f344c7530c internal/lsp: add ranges to some diagnostics messages
Added a View interface to the source package, which allows for reading
of other files (in the same package or in other packages). We were
already reading files in jump to definition (to handle the lack of
column information in export data), but now we can also read files in
diagnostics, which allows us to determine the end of an identifier so
that we can report ranges in diagnostic messages.

Updates golang/go#29150

Change-Id: I7958d860dea8f41f2df88a467b5e2946bba4d1c5
Reviewed-on: https://go-review.googlesource.com/c/154742
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-20 19:13:07 +00:00
Heschi Kreinick
3571f65a7b go/packages: deduplicate roots
refine needs to match packages back to roots, and it gets confused if
the same root appears twice. Deduplicate roots the same way we
deduplicate packages.

Introduce a new wrapper around driverResponse to make this easier, and
pass that around instead of the addPackage callback.

Fixes golang/go#29297

Change-Id: I49ea37155c507af136391b9eb55a83b6dedfcc14
Reviewed-on: https://go-review.googlesource.com/c/155020
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-12-20 18:52:03 +00:00
Rob Pike
92cdcd90bf godoc: choose a smaller-output example as help when there are unexpected arguments
Change CL 153869 added a help message when there are leftover arguments,
as that used to invoke the command-line interface that is now gone.
But the example in the help text (go doc -all net/http) generates a huge
amount of output.

Use a very simple, small-output example instead, to illustrate how to
solve the problem without scrolling the program description hundreds
of screenfuls away.

Change-Id: I1887af1f3e853bf3a852dc374746074f1cd39441
Reviewed-on: https://go-review.googlesource.com/c/155157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-12-20 02:49:03 +00:00
Rebecca Stambler
6e267b5cc7 internal/lsp: add additional tests for completion
New tests include cases for anonymous structs, composite literals,
ranking of results in binary expressions, and import cycles.

Change-Id: Ic02e84e09101bb9873fc1705bba2594d655bb45b
Reviewed-on: https://go-review.googlesource.com/c/153443
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-19 22:27:14 +00:00
Ian Lance Taylor
2240b23956 go/packages: use packagesdriver to fetch sizes for "go list"
Also fix packagesdriver to use "go list" if the gopackagesdriver
program is not available, rather than returning nil with no error.

Also fix some comments.

Change-Id: I0457cfa4eab4294760af71c780c62c05ad841c85
Reviewed-on: https://go-review.googlesource.com/c/154757
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-12-19 20:36:29 +00:00
Filippo Valsorda
88e3b261f2 cmd/godoc: print a helpful error if used for command-line docs
The command-line interface was recently removed in favor of "go doc".

Change-Id: Idfcfca3b2eafaf63148a2ed88d4d25c61d9e3c69
Reviewed-on: https://go-review.googlesource.com/c/153869
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-12-19 18:50:13 +00:00
Heschi Kreinick
d4971274fe imports: don't remove imports that conflict with globals
When a package contains both a var and an import that produce the same
identifier, the compiler will complain. I had thought that it made sense
to remove the redundant imports in that case. However, we can't reliably
tell whether a global from one file is in scope in another file. Most
notably, having multiple main packages in the same directory is pretty
common, and if someone declares a var in one that matches an import in
another, we don't want to remove the import.

Change-Id: I49f58fccdb8a8542ec85cf4d80d3e20d3159d2c7
Reviewed-on: https://go-review.googlesource.com/c/154740
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-18 20:40:10 +00:00
Michael McLoughlin
bbbd9518e8 go/analysis/passes/asmdecl: fix array offsets
Array offsets in recursive structures do not include the accumulated
offset. This diff fixes the mistake and adds a test.

Fixes golang/go#29318

Change-Id: Iaa2a2f9404e4ed0e38b87e5e041709c1a8e25809
Reviewed-on: https://go-review.googlesource.com/c/154665
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2018-12-18 19:42:33 +00:00
David Symonds
13ba8ad772 go/vcs: use Bitbucket v2 REST API
This ports the change made to cmd/go in
https://go-review.googlesource.com/36219 (Feb 2017).

Change-Id: I04e55749b187e21d140500b8878866bd3ceea174
Reviewed-on: https://go-review.googlesource.com/c/154677
Reviewed-by: Andrew Gerrand <adg@golang.org>
2018-12-18 02:00:41 +00:00
Ian Cottrell
a072e66104 internal/lsp: refactor the command line handling
This switched the golsp binary to support a sub-command model so it can grow
some guru like command line query capabilites

Change-Id: I1a7a49bb17701e62004bba636d6bee9de2481ffd
Reviewed-on: https://go-review.googlesource.com/c/154559
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2018-12-17 23:08:30 +00:00
Ian Cottrell
71d3d868db internal/tool: add a small package to unify the flag handling across all our tools
This adds an opinionated package that has the common code that should be in all
our tools (profiling, logging, context handling etc)
It also adds code for using struct fields as flags to allow us to remove all the
flag globals.

Change-Id: I27bb493ebcce3a86ddcdab87892a2295c237cb16
Reviewed-on: https://go-review.googlesource.com/c/154557
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2018-12-17 23:08:00 +00:00
Michael Matloob
ae5b881676 go/packages: suppress go list errors when ad-hoc package doesn't exist
Updates golang/go#29280

Change-Id: Ie5a5dc1fef8f3d989b3a5fffb6c2ca66e97c143a
Reviewed-on: https://go-review.googlesource.com/c/154517
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-17 22:06:04 +00:00
Rebecca Stambler
57eff0d8ac internal/lsp: add support for running goimports as a code action
This change adds support for goimports as a code action that can be run
on save. However, there do appear to be issues with the propagation of
the context.Only field of the CodeActionParams, so we treat every
codeAction as an organizeImports action - this should be fixed in the
next vscode-languageclient release
(https://github.com/Microsoft/vscode-languageserver-node/issues/442).

Change-Id: I64ca0034c393762248fde6521aba86ed9d41bf70
Reviewed-on: https://go-review.googlesource.com/c/154338
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-17 20:01:16 +00:00