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

3017 Commits

Author SHA1 Message Date
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
Josh Bleecher Snyder
4ccd092f47 cmd/compilebench: generate separate mem profiles when using -count
When the -count flag is provided,
instead of having each run overwrite the previous profile,
add a count suffix to the profile filename.

Then you can combine the profiles with

go tool pprof `go tool -n compile` <all profile files here>

This was done for CPU profiles in https://golang.org/cl/39718.

Change-Id: I4aa66d745fe18088655fc1d9cf3ecf29f68370bb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166523
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-03-14 00:31:01 +00:00
Rebecca Stambler
a10017ccd2 internal/lsp: handle common nil pointer exceptions
We may encounter these nil pointer if go/packages cannot find the
package of the given file, for example, when the user creates a new file
or a new package.

Change-Id: I16993017243a56332dd9f7e0aaf3c1d57f20fc3a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167462
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-13 23:43:22 +00:00
Ian Cottrell
48d47c461c internal/span: fix utf16 column when span is line based
A span with column 0 is intended to mean the start of the line, which in utf16
mode must be the 1st character

Change-Id: I4b98fe86528b889bbfe4b5ed3ae79c4da81017b1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167459
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-13 22:14:19 +00:00
Ian Cottrell
dbad8e90c9 internal/lsp: convert to the new location library
This rationalises all the position handling and conversion code out.
Fixes golang/go#29149

Change-Id: I2814f3e8ba769924bc70f35df9e5bf4d97d064de
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166884
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-13 19:34:21 +00:00
Rebecca Stambler
d55b9fb8ef internal/lsp: stop providing insertText for completion items
InsertText is deprecated, and it seems that providing both InsertText
and TextEdits causes unexpected behavior from VSCode. Avoid this by
providing only TextEdits.

Fixes golang/go#30796

Change-Id: Ieb5ad2fecd6f7083a4c1bc402634893c7e6ff49f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167457
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-13 18:39:08 +00:00
Ian Cottrell
516ab0aa77 go/packages/packagestest: add Exported as a type expectations can use
This is mostly to allow access to exported file contents for tests
that need the source.

Change-Id: I0ef946d7bdd971b931e509d2cb54e2c59649fe47
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166883
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-13 15:35:39 +00:00
Rebecca Stambler
e65039ee41 internal/lsp: make sure completion items are never null
Change-Id: Ic6e0988319f8fb2c91b473ac2fa5480dc25dc0b7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167158
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
2019-03-12 17:02:43 +00:00
Rebecca Stambler
7b79afddac internal/lsp: add a source.Package interface
This change adds a Package interface to the source package, which allows
us to reduce the information cached per-package (we don't use any of the
unnecessary fields in a *go/packages.Package).

This change also adds an analysis cache for each package, which is used
to cache the results of analyses to avoid recomputation.

Change-Id: I56c6b5ed51126c27f46731c87ac4eeacc63cb81a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/165750
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-12 16:49:27 +00:00
Peter Weinberger
0bb0c0a6e8 tools/internal/lsp/protocol: generate LSP protocol types from source
The existing code implementing the jsonrpc LSP (language server protocol)
relies on hand-translated definitions for the needed Go data types.
Unfortunately Microsoft makes changes, not always backwards
compatibly. This code generates the Go data types directly from the
Typescript source.

Adapting gopls to the new data definitions will happen in a future CL.

Change-Id: I032c69a16b6f2614370765dcd6dbdb38e9f40ab6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166277
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-12 15:15:45 +00:00
Peter Weinberger
6a988fd03a tools/cmd/gopls: modify gopls to use automatcally generated types
Gopls presently uses hand-coded data types (in internal/lsp/protocol)
for communicating with LSP clients. Instead, modify it to use the
automatically generated file (internal/lsp/protocol/tsprotocol.go).

Replaced files have been put (temporarily) in a directory 'preserve'
so readers can compare the old data types with the new ones.

Change-Id: Idfa53a5783e2d6a47e03b20641dd76fbc2c32677
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166757
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-12 15:13:52 +00:00
Josh Bleecher Snyder
c0c382bb4e go/ssa: fix import in comment
Change-Id: I55c5d407079afa0137f931c983ebef76ec194413
Reviewed-on: https://go-review.googlesource.com/c/tools/+/164643
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-03-12 14:13:10 +00:00
Ian Cottrell
5c2858a9cf internal/lsp: adding utf16 handling to the span package
Change-Id: Icf8a531c4257e31178beea8f98b755648938fa7a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166777
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-11 21:50:38 +00:00
Michael Matloob
11955173bd all: update golang.org/x/net dependency in go.mod
x/net now has a smaller set of transitive module dependencies, and
with this update, x/tools will also have a smaller set of transitive
module dependencies.

Change-Id: Idaa0bb72bf896bb8addc0004f17c3e97f8cc8b7a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166877
Run-TryBot: Michael Matloob <matloob@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-03-11 21:29:46 +00:00
Ian Cottrell
6eedde5c1d internal/lsp: using a non line based applyEdits in tests
Change-Id: Ibbef0a74b53a95d0b08fae6e8ef24be8b0f78273
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166881
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-11 21:20:53 +00:00
Ian Cottrell
de4a0b36f1 internal/lsp: allow end of file byte offsets
Change-Id: I46d7e07a4603f19f615fed2e37e733573ea0fe08
Reviewed-on: https://go-review.googlesource.com/c/tools/+/166880
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-11 21:20:38 +00:00
Rebecca Stambler
00c44ba9c1 internal/lsp: add cache for type information
This change adds an additional cache for type information, which here is
just a *packages.Package for each package. The metadata cache maintains
the import graph, which allows us to easily determine when a package X
(and therefore any other package that imports X) should be invalidated.

Additionally, rather than performing content changes as they happen, we
queue up content changes and apply them the next time that any type
information is requested.

Updates golang/go#30309

Change-Id: Iaf569f641f84ce69b0c0d5bdabbaa85635eeb8bf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/165438
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-03-08 17:45:44 +00:00
Ian Cottrell
b40df0fb21 internal/span: adding a source location package to unify the pos conversions
This implements a standard way of describing source locations along with
printing and parsing of those locations and conversion to and from the token.Pos
forms.

Change-Id: Ibb3df0a282bc2effb0fa8bd3a51bb0d281b2ffb1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/163778
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-03-08 14:21:31 +00:00