1
0
mirror of https://github.com/golang/go synced 2024-11-18 22:14:56 -07:00
Commit Graph

1292 Commits

Author SHA1 Message Date
Michael Matloob
5e247c9ad0 go/packages: print gopackagesdriver errors when GOPACKAGESPRINTDRIVERERRORS is set
This is an analogue to GOPACKAGESPRINTGOLISTERRORS, and behaves much the same way.
I'm wondering if they should just be the same env variable.

Fixes golang/go#34649

Change-Id: Ic64cbbfdad2341448fb48e16d72835fb94046cb9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/204201
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-10-30 20:35:35 +00:00
Dominik Honnef
521f1f80fe go/packages: handle "outside module root" error printed to stderr by go list -e
Running `go ../...` fails if the glob refers to modules that lie
outside the current module:

$ go list ../...
go: pattern ../... refers to dir /tmp/foo, outside module root /tmp/foo/b

This is very similar to the "outside available modules" error you get
when not using globs.

Change-Id: I766af058d1ee685fdbfb4e60512a342437fecf14
Reviewed-on: https://go-review.googlesource.com/c/tools/+/202437
Run-TryBot: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-10-29 23:37:20 +00:00
Erik Dubbelboer
288d118ee9 go/analysis/passes/printf: allow # for b flag
Adding the `#` to a `b` flag is allowed and adds a leading `0b` to the output.

Change-Id: I421891f9478d1aaff2585455f38b3aa50e8277ab
GitHub-Last-Rev: 016896ad081bfc23f0c0a481042c90f028509831
GitHub-Pull-Request: golang/tools#182
Reviewed-on: https://go-review.googlesource.com/c/tools/+/203798
Reviewed-by: Erik Dubbelboer <erik@dubbelboer.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2019-10-29 17:11:02 +00:00
Ilya Sinelnikov
d78a1f2664 tools/go/analysis: Fix datarace in set of analysis.Fact
Fixes https://github.com/golang/go/issues/35098

Change-Id: I732edd5129de055138dc22e5e71f8ca3560d13e0
GitHub-Last-Rev: 3582f7669d70c48c5773ecf98f065f77be26c27f
GitHub-Pull-Request: golang/tools#179
Reviewed-on: https://go-review.googlesource.com/c/tools/+/202718
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-10-28 19:41:31 +00:00
Michael Matloob
e3efbe408c go/analysis: rename reportNodef to ReportRangef
This adds (or makes exported) a convenience function for reporting diagnostics with a
node directly (which is what folks usually want).

Change-Id: Ieb7ef2703f99d3a24ba7e48a779be62a7761cd0c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/180237
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-10-28 19:16:33 +00:00
Bryan C. Mills
b394bd8bba go/packages: do not return from goListDriver with goroutines still in flight
This fixes a race found in
https://storage.googleapis.com/go-build-log/0ae93896/linux-amd64-race_e84a66dd.log.

Change-Id: I6b928e3b96378d458b48cf1f27341775a3dd0601
Reviewed-on: https://go-review.googlesource.com/c/tools/+/203897
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-10-28 17:39:13 +00:00
Aaron Beitch
c8a4b8d038 go/analysis/passes/printf: return Result for querying func Kind
printf.Result has IsPrint function telling the caller if a function is
a Print/Printf function or a wrapper of one.

This aids in developing Ananlyzer's applying checks on Print/Printf
functions.

Implements @alandonovan suggestion from
https://github.com/golang/go/issues/29616#issuecomment-503277625

Change-Id: I203d51f1fcab7d8574d9309c22b404f8e3de43db
GitHub-Last-Rev: 5cb9115d21e89da8e75c5b207bfa1c512c315161
GitHub-Pull-Request: golang/tools#138
Reviewed-on: https://go-review.googlesource.com/c/tools/+/186317
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-10-28 16:16:07 +00:00
Bryan C. Mills
8715e36070 Revert "go/packages: temporarily disable some tests running on go tip with -race"
This reverts CL 200819.

Reason for revert: known races in dependencies have been fixed.

Change-Id: I7019055ea57b846d7546fbcc628fb341b7351a99
Reviewed-on: https://go-review.googlesource.com/c/tools/+/202538
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-28 14:32:39 +00:00
Rohan Verma
ff611c50cd go/analysis/passes/inspect: fix incorrect example
Fixes golang/go#35028

Change-Id: I2239b966fdc0b98b3c92f3d0987ce2fd26ea1b4a
GitHub-Last-Rev: 511c3beb15e96ac40f491f85c15438598b2d0f39
GitHub-Pull-Request: golang/tools#177
Reviewed-on: https://go-review.googlesource.com/c/tools/+/202817
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
2019-10-23 14:34:23 +00:00
Rebecca Stambler
ab6dbf99d1 go/internal/gcimporter: use empty string for the top-level package path
I made a mistake with the initial port of iexport.go in that I left the
original package path of the top-level package in the export data.
The package path for the top-level package should have been empty so
that it can be changed when the package is loaded.

Updates golang/go#28260

Change-Id: I781e63317a54eaf59385f25d18609e73ff97d572
Reviewed-on: https://go-review.googlesource.com/c/tools/+/201097
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-10-22 17:41:49 +00:00
Rebecca Stambler
44c9a601ac go/packages: create Imports map when creating package
Fixes golang/go#35035

Change-Id: I44a0a24592005aa2aa60401cde8a1eab372f3492
Reviewed-on: https://go-review.googlesource.com/c/tools/+/202537
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-10-21 20:10:49 +00:00
Dominik Honnef
ce0314c87e go/analysis, internal/lsp: add support for related information
This CL adds support for "related information", which allows
associating additional source positions and messages with a
diagnostic.

Change-Id: Ifc0634f68c9f3724b6508dc6331c62c819a24f78
Reviewed-on: https://go-review.googlesource.com/c/tools/+/200597
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-10-21 19:00:55 +00:00
Caleb Spare
04252eccb9 go/analysis/passes/printf: allow %x/%X for float/complex types
These verbs are supported as of Go 1.13.

Updates golang/go#34993

Change-Id: Ib7892e45b51073e3771bebb652a8fe3a1c6ae3c6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/202041
Run-TryBot: Caleb Spare <cespare@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-10-18 20:32:02 +00:00
Michael Matloob
341939e086 go/packages: fix ad-hoc package tests
Make sure that the user's environment doesn't affect the adhoc package
tests. Noticed that one test failed with GO111MODULE=on, so added a hack
to try and support that case. Not sure if that's the right approach.

Fixes golang/go#33374

Change-Id: I373cd57b9982cd46193c61d08e262fd50b5b7e18
Reviewed-on: https://go-review.googlesource.com/c/tools/+/195319
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-10-18 00:00:36 +00:00
Rebecca Stambler
de666e9706 internal/lsp: add a test to make sure we handle bad imports
There was a regression where gopls would not type-check any package with
a bad import. This change fixes the regression and adds a test to make
sure it doesn't happen again.

Change-Id: I3acf0917d46e9444c20135559f057f0ecd20e15b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/201539
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-10-17 20:52:05 +00:00
Rebecca Stambler
a3bc800455 go/expect: support markers in comments in go/packagestest
This is specifically necessary to test CL 197879.

Change-Id: I2b4bbdd322d52097fc1444242d3e26a3d8ea75e7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/201520
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-10-17 15:15:54 +00:00
Rebecca Stambler
eec4c98bf5 go/packages: fix staticcheck warnings
Ran gopls with staticcheck enabled and found these warnings.

Change-Id: I0b41c0daa19ac98c778d643530c9cb3f5f994399
Reviewed-on: https://go-review.googlesource.com/c/tools/+/201442
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-10-16 22:20:41 +00:00
Rebecca Stambler
6f5e27347a go/packages: handle invalid files in overlays
This change handles a specific case where `go list` returns an error on
a file that lacks a package declaration. If only one package is returned
as a response, we should add that file to that package, since it may
have valid content in an overlay.

This change uses the internal/span package to correctly parse the error
message from `go list`.

Change-Id: I5909c4fd765746df1003685aa915b7c5f9cdcee5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/201220
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-10-16 22:16:03 +00:00
Michael Matloob
ba31bb9056 go/analysis: remove requirement for unique Analyzer names
It's hard to prevent two independent analysis writers from
using the same name so enforcing this requiremnet just
causes trouble for analysis writers. Remove the requirement.

It would be nice to guarantee that two packages don't introduce
analyses with the same name, but because analyses are values
and not types, they don't have a logical package.

Change-Id: Iad3493e02ceae04ba3e9015c3e9c68ed9fa4b5a2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/201218
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Dominik Honnef <dominik@honnef.co>
2019-10-16 18:38:41 +00:00
Rebecca Stambler
89dd9f8220 go/packages: handle multiple modules in gopackagestest
Adding a second module to the gopackagestest configuration exposed a
flaky failure. go/packages was attempting to construct an ID relative to
a module. Depending on which module it saw first, it could construct a
relative path based on the incorrect module. Add an additional module to
the overlay tests to make sure we don't regress here.

Also, fix up a few staticcheck errors that were spotted along the way.

Change-Id: I53c2c0eee62ff88eadcb96a3770452dd7799312e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/199645
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-10-16 18:04:19 +00:00
Michael Matloob
539cdc44f8 go/packages: temporarily disable some tests running on go tip with -race
A change in go/types has uncovered a race in go/packages. While we debug,
ignore those tests when running on tip with -race to make the builders
green. This change will be reverted as soon as the issue is fixed.

Updates golang/go#31749

Change-Id: I96f0b30a1bc203a5c36a2ce30c943583b7f8035a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/200819
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-10-14 17:20:00 +00:00
Michael Matloob
4c025a95b2 go/packages: make a copy of the config.Env slice in the test.
Before this change, we were "saving" config.Env and then appending
to it to create a new slice, like so:

  savedEnv := config.Env
  ...
  // for each test case
    config.Env = append(savedEnv, additionalValue)

but we're modifying savedEnv during each env. Even though it might
work, it's not doing what we expect. Clean this up.

Change-Id: Idcf8199d836241df2b934308863512c566c0c485
Reviewed-on: https://go-review.googlesource.com/c/tools/+/200769
Run-TryBot: Michael Matloob <matloob@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-10-11 21:18:36 +00:00
Brad Fitzpatrick
b090f1f240 go/analysis/passes/asmdecl: remove amd64p32 support
Updates golang/go#30439

Change-Id: I46c7de8d16c3470f2f20a4d0e03b74bb38c8aff0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/199500
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-10-09 21:34:38 +00:00
Michael Matloob
43d3a2ca2a go/packages: update tests to reflect changes in golang.org/cl/198459
That change changes the name of an ad-hoc package go list produces
to contain the names of the files instead of just being called
"command-line-arguments". It also means go list will report multiple
packages for an ad-hoc package that's not saved on disk that contains
multiple sources.

Update test cases that depend on this behavior.

One thing to be aware of: the change in go list (without additional
changes in go/packages) will break users depending on ad-hoc
packages with multiple files, when the any of the  files don't exist
on disk. We're not adding a work-around in this cl because overlays
aren't guaranteed to be 100% correct and the LSP doesn't need this
functionality. If this turns out to be a problem we can fix it.

Change-Id: I342cd3cb54bf35992186ee02ddd9ac316ff1db4f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/199097
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-10-04 21:17:43 +00:00
Matts966
d89860af3b go/analysis/analysistest: fix nil pointer dereference when sorting facts
Without this change, we can't use `ExportPackageFact` function with analysistest package.

PackageFacts are keyed by nil and analysistest.check crashed while sorting, due to a nil object dereference.

Change-Id: Ic94c71acc9c74012bf150e1d72e937da8dfdff75
GitHub-Last-Rev: 51c91008a6756e66c630bfeabc9b8da08c12bfdd
GitHub-Pull-Request: golang/tools#163
Reviewed-on: https://go-review.googlesource.com/c/tools/+/196758
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-10-04 19:10:47 +00:00
Rebecca Stambler
b22818684c go/internal/gcimporter: support Go versions < 1.11
Fixes golang/go#34689

Change-Id: I7ab6c5a00c24a188b2dbd75160091cf6c834bd6a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/199037
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-10-04 18:21:43 +00:00
Rebecca Stambler
72853e10c5 go/internal/gcimporter: handle the possibility of a nil fileset
This panic was found by running the gopherjs tests:
https://circleci.com/gh/gopherjs/gopherjs/1767.

Change-Id: Ica97f31d20bbbd541b40ae3fd17594238883706a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/198857
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-10-04 05:50:02 +00:00
Rebecca Stambler
246a69f4f1 go/gcexportdata: use IExportData when writing gcexportdata
Updates golang/go#28260

Change-Id: Id0ef98e1599fbef4dd67ba23c20ddb8bc4d33228
Reviewed-on: https://go-review.googlesource.com/c/tools/+/198742
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-10-04 02:16:33 +00:00
Denis Isaev
4414aad16c go/ssa: make a setNumable interface
Workaround crash on go/ssa in go < 1.13.
See https://github.com/golang/go/issues/29612.

Change-Id: I32687f6ee0baaf223248d5c1631663c73cbbfc65
GitHub-Last-Rev: 6bf28bf927cff6d53bcfaf199701e5451d17305e
GitHub-Pull-Request: golang/tools#162
Reviewed-on: https://go-review.googlesource.com/c/tools/+/195477
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-10-01 17:08:58 +00:00
Matthew Dempsky
db0687cefd go/internal/gcimporter: support reading column details from export data
Mirrors the changes in the main repo.

Updates golang/go#28259.

Change-Id: I0cc9bc2f120d513f2f3d4ab503981c653e4ee7c2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/197678
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-27 18:38:43 +00:00
Hasit Bhatt
e4ea94538f go/analysis: fix vet errors
Updating tools version in go fails the builds due to go vet errors as it can be observed in https://golang.org/cl/196843.

Fix vet errors in facts.go and assign.go

Updates golang/go#34062

Change-Id: I8e5a819a08d0bdc91c4fb21761065f026581bcd2
GitHub-Last-Rev: 57d832932859360d4668711ab6b46ac8cdd2e010
GitHub-Pull-Request: golang/tools#164
Reviewed-on: https://go-review.googlesource.com/c/tools/+/197338
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
2019-09-25 21:18:24 +00:00
alkiller22
7460b8e10b cmd/vet: fix a bad case of shadow check about redeclaration
`go tools vet -shadow` ignored the case like this form
```golang
func shadowBlock() {
    var a int
    {
        var a = 3
        _ = a
    }
    _ = a
}
```
This commit fix it on "idiomaticRedecl" func, and add the code above in testcase.

Change-Id: I007f8287766f59cd7ded86072ba6bf6743c392be
GitHub-Last-Rev: b8b302b2048d709a39fb17496ba80917f9f4c889
GitHub-Pull-Request: golang/tools#143
Reviewed-on: https://go-review.googlesource.com/c/tools/+/189158
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-19 03:18:56 +00:00
Rebecca Stambler
2c1181b567 go/packages: fix overlay deps for packages with test variants
This change handles the case when an import gets added in an overlay a
package with a test variant. Previously, we would only add that
dependency to the test variant of the package.

Fixes golang/go#34379

Change-Id: I82c3d72d7c2d0b970fb27c1aea5be71783b83764
Reviewed-on: https://go-review.googlesource.com/c/tools/+/196259
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-09-18 21:04:43 +00:00
Heschi Kreinick
68f92b6635 go/packages: remove go.mod files
Files named go.mod define a module boundary and punch a hole in the
repository when the module is fetched with go get. We had a couple in
testdata. Get rid of them.

In one case the changes I made to produce a module cache in packagestest
were enough. In the other, the test needs multiple minor/patch versions
of the same module, which we have no provision for. Rename them to
"definitelynot_go.mod" in the repo and fix it up in the test.

Updates golang/go#34352

Change-Id: I284578b3aebb0f1fec3ddb4bef0df24f050d0636
Reviewed-on: https://go-review.googlesource.com/c/tools/+/196258
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-18 20:53:24 +00:00
Michael Matloob
567d1c21dc go/packages: fix a small spelling mistake
Change-Id: I06478ae275c25c2acfc26875a175799ed2507f65
Reviewed-on: https://go-review.googlesource.com/c/tools/+/195066
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-18 20:39:58 +00:00
Than McIntosh
6c790d6458 go/internal/gccgoimporter: update package to match std lib version
Import changes from std lib version, specifically

   https://golang.org/cl/194565
   https://golang.org/cl/194440

related to handling of embedded fields in pointer loops.

Change-Id: I7218e39d67ada728accd707b11fced6ed52f5fa2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/195958
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-17 14:45:18 +00:00
Johan Brandhorst
31e00f45c2 go/analysis: add sortslice pass
The sort.Slice method accepts an empty interface as its first
argument, but a slice type is the only valid use of the method.
This analyzer adds a diagnostic if the user uses the sort.Slice
method with anything other than a slice type as the first argument.

Change-Id: I3b54873faba2e9c2e832223a3cdab15a0b534650
Reviewed-on: https://go-review.googlesource.com/c/tools/+/191598
Run-TryBot: Johan Brandhorst <johan.brandhorst@gmail.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-09-14 23:59:51 +00:00
Michael Matloob
3720d1ec36 go/packages: suppress go list -e error when directory outside modules
If an absolute directory path being listed is outside any modules,
go list -e returns a non-zero exit status and non-empty stderr, but
should suppress the error. This was causing a weird bug when golang.org/cl/186337
was submitted because that changed the conditions when -export was passed,
which in turn affected how we suppressed the go list -e error (because
-export causes a compile it overtriggers errors, so we explicitly
suppress errors in that case). The way the error was being suppressed,
no error was generated, and no fake package was generated (which go list
is supposed to do), so the contains query fallback code wasn't run.

Fixes golang/go#34265
Updates golang/go#34273

Change-Id: I1213cff0e03a62c6976e50db5b2d805aa3ddbb7a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/195065
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-12 21:56:17 +00:00
Michael Matloob
22c3443cad go/packages: fall back to loading from export data if sources are missing
When a user asks Syntax or TypesInfo, we need to typecheck from sources.
If the sources are missing fall back to trying to load from export data,
but still report an error.
This will help in some cases where the driver has incomplete data.

Change-Id: I3b23e90a5cd865c5f729e50f09f5fadff2d32994
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194683
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-12 15:29:02 +00:00
Denis Isaev
7dd31af5a6 go/packages: allow types loading without NeedDeps
Before separating Load* into Need* we could use LoadSyntax
to get types information by loading inital packages
from source code and loading it's direct dependencies from export data.
It was broken when separation was introduced and before this commit
everything was loading from source code what resulted into slow
loading times. This commit fixes it.

Also, do backwards-incompatible fix of definition of deprecated
LoadImports and LoadAllSyntax.

Improve an internal error message
"internal error: nil Pkg importing x from y": replace it with
"internal error: package x without types was imported from y".

Remove packages.NeedDeps request for loading in tests
TestLoadTypesBits and TestContainsOverlayXTest.

Fixes golang/go#31752, fixes golang/go#33077, fixes golang/go#32814,
          fixes golang/go#31699, fixes golang/go#31930

Change-Id: I416e3c1035d555d67039e45a4fdd1deb9b2184ef
GitHub-Last-Rev: 2e3a46e6572d100ace486af33dcde45288cced46
GitHub-Pull-Request: golang/tools#139
Reviewed-on: https://go-review.googlesource.com/c/tools/+/186337
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-09-11 20:03:32 +00:00
Ainar Garipov
feee8acb39 all: fix more typos
Change-Id: I978ad5e1800ebfceb78aaced438331a8341715d4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194697
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-11 15:13:14 +00:00
Rebecca Stambler
c9a5ac55f0 go/packages: add a test case for golang/go#33374
Change-Id: Iea94f3fd4ec2faa67a26176250e20f98d693f91d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192260
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-09-10 23:27:45 +00:00
alandonovan
c1ad8a4bd1 go/analysis: copyedit doc.go
Change-Id: I586a698d5026805faa5ae637eebdae565f220ae3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194557
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-10 16:19:12 +00:00
Michael Matloob
75be6cdcda internal/lsp: enable suggested fixes by default
Remove the wantSuggestedFixes flag, and run the flagged code
by default.

Add test cases for suggested fixes.
Generate a suggested fix to the assign analysis that suggests removing redundant assignments.
Fix the propagation of suggested fixes (using rstambler's code).

Change-Id: I342c8e0b75790518f228b00ebd2979d24338be3b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193265
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-09 19:40:07 +00:00
Michael Matloob
61375c9358 go/packages: ignore any go list errors that seem to come from cgo
This may overtrigger if there are errors other than cgo errors in
the output, but in general, we can't parse the errors output by
cgo. Long term, we should fix go list to suppress cgo errors when
run with -e.

Fixes golang/go#33937

Change-Id: Iad7472e41eb9ad1cdee32098649be75764f05521
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192330
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-09 18:32:57 +00:00
Ainar Garipov
5b82db0742 go/analysis: fix typos
Change-Id: I07235ffba66bf0f7ef0e1917c6f711d317c9ae02
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194139
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-09 03:06:54 +00:00
Tobias Klauser
4c50eace5a all: add a space before +build in build tag comments
Add a space before build tag comments so it corresponds to the format
documented at https://golang.org/pkg/go/build/.

Change-Id: I72a0f72ca422f15688b2d7991f82b2361c21fb17
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194138
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-09-08 12:23:18 +00:00
Michael Matloob
958971f5c2 go/ssa/interp: skip recover2 testcase
The test case (taken from the go distribution itself) seems to be broken
when run against tip. Disable it when run against tip.

Updates golang/go#34089

Change-Id: I47d2e12ca39bc060fe0a0c967e95b900bdd0d725
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193377
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-04 21:37:38 +00:00
Michael Matloob
573d992605 go/analysis/doc: fix stuff that was left out of the previous commit
I forgot to add the section on supplying AST nodes directly.

Change-Id: Ibf9930693cf32542832b21a95621224c8d68e0f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192682
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-30 22:31:41 +00:00
Michael Matloob
8fa7b020d0 go/analysis/doc: provide more motivation for suggestedfix design
Change-Id: I8139010883357616bf6bfd76b62debe00267164b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192681
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-30 22:15:19 +00:00