Commit Graph

6454 Commits

Author SHA1 Message Date
Tim King 46bc274e02 go/ssa: Update callee for wrapper function instantiation.
Updates golang/go#48525

Change-Id: Iee30bee08f124118d22524e276762389c8358244
Reviewed-on: https://go-review.googlesource.com/c/tools/+/400374
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2022-04-15 16:11:44 +00:00
Xiaodong Liu 884ffcdf16 go/analysis: add support for loong64
On loong64 stack pointer register (SP) is R3 and link register is R1.

Updates golang/go#46229

Co-authored-by: Meidan Li <limeidan@loongson.cn>
Change-Id: I5a47e53846a24934f786655dbe2c2b164aece5c4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/356089
Run-TryBot: Ian Lance Taylor <iant@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-04-14 18:02:41 +00:00
Brad Fitzpatrick afc6aad76e go/packages: make loadFromExportData ignore go.shape
From Reilly Watson <reillywatson@gmail.com> (previous CLA)

Fixes golang/go#51629

Change-Id: I5891aa568d66d9471488a957e45a2fa22a58e0a4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/400034
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-13 17:03:36 +00:00
Bryan C. Mills b7d757405f internal/lsp/protocol: avoid replying with non-nil interface values in case of error
The JSON-RPC 2.0 protocol requires that responses objects
have either a "result" or an "error", but not both.
In Go, this corresponds to a non-nil result interface value or a
non-nil error.

