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

8 Commits

Author SHA1 Message Date
Suzy Mueller
9bea2ecb95 internal/imports: refactor to split finding and applying fixes
A pass is responsible for fixing the imports of a given file. It now
finds the necessary changes to make without applying the result to the
ast, which may be desirable to give a user more control about what
changes will be applied to their program. This change splits the process
of finding the fixes from making the modifications to the ast to allow
this functionality to be easily possible.

Change-Id: Ibf8ca247c35539f91de4be90c634f0db9a939d07
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184197
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-07-02 14:45:09 +00:00
Rebecca Stambler
38ae2c8f64 internal/lsp, internal/imports: use the internal goimports library
This change modifies gopls to use the internal goimports library, which
allows us to manually configure the ProcessEnv. We also add a logger to
the ProcessEnv to allow this change not to conflict with gopls's logging
mechanism.

Fixes golang/go#32585

Change-Id: Ic9aae69c7cfbc9b1f2e66aa8d812175dbc0065ce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184198
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-07-01 19:45:22 +00:00
Heschi Kreinick
0945d3616f internal/imports: suggest x for x_tests
golang.org/cl/170238 forgot that it's okay for an x_test to import a
package in the same directory. Only skip the candidate if the package
we're looking for has the same name as the one being fixed.

Fixes golang/go#32440

Change-Id: I7806d9f4174ca217ac83887da5e23b28cd102095
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181338
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-10 21:48:47 +00:00
Heschi Kreinick
e9a20a1396 internal/imports: actually cache resolvers
I forgot to actually save the resolver instances...

Change-Id: Ieff4f22d29038895dc15be97491476f414544a5c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181337
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-06-10 16:54:38 +00:00
Heschi Kreinick
755ce86c76 internal/imports: fix TestNoMainModule
https://golang.org/cl/179998 made it an error to run go mod download
without args and without a go.mod. Don't do that.

Fixes golang/go#32488

Change-Id: Icd845feb8fecae69b6a8363438bb9ee546a310dc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181298
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-07 22:46:22 +00:00
Heschi Kreinick
d487f80763 all: GOSUMDB=off for tests that use fake modules
Users of packagestest will create modules that don't exist on the
Internet and can change. There's no point in checking sum.golang.org for
them under any circumstances.

Similarly for the various goimports tests.

Fixes golang/go#32216.

Change-Id: Id9a6b660564cb744530bf9d209fca19008fb9c4f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178722
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-24 18:48:02 +00:00
Heschi Kreinick
26647e34d3 imports: allow nil Options in Process
Forgot this case in CL 175437.

Change-Id: I9825cf010611fed9f47b1a87fc793bf3a5a36f68
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178257
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-20 22:08:59 +00:00
Heschi Kreinick
757ca719ca imports: rename to internal/imports
For various reasons we need an internal-facing imports API. Move imports
to internal/imports, leaving behind a small wrapper package. The wrapper
package captures the globals at time of call into the options struct.

Also converts the last goimports tests to use the test helpers, and
fixes go/packages in module mode to work with empty modules, which was
necessary to get those last tests converted.

Change-Id: Ib1212c67908741a1800b992ef1935d563c6ade32
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175437
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-05-20 21:49:35 +00:00