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

3134 Commits

Author SHA1 Message Date
Rebecca Stambler
0926561711 internal/lsp: fix nil pointer exception in document symbols
Change-Id: I168bf7b995aa0b609de67999879addad250eff11
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170006
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-29 18:25:15 +00:00
Ian Cottrell
23e29df326 internal/lsp: fix broken gopls query help comment
Change-Id: I7f1f9c4a56a1471ebb6f2b4d1a72b8d7c2223e85
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170017
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-29 15:12:28 +00:00
Ian Cottrell
4471d52094 internal/lsp: allow command line tests to connect through a pipe
With this change (finally, after a lot of detours) if you run the lsp tests with `-race -pipe` then you
can reliably reproduce the race in golang/go#30091

Change-Id: Ibd9fda5e07409a15d1bc8d14cb46fde41155aa6e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169999
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-29 15:12:06 +00:00
Ian Cottrell
ab21143f23 internal/lsp: adding command line access to diagnostics
Change-Id: I011e337ec2bce93199cf762c09e002442ca1bd0d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167697
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-28 21:17:00 +00:00
Ian Cottrell
8889bfc21e internal/lsp: wire up configuration
This connects up the configuration message, and uses it to allow the client to set the environment
in the config passed to packages.Load

Change-Id: I75e03c01c74e9b11c8b4c47b9cbdd0574cddf778
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169704
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-28 21:16:46 +00:00
Zac Bergquist
8f05a32dce internal/lsp: correctly report interface symbols
Updates golang/go#30915

Change-Id: I9c5faa615df506cf1d015a9eb48196fa9b0387ee
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169682
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-28 03:05:05 +00:00
Rebecca Stambler
2898d834dc internal/lsp: fix tiny bug in getting files by basename
This change fixes gopls on Windows.

Fixes golang/go#30967

Change-Id: Iba5eb6932a4acd6a574ad6970faf7c133ecb7d32
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169703
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-28 02:26:11 +00:00
Ian Cottrell
c70d86f8b7 internal/lsp: match files by identity
Instead of using a simple path map we now attempt to match files with
os.SameFile with fast paths for exact path matches. This should fix issues both
with symlinked directories (the mac tmp folder) and with case sensitivity
(windows)

Change-Id: I014dd01f89d08a348e7de7697cbc3a2512a6e5b3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169699
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-27 20:14:19 +00:00
Michael Matloob
dbeab5af4b go/packages: split LoadMode into fine-grained options
The options are all unexported, and this CL is (almost) a no-op:
the one difference is that since needImports and needSyntax are now
independently specified, LoadSyntax and LoadAllSyntax are equivalent,
because LoadSyntax needs both the needImports and needSyntax bits.

I want to pin down the options that we want to split into, and
future CLs can allow the options to be used individually...

Updates golang/go#29429
Updates golang/go#29427

Change-Id: I5b2913e2c53e7ade56905e46912b076ccc339827
Reviewed-on: https://go-review.googlesource.com/c/tools/+/162140
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-27 18:08:49 +00:00
Rebecca Stambler
45dd101d87 internal/lsp: unescape uris before we convert them to span.URI
This is the first step of fixing gopls on Windows.

Change-Id: I20cea63051f448cba86996edaf7a8347b0d20bd1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169444
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
2019-03-27 16:50:41 +00:00
Rebecca Stambler
79af862e67 internal/span: switch to an offset function that doesn't panic
go/token.File.Offset panics on invalid positions, which is causing
crashes on invalid ASTs.

Change-Id: I6c698760ae92f3076a056c3560bea2e8eeb528db
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169443
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-27 01:14:46 +00:00
Rebecca Stambler
41a94eb788 internal/lsp: add back distinction between var and const symbols
Change-Id: I59f87d4430c93438804cea7cc56a80f12bb42a00
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169441
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-27 01:06:29 +00:00
Rebecca Stambler
cd3f3f06fc internal/span: return error when on spans with invalid starts
Fixes golang/go#30155

Change-Id: I7f9dbec6fdfa92654f58627ef44ee4bfe2870fa6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169440
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-27 00:00:45 +00:00
Rebecca Stambler
c02eab13f0 internal/lsp: group document symbols and add more detail
This change uses go/types information to get the types for the
different symbols. It also groups the symbols according to their kinds,
though this doesn't seem to be reflected in the actual VSCode UI...

Updates golang/go#30915

Change-Id: I2caefe01f9834aaad6b9e81cd391d461405ef725
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169438
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-26 23:54:22 +00:00
Jonathan Amsterdam
3ad05305c9 go/analysis/cmd/vet: add errorsas analyzer
Change-Id: I4900b62cb460c8fab2fca6302b472bb531e46eb7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169457
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-26 22:16:39 +00:00
Jonathan Amsterdam
b8c0eb4911 go/analysis/passes/errorsas: check type of errors.As target
Add a vet pass that checks that the second argument to errors.As
is a pointer to a type implementing error.

Change-Id: I0924e634cbea0664c8728f0e74213b924f8498e6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168938
Reviewed-by: Damien Neil <dneil@google.com>
2019-03-26 20:44:19 +00:00
Ian Cottrell
0268d3dd07 internal/lsp: use main testdata folder
This upgrades the current gopls query definition tests to use the main testdata
folder. This considerably increases the coverage and also sets us up to better
test the other command line features as we add them.

Change-Id: If722f3f6d0270104000f1451d20851daf0757874
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169159
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-26 19:49:56 +00:00
Zac Bergquist
ca36ab2721 internal/lsp: add support for document highlight
Change-Id: I232dbb0b66d690e45079808fd0dbf026c4459400
Reviewed-on: https://go-review.googlesource.com/c/tools/+/169277
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-26 19:08:20 +00:00
Zac Bergquist
1d95b17f1b x/tools/internal/lsp: add support for document symbols
Updates golang/go#30915

Change-Id: I9a447f7748eb9894fb6f4072febec132b2ed91d7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168338
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-25 22:30:49 +00:00
Ian Cottrell
5a8dccf5b4 go/packages/packagestest: convert to the span library
Change-Id: Ib8984dd0828e3bb0b49eaa1604649300a4d54306
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168900
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-03-25 16:17:52 +00:00
Michael Matloob
c1a832b0ad go/packages: remove spurious print
Also fix a test name.

Fixes golang/go#30994

Change-Id: Ib37359254206ecf47b0ac23098c57da1e69944a1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168939
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-22 20:37:28 +00:00
Michael Matloob
3a76a6439c go/packages/testdata: add go directives to fake module files
Stop fighting the behavior of the go tool when run in these directories.

Updates golang/go#30790

Change-Id: I32dfeb0bafa3ed3664500f1768b2293e5257d09b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168757
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-03-22 20:32:07 +00:00
Dmitri Shuralyov
8f249a1648 go/packages: detect missing binary via exec.ErrNotFound error
exec.Command already runs exec.LookPath when given a name that contains
no path separators. There's no need to call exec.LookPath a second time
to detect that cmd.Run failed because of a missing executable file.
It can be detected from the returned error. Do so because it's cleaner.

Also improve the error text to say that the problem was that the go
executable file was not found in $PATH (or %PATH%, etc., depending on
the underlying operating system). In the general case, we can't know if
Go is or isn't installed.

Example error text on macOS:

	gopackages: 'go list' driver requires 'go', but executable file not found in $PATH

Updates golang/go#29552

Change-Id: I769553f125240dccd02098c22641f6a1ed10063c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168897
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-03-22 19:14:23 +00:00
Alan Donovan
e779aa49e3 go/ssa/interp: make tests fast and robust
The go/ssa/interp tests have been a maintenance nightmare for years
because the interpreter requires intrinsics for all low-level or
non-Go code functions, and the set of such functions in the standard
library naturally changes from day to day.

This CL finally drops support for interpreting real packages (which
has anyway been broken for ages) and restricts the test suite to small
programs that use a handful of simple functions in packages bytes,
strings, errors, runtime, reflect, and unicode. These functions are
declared in a tiny fake standard libary in testdata/src, and the
implementations of these functions are provided by interpreter
intrinsics that delegate to the real Go implementation---all their
parameters and results are basic datatypes.

The test suite is now very fast and should be easy to maintain going
forward. It is still possible that a change to some file in
$GOROOT/test/*.go adds a dependency to a symbol not present in our
standard library, but this is rare. I will either delete the test or
add the intrinsic on a case-by-case basis.

We no longer attempt to interpret major functionality like
fmt.Sprintf or "testing".

The interpreter always pretends to be in linux/amd64 mode.

Happy Christmas, Brad. ;)

Fixes golang/go#27292

Change-Id: I715cf63e3534e2e0dab4666a5d7c669bf1d92674
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168898
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-22 17:29:27 +00:00
Ian Lance Taylor
cc8e56e55e go/analysis/passes/tests: break out of loop when we find a method
Updates golang/go#30971

Change-Id: I7c9250c46fede553689cdc5007b6f330a006b867
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168804
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-22 16:28:07 +00:00
Ian Lance Taylor
6aabc1ca79 go/analysis/passes/tests: don't warn about missing method for each type
Only warn if the method is missing for all types.

Fixes golang/go#30971

Change-Id: I94169ad3266f68ca20378a8dc5538aed2541a773
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168803
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-22 14:36:16 +00:00
Brad Fitzpatrick
e250d351ec go/packages: fix the build
Broken by CL 168657

Change-Id: I359d53c13eb470a5d95440d89b0cca3616b94f00
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168798
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-21 23:23:50 +00:00
Steven L
a94d7df2cb go/analysis/internal/checker: don't clobber fact when codeFact fails
`codeFact` returns `nil, err` on errors, which results in error messages like:

    panic: internal error: encoding of nil fact failed in [analyzer]

Though that and the stacktrace are often enough to identify the cause, the nil
hides the actual source of the problem.

Change-Id: Iddcdee386a5c64c6567d2727ebe7a77fe21927e9
GitHub-Last-Rev: 92163c2a5a631817319c992f7445f86d95130514
GitHub-Pull-Request: golang/tools#78
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167997
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2019-03-21 21:13:22 +00:00
Michael Matloob
43e94f7338 go/packages: give a better error if 'go' is missing
If we can't execute the go command, check to see if it exists. If it doesn't,
say so in the error.

Fixes golang/go#29552

Change-Id: Iffd2db5fc8f1daa2e458eaa326b27d9a0d971b6b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168777
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-21 21:09:38 +00:00
Michael Matloob
86483bace6 go/packages: make error message for conflicting packages more clear
Make it slightly more clear that this is not a user error, but an
internal error.

Updates golang/go#30519

Change-Id: I7adb3b5bb1548eab8e46db48946d55f9d59a4311
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168657
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-21 21:07:48 +00:00
Michael Matloob
db798565ff go/analysis/passes/test: remove some false positives
Alternative build systems like blaze don't always provide a way to determine
the relationship between a package and the package it's testing. This means
that sometimes the check for misspelled Example function names over-reports
because it doesn't find the object being exemplified. Don't report errors
unless a object can't be found in any of the imports. This means that there
won't be any false positives though of course this comes at the cost of
false positives.

Change-Id: I7435eeb2333b6dd72e06bb6383fff2ac17bee845
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168404
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-21 21:05:29 +00:00
Colin Arnott
c5e06eb4cd go/packages: remove fallback listfunc for Go 1.10.4
go list functionality changed in 1.11 and compatibility logic was added
to support 1.10 and before. Now that Go 1.12 has been released, support
for those version has ended and we can remove the legacy code.

Change-Id: Ifdd5c566dbbfe4fade5be27ad9ae20052d604c15
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166537
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2019-03-21 19:01:50 +00:00
Benjamin Peterson
ae772f11d2 third_party: remove
third_party only had JavaScript for cmd/heapview, which was deleted in 3c4dfba64b.

Change-Id: I7378e04e8eea74c32fcad4f7759b4e3b399faabc
GitHub-Last-Rev: 0f6ad4a47d85fe2ad00adb4b851ac01ba1881463
GitHub-Pull-Request: golang/tools#79
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168577
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-21 15:44:06 +00:00
Benny Siegert
3096223ce8 internal/lsp/cmd: fix regexp in test
The test fails if the GOROOT directory contains a dash, e.g. as in
/usr/lib/google-golang on corporate workstations, or on certain
builders.

Change-Id: If08c438764f4b76fff7fb43ccf3e4fd56afeff1a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168063
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-21 15:39:10 +00:00
Gergely Brautigam
36c10c0a62 x/tools/go/packages: seems to do nothing when given non-Go files
This CL fixes packages ignoring errors regarding files that have
non .go extensions. Packages can be called with just file names
or path which includes files. These aren't checked at all by
packages if they are go files or not, but it fails silently because
of it.

In more detail, go list fails with named files error in STDERR.
However, that is ignored, because go list notoriously abused STDERR
for non-error messages.

Fixes golang/go#29899

Change-Id: Ie4dc39da0b87200ebd23e6c607396557685e2807
Reviewed-on: https://go-review.googlesource.com/c/tools/+/164663
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-03-20 21:58:29 +00:00
Daniel Martí
b6b7807791 go/analysis: make stdmethods happy on encoding/xml
Historically, vet had always been unhappy about encoding/xml itself:

	method MarshalXML(e *xml.Encoder, start xml.StartElement) error should
		have signature MarshalXML(*xml.Encoder, xml.StartElement) error

This dates back to the time when vet couldn't depend on type
information. It compared the type expressions directly as strings, which
was a problem when the code was in encoding/xml itself. There, the
function parameters are *Encoder and StartElement, not *xml.Encoder and
xml.StartElement.

However, vet has been depending on type information for a while, so this
restriction no longer makes sense. The analyzer almost got it right, but
the only stopgap was a piece of the old code that tried to compare type
expression strings.

Remove it; typeString already deals with these edge cases for us. To
ensure vet remains happy with encoding/xml, add a very simple test for
it. The package now has zero reports, so the fact that its source has
zero "// want" comments is appropriate.

Finally, remove some long unused parameters from matchParamType.

Change-Id: Iab3ed57da7bc4a80522ae21e62b67e7828b97c89
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168058
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-03-20 16:06:34 +00:00
David Chase
3f1ed9edd1 go/gcexportdata: fix gcexportdata example for new compiler behavior
Initialization changes in
https://go-review.googlesource.com/c/go/+/161337
added a symbol, which was not 'expected output'.

Adjusted behavior to conform to expectations, since older
Go versions must continue to pass.

Fixes golang/go#30912.

Change-Id: If2f27ea29e20a03c5412f1999711a9208c3ca470
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168397
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-19 23:21:07 +00:00
Ian Cottrell
bb1270c20e internal/lsp: fix accepting line:colum forms to query definition
Change-Id: I425a9ebf77925b16fb7cb6fd5727d2377ab836b1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168178
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-03-18 20:07:14 +00:00
Ian Cottrell
a41300a290 internal/lsp: refactor query definition test to allow adding a new test
Change-Id: I360f21012f26118947dbac7c39e17c9c1f599379
Reviewed-on: https://go-review.googlesource.com/c/tools/+/168177
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-03-18 20:06:54 +00:00
Roger Peppe
63e6ed9258 cmd/stringer: compile error when constants change
When constant values change but stringer has not
been run again, we can get misleading string values.
Protect against this by generating code that will fail
with a compiler error when this happens.
Most compilers should be smart enough to omit the
code containing the checks.

Change-Id: I7a36d20f014cba0e7d88851d1b649a098ee30d76
Reviewed-on: https://go-review.googlesource.com/c/tools/+/163637
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-03-18 00:52:22 +00:00
Elias Naur
f0bfdbff1f internal/lsp,internal/lsp/cmd: skip tests on android
Change-Id: Idd9ddd32742a9f85096b71509511492b54538190
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167818
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-15 21:40:10 +00:00
Brad Fitzpatrick
658e28e1e6 cmd/stringer: add temporary(?) fix to get stringer test working in module mode
Updates golang/go#30874

Change-Id: I170ea99b3f06c8bc4cc624e86b80eeb852ea7115
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167771
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-15 20:35:58 +00:00
Heschi Kreinick
c74ccfb859 imports: handle missing main module
If GO111MODULE=on but there's no go.mod, GOMOD will be set to /dev/null
or NUL and there will be no main module. goimports should handle this
case roughly the same way the go command does.

Fixes golang/go#30855

Change-Id: I6fbf4c056000db5abd8788a6014ae5f13b1c8cd4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167860
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-15 20:09:29 +00:00
Michael Matloob
e6df0c1bb3 go/packages: run name query tests in a temporary directory
Some of the tests on the name query operate on test modules or module cache
trees that are checked in as testdata. When the tests run, they can modify
the go.mod files and the cache tree directories. Copy the directories
to a temporary directory to avoid getting spurious git diffs showing up.

Change-Id: I991a4510201988d596833faea88425a335d3228b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167859
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-03-15 19:15:01 +00:00
Ian Cottrell
2f43c6d1a2 internal/span: change to private fields
Change span to hide its fields and have validating accessors
This catches the cases where either the offset or the position is being used
when it was not set.
It also normalizes the forms as the API now controls them, and allows us to
simplify some of the logic.
The converters are now allowed to return an error, which lets us cleanly
propagate bad cases.
The lsp was then converted to the new format, and also had some error checking
of its own added on the top.
All this allowed me to find and fix a few issues, most notably a case where the
wrong column mapper was being used during the conversion of definition results.

Change-Id: Iebdf8901e8269b28aaef60caf76574baa25c46d4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167858
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-15 18:05:47 +00:00
Marwan Sulaiman
f59e586bb3 cmd/lsp: skip completion in string literals
This CL ensures that a "." inside a string literal will return an empty
completion list.

Fixes golang/go#30477

Change-Id: I1442d0acab4c12a829047805f745c4729d69c208
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167857
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-03-15 16:51:35 +00:00
Rebecca Stambler
8110780cfa internal/lsp: add correct handling for circular imports
This change brings back handling for circular imports, which was removed
because I originally thought that go/packages would handle that.
However, since we are type-checking from source, we still end up having
to deal with that.

Additionally, we propagate the errors of type-checking to the
diagnostics so that the user can actually see some of the problems.

Change-Id: I0139bcaae461f1bcaf95706532bc5026f2430101
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166882
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-15 16:49:21 +00:00
Rebecca Stambler
8b67d361bb internal/lsp: configure completion to preselect the first item
The language client must support the preselect feature, so as of right
now, I don't think that this change has any effect. However, ultimately,
we should preselect the first completion item we suggest, as we rank
items.

Change-Id: I977cce26157504595a0193ab551685e21a3df155
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167466
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-03-15 04:42:04 +00:00
Rebecca Stambler
8781451fe3 internal/lsp: propagate errors from in diagnostics
An ignored error in toProtocolDiagnostics could result in empty
diagnostics being (incorrectly) sent to the user.

Change-Id: I34c86a1f5bbf28888bedad094f596cc27a52b86d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167714
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-15 04:33:14 +00:00
Rebecca Stambler
1286b2016b internal/lsp: filter on insert text, not label
Change-Id: Ibd0c0c7af57cc8aeec56188cf52300f7c558adfe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167464
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-14 01:07:20 +00:00