However, the generated wrappers for the LSP protocol were passing
non-nil values for both in case of error, due to passing typed-nil
pointers as (non-nil) interfaces (see
https://go.dev/doc/faq#nil_error).

This change fixes the generator to explicitly pass only one or the
other, and re-runs the generator at the existing commit.

For golang/go#49387
For golang/go#46520

Change-Id: I582b52820bdac15d9f947e8d6c1e9daa70c53e40
Reviewed-on: https://go-review.googlesource.com/c/tools/+/388600
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-13 01:06:48 +00:00
Carlos A Becker 1f10767725 gopls/doc: update neovim examples for nvim 0.7
On neovim 0.7-dev `apply_workspace_edit` needs the encoding.

This PR updates the organize imports documentation example.

This does not break neovim v0.6+. Haven't tested in <=v0.5.

refs https://github.com/neovim/neovim/issues/14090

Change-Id: I82a08c54dd94e6aacb5aa30a19a1fa209ef5264b
GitHub-Last-Rev: f4072a0eec9c14a0efd618c1835e0d99c4a2d6f4
GitHub-Pull-Request: golang/tools#375
Reviewed-on: https://go-review.googlesource.com/c/tools/+/390417
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 22:37:10 +00:00
Bryan C. Mills a22008757f internal/lsp/protocol: ignore reply values with non-nil errors in jsonrpc2_v2 adapters
The documentation for jsonrpc2.Replier states that
“[i]f err is set then result will be ignored.”

jsonrpc2_v2 documents no such affordance, and the JSON-RPC 2.0
protocol explicitly requires that the result “MUST NOT exist if there
was an error invoking the method.”

Although CL 388600 already avoids returning values in case of error
(which may also help with escape analysis and/or allocation
efficiency), it seems simplest and least confusing to make the
semantic difference between the jsonrpc2.Handler and
jsonrpc2_v2.Handler explicit in the code.

For golang/go#46520.

Change-Id: If13eb842505d42cbc51c01f5f5e699a549a3a28b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/400054
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-12 20:21:55 +00:00
Russ Cox d5f48fca53 all: gofmt
Gofmt to update doc comments to the new formatting.

(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs. This is the leftovers.)

For golang/go#51082.

Change-Id: Id9d440cde9de7093d2ffe06cbaa7098993823d6b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399363
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 17:53:17 +00:00
Russ Cox d996daab27 go/ssa: gofmt
Gofmt to update doc comments to the new formatting.

(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs.)

For golang/go#51082.

Change-Id: I58a534f3e518dad2d3a867f81b08a551a76bd423
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399362
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 17:48:54 +00:00
Russ Cox f9c13bbb3d go/pointer: gofmt
Gofmt to update doc comments to the new formatting.

(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs.)

For golang/go#51082.

Change-Id: I5e11f2946001b9b36b7bd3af4d42da9dcea7494f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399361
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 17:46:27 +00:00
Russ Cox ad8ef159e2 go/callgraph: gofmt
Gofmt to update doc comments to the new formatting.

(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs.)

For golang/go#51082.

Change-Id: I229b90365998244cfa858ae678382f6089b1cdb9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399360
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 17:44:05 +00:00
Russ Cox ce1e683fa6 go/analysis: gofmt
Gofmt to update doc comments to the new formatting.

(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs.)

For golang/go#51082.

Change-Id: I77809c80838cc8f4cdf43c3c42685e2fc695328a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399359
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 17:43:14 +00:00
Russ Cox 2bbdb7a52e gopls, internal/lsp: gofmt
Gofmt to update doc comments to the new formatting.

(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs.)

For golang/go#51082.

Change-Id: Ife11502fe1e59a04d53dba9edccd3043e57f9ae8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399358
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 17:41:31 +00:00
Russ Cox 5fef6fdaed cmd: gofmt
Gofmt to update doc comments to the new formatting.

(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs.)

For golang/go#51082.

Change-Id: I0cc2e6cac2e4ed975770aea78cc2f39c13d6f874
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399357
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 17:38:38 +00:00
Zvonimir Pavlinovic 04fab9a0d9 go/callgraph/vta: avoids cycles for pathological recursive types
Helper type logic did not handle properly pathological recursive types
such as type B *B. This CL addresses that.

For golang/go#51560

Change-Id: Ibb69ac68d77fc3956b98c701f17d28b9f30ac22c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399674
Reviewed-by: Tim King <taking@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Auto-Submit: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-12 15:21:28 +00:00
Russ Cox fbebf43d9f go/internal: gofmt
Gofmt to update doc comments to the new formatting.

(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs.)

For golang/go#51082.

Change-Id: Ibb9d8a38c0bf6973419cb1efc13f0775000a607a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399364
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 05:50:31 +00:00
Tim King b900e88040 go/ssa: emit Low expression before High in *ast.Slice
Order of evaluation is lexical left-to-right order. Emit the Low subexpression before High subexpression when building an *ast.Slice.

Fixes golang/go#52142

Change-Id: If56a1c9ac12485717d2783efdf791fe24582b306
Reviewed-on: https://go-review.googlesource.com/c/tools/+/398057
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-12 01:29:39 +00:00
Robert Findley b2552ef554 internal/lsp: run go mod vendor exclusively to avoid file contention
Running go mod vendor can result in vendor/modules.txt being transiently
deleted while it is being updated. On Windows this introduces potential
problems with file locking, if modules.txt is being read by another go
process, such as an ongoing package load.

Change the command to use RunGoCommandPiped, which executes serially
within the gopls process.

For golang/go#49646

Change-Id: If2d1fe5431122ba05014051a0e9c303cf7ee9cb2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399714
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-11 22:06:59 +00:00
Robert Findley 9e788ee169 internal/lsp/fake: consider mtime when polling for file changes
When polling for on-disk file changes, we must detect changes even if
there is no change in the file since the last polling.

The reason for this is that there could have been intermediate changes
to the file that affected our calculations, and those calculations must
be invalidated.

For golang/go#51930

Change-Id: I92f5c34f982970d8386fddfaa22b82ba471e22e7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399625
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-11 22:00:47 +00:00
Tim King fe932b4680 go/ssa: Instantiate calls to generic functions and methods.
Instantiates calls to generic functions and methods from non-generic functions.

Testing against all of the compilable $GOROOT/test/typeparam/*.go tests. Adds stubs for standard libraries.

This is not yet building the bodies of the instantiated functions.

Updates golang/go#48525

Change-Id: I7e2c103c547edefb833a6930270b3137f89f1977
Reviewed-on: https://go-review.googlesource.com/c/tools/+/397854
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-04-08 14:45:41 +00:00
Tim King ce5936cd50 go/ssa: bound functions are now unique per instantiation.
Updates golang/go#48525

Change-Id: I028ee12c2b85bb4c1761e5255711eaab52912491
Reviewed-on: https://go-review.googlesource.com/c/tools/+/397794
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Trust: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-04-08 13:46:41 +00:00
Tim King 7dd9f20eba go/ssa: Adds datastructures for function instantiation.
Adds [unexported] fields to Function for Origin, TypeParams, and TypeArguments. Populates TypeParameters for package level functions and methods.

Adds datastructures for creating function instantiations. Tracking unique instantiations on Program.

Adds map for canonicalizing lists of types.

Updates golang/go#48525

Change-Id: I9cb01f2ed24a9cacf3a515444d0cc0474333e417
Reviewed-on: https://go-review.googlesource.com/c/tools/+/397714
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-04-08 13:27:25 +00:00
Peter Weinberger ee2bc8be3a go/ast/astutil: fix panic in DeleteNamedImport from line directive
DeleteNamedImport used FileSet.Position() where it should have
used FileSet.PositionFor(, false) to ignore line directives.

There are likely many more of these panics lurking in x/tools.

Change-Id: I11fc0ea5301fe873cb679a82e231b1720dbdaef6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/398596
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-04-07 18:59:33 +00:00
Bryan C. Mills 48e6d8d2ff cmd/fiximports: skip TestFixImports on plan9-arm
For golang/go#50775.

Change-Id: Ia7d99e9e7b007af3fa35332f0385949867e975eb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/398817
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
2022-04-07 18:45:34 +00:00
Bryan C. Mills 7f1077708f gopls/internal/regtest/modfile: temporarily skip TestSumUpdateFixesDiagnostics
This test is somewhat noisy on the builders.
I'd like to skip it until someone can look into it in more depth.

For golang/go#51352.

Change-Id: I2aa5c9c279807b57872324d84c1bb585cdf34d06
Reviewed-on: https://go-review.googlesource.com/c/tools/+/398699
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-04-07 15:21:45 +00:00
Robert Findley 7cc24c2ba3 gopls: upgrade staticcheck to v0.3.0
Upgrade staticcheck to v0.3.0 to pick up support for generics. Since
this version only supports Go 1.17+, increase the version at which we
install staticcheck to 1.17 (from 1.15). This change is likely to cause
confusion for users on Go 1.16, so show a warning when setting
the "staticcheck" option to an unsupported value. Slightly refactor our
setting of options along the way.

Fixes golang/go#52159

Change-Id: Id9b4cee340e31988c64ca712d98573343aaf5848
Reviewed-on: https://go-review.googlesource.com/c/tools/+/396974
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-04-07 14:59:24 +00:00
pjw 1f763dfd2e internal/lsp: add semantic tokens for arrows in declarations
Fixes: golang.org/#52024

Change-Id: Ib79a839f9bdeaef1250925add69dea3ae32e1cae
Reviewed-on: https://go-review.googlesource.com/c/tools/+/397479
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Peter Weinberger <pjw@google.com>
2022-04-07 14:52:22 +00:00
Tim King b3e0236d65 go/ssa: Track created functions in the builder.
Changes the builder to be stateful and track the Functions that were created while building the current Package [or MethodValue]. Additional bookkeeping is now done whenever a synthetic functions is created.

Adds an additional state to Function to track if it is done with the BUILD phase.

Moves (*Program).needsMethods from emitConv to a postprocessing phase in package BUILD phase.

Clarifies that anonymous functions are done at the same time as their parent.

Updates golang/go#48525

Change-Id: I09d1ed2abc95d252029917f49f783a3cfd9f0a78
Reviewed-on: https://go-review.googlesource.com/c/tools/+/396876
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-04-06 22:00:21 +00:00
Zvonimir Pavlinovic 673165911b go/ssa: adds position info to implicit field selection instructions
Fixes golang/go#51986

Change-Id: I1fa5868d70ae53f57b6c2bc0c4dbe4ac524b89e6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/396495
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
2022-04-06 18:19:46 +00:00
Peter Weinberger 74cea6e8cb internal/imports: ignore some line directives
This is a minimal fix for the reported panic. The existing code
used FileSet.Position() where it should have used FileSet.PositionFor(, false).

gopls does this in lots of places; each use of Position() needs to
be thought about.

x/tools/go/ast/astutil/import.go:273,274 is another example.

Fixes: golang/go#51916

Change-Id: I42de6affca2c97c09efb7974a9e44322556b3ffd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/398395
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Peter Weinberger <pjw@google.com>
2022-04-06 14:24:15 +00:00
Suzy Mueller 37acb39970 internal/lsp: run vulncheck in specified dir
The directory for the vulncheck command is passed
as an argument. Use the specified directory
in the configuration.

Change-Id: I1824b308701fd30548efa8bec7452de1fdf76bb9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/398394
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-04-05 17:18:24 +00:00
Dan Kortschak 4077921f14 all: fix spelling
Change-Id: I13cf73d7e043dda1a06c28bb09e413a76a68df1f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/391934
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-04-04 19:50:34 +00:00
Dylan Le ff66cbef33 internal/lsp: remove unused parameters from moduleAtVersion
Change-Id: I16ed074188fa5f670894778a89cea1a500ec5c7f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/397416
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Cherry Mui <cherryyz@google.com>
2022-04-04 16:32:51 +00:00
Bryan C. Mills 7d125fe075 cmd/callgraph: expand windows/arm64 skip to the whole platform
This test produces apparent file corruption on all of the
windows/arm64 builders. I suspect that this is a low-level bug (in
either the platform itself or the Go standard library on
windows/arm64).

Since windows/arm64 is not yet a first-class port, this test can be
skipped for now. However, if windows/arm64 becomes a first-class port
the underlying file-corruption bug should be investigated and fixed.

Updates golang/go#50706.

Change-Id: I0bc80cefee50895d40acc658286eb7ef8790493a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/397996
Reviewed-by: Russ Cox <rsc@golang.org>
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-04 15:58:39 +00:00
Pontus Leitzler 153e30b3c7 internal/lsp/lsprpc: only propagate explicit GOWORK when using remote
When using gopls remote, existing go env vars are injected in the
initialize message. Setting GOWORK explicitly will impact cmd/go
invocations, for example "go list" during package load. The reason it
impacts is that gopls manually sets PWD to fix paths returned by cmd/go
if the working directory is inside a symlinked directory.

By only propagate GOWORK when it is explicitly set we will ensure that
the behavior is the same when running with or without remote.

See golang/go#51823.

Fixes golang/go#51825

Change-Id: I6280aa7d8208e5aee269f19356668c7713e9f0a4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/394054
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-04-01 20:25:27 +00:00
hiroebe cda13e227d internal/lsp: fix incorrect line and start of semantic tokens
Current implementation returns incorrect result when some of the items are skipped, because positions could be relative to a skipped item. Instead, each position must be relative to the previous item added to the result.

Change-Id: I3c1a68d37bf0c9cfc1bccfe6f76c25b536224293
GitHub-Last-Rev: 6eedc7cbcc27f47ed5742b340f4438291ab70863
GitHub-Pull-Request: golang/tools#376
Reviewed-on: https://go-review.googlesource.com/c/tools/+/396715
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
Trust: Peter Weinberger <pjw@google.com>
Trust: Suzy Mueller <suzmue@golang.org>
2022-03-31 23:32:26 +00:00
Robert Findley 41787c4fe7 gopls: run go mod tidy -compat=1.16 to fix the 1.16 build
Change-Id: Idfa5fbd41720d6f12084fc351774fed5dc68c488
Reviewed-on: https://go-review.googlesource.com/c/tools/+/397356
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-31 21:49:24 +00:00
Charlie Vieth b9a48075ea internal/gopathwalk: remove unnecessary call to os.Lstat
internal/gopathwalk.walk remove an unnecessary call to os.Lstat when
checking if a symlink should be traversed. And remove a call to
filepath.EvalSymlinks that should be unnecessary as we are using
os.Stat to compare files.

Change-Id: Ie5ad1cb99cbd6d62f08f2b482a3e84b6fe41114d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/392095
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2022-03-31 05:33:07 +00:00
Tim King 8e193c2ba9 go/ssa: removes conversion of index value in Index and IndexAddr to int
Removes the forced conversion of the Index field in Index and IndexAddr to type int. ssa/interp now intprets indices as int64s instead of ints.

Converts untyped indices for strings to ints before the lookup.

Fixes golang/go#50949

Change-Id: Ib5d7f1ad28728d16c8e0a8411014d1209c62a3f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/387996
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Tim King <taking@google.com>
2022-03-30 17:49:40 +00:00
zhangyunhao 9d8009b6b7 go/analysis: validate report if analyzer.Run is empty
The Run function is necessary for an analyzer, if left a nil Run, the runner will panic in run-time(singlechecker.Main, etc).

Change-Id: Ibbeea2d8c740f73e6c083647df6ded445036e272
Reviewed-on: https://go-review.googlesource.com/c/tools/+/329451
Trust: Carlos Amedee <carlos@golang.org>
Reviewed-by: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-30 03:52:37 +00:00
Tim King 761e51fea3 go/ssa/interp: Adds reflect.DeepEqual model for interp testing
Implements reflect.DeepEqual() for testing interp packages. Adds test that exercises this.

Fixes a nil pointer dereference in ext۰reflect۰Value۰Elem in interp.

Updates golang/go#48525

Change-Id: Ib32e96d37aa5c85cefe59e9514d4e162d7f7011e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/391314
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Tim King <taking@google.com>
2022-03-29 21:53:41 +00:00
Hana e342718dfc gopls/internal/vulncheck: skip vuln entries without callstacks
Vulnerability entries that do not have call traces are
considered false-positives by govulncheck.

Change-Id: I50d7fc815723038e904805213cd039a05934a469
Reviewed-on: https://go-review.googlesource.com/c/tools/+/396434
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-03-29 17:29:50 +00:00
Robert Findley b22bc85c18 gopls/doc: update stale documentation on generics
Change-Id: I01b7bad40e466ef04450aae84d51b5cf47fa4a0e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/396435
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-03-29 16:50:19 +00:00
Russ Cox e693fb4172 go/internal/gcimporter: fix IImportBundle error text
When called from IImportBundle, the current code returns
a message saying:

	cannot import "" (actual error) ...

That looks like the user has somehow caused an invalid import path
to be passed, which is not the case. Skip the wrapping in the bundle case.

Change-Id: I6cdb83911d18501895671fc70d87c2519f0570a3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/310514
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 21:22:34 +00:00
Russ Cox ed5a15cbaa go/internal/gcimporter: replace assert with more helpful panic
If this code is misused, the result of the assert is

	panic: assertion failed

This CL replaces the panic text with a useful message.

Change-Id: I3710ebe975e7f1e907b0378e9c67dd0c224492fb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/310513
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 21:22:33 +00:00
Russ Cox f4515dde79 go/packages: fix load with NeedTypes but not NeedImports
Fixes golang/go#45584.

Change-Id: I65238cc3bdc640bb044c615a5699e8d3cfa39db0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/310512
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 21:22:31 +00:00
Russ Cox 11930bd9d7 go/packages: fix handling of NeedExportFile in go list
If we need the export file, can't use -find,
which stops the go command too early.

Change-Id: I82adca728e3e8a2435cddad14cfed97665ea4234
Reviewed-on: https://go-review.googlesource.com/c/tools/+/310510
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 21:22:29 +00:00
Russ Cox e0095ae32c go/packages: fix precedence typo in needtypes calculation
I haven't figured out exactly how to exercise it,
but the code as written is clearly wrong.

Change-Id: I8849bc37210d08ad8ae3bc857a84ae55b34908a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/310511
Reviewed-by: Austin Clements <austin@google.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 21:01:57 +00:00
Russ Cox e30967270c go/packages: rename NeedExportsFile to NeedExportFile
I'm going to use NeedExportFile in the go/gcexportdata example,
and we might as well start with the correct spelling.
Leave behind a deprecated alias to preserve compatibility.

Change-Id: Id26e5db58cb59a01ed7904ab801a894ea76edd9e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/310509
Reviewed-by: Austin Clements <austin@google.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 19:08:41 +00:00
Hana 54af36eca2 internal/lsp: handle invalid URL args in command params
beginFileRequest returns a nil error when file request url is
not a valid file url format. This is reported with a separate 'ok'
boolean return value.

This bug caused custom gopls commands to return success with
an empty result, instead of reporting the problem as an error.

Change-Id: I8eed39368087fa9928bcc68853225ea432f500d2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/395814
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 15:45:26 +00:00
Robert Findley 707beb0c63 internal/lsp/source: descend into fields and field lists in qualifyExpr
We do a lot of gymnastics to format var types, working around the lack
of alias tracking in go/types. As part of this, we clone and qualify
expressions. In this case, we were not qualifying identifiers that were
contained within fields or field lists.

Fix this by updating our expression traversal to include *ast.Field and
*ast.FieldList.

Fixes golang/go#50539

Change-Id: I6531c6a51aa402bd784778b8bedaa3dccee75af0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/395678
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 15:26:50 +00:00