When displaying a diff the gorename command would panic because the
stdout variable was never set. These changes default stdout to
os.Stdout.
Fixes https://github.com/golang/go/issues/14009
Change-Id: I0902b2b4e2b8e1f46f8ab50e30dcfc841c925174
Reviewed-on: https://go-review.googlesource.com/18813
Reviewed-by: Alan Donovan <adonovan@google.com>
Cause: the absolute cwd, not ".", must be passed to build.Import.
Also: simplify the lookup logic in findFromObjects, and handle nil
gracefully.
(No unit test---not worth faking os.Getwd.)
Fixes issue #13866
Change-Id: I7e8eede55bc83d98e2ef5e42609c287e74c04501
Reviewed-on: https://go-review.googlesource.com/18453
Reviewed-by: Michael Matloob <matloob@golang.org>
(See https://go-review.googlesource.com/#/c/18450)
Details:
- delete buildutil.AllowVendor flag.
Instead use unexported 'go16' var in each package that needs it.
- delete buildutil.StripVendor; was never needed.
- remove inapplicable vendoring comments from loader14.go
- importgraph: go1.5: don't bother checking for 1.6 before calling
absolutize (minor simplifiication and deoptimization).
Tested on 1.4.1, 1.5, and ~1.6 (tip).
Change-Id: If692b0df2eb6c120a9c09d7b1ed99f1b4c6b0826
Reviewed-on: https://go-review.googlesource.com/18452
Reviewed-by: Russ Cox <rsc@golang.org>
A few files have been forked and tagged "go1.5,!go1.6" to work around
minor API changes between the two types packages:
- constant.Value.String() in oracle/describe.go and its tests;
- constant.ToInt must now be called before constant.Int64Val.
- types.Config{Importer: importer.Default()} in a number of places
- go/types/typeutil/import_test.go uses lowercase names to avoid 'import "C"'.
Files in go/types/typesutil, missing from my previous CL, have been
tagged !go1.5; these files will be deleted in February.
All affected packages were tested using 1.4.1, 1.5, and ~1.6 (tip).
Change-Id: Iec7fd370e1434508149b378438fb37f65b8d2ba8
Reviewed-on: https://go-review.googlesource.com/18207
Reviewed-by: Robert Griesemer <gri@golang.org>
This change will ensure that the tree continues to work with go1.4.1.
All files continue to depend on golang.org/x/tools/go/types, but in a
follow-up change, I will switch the primary files to depend on the
standard go/types package. Another (smaller) set of files will be
forked and tagged, this time !1.6, due to API differences between the
two packages.
All tests pass using 1.4.1, 1.5, and ~1.6 (tip).
Change-Id: Ifd75a6330e120957d646be91693daaba1ce0e8c9
Reviewed-on: https://go-review.googlesource.com/18333
Reviewed-by: Robert Griesemer <gri@golang.org>
Use an concurrency-limiting semaphore to reduce I/O parallelism in Import.
Also, start the producer in a new goroutine so that it runs in parallel
with the consumer. Paradoxically, this reduces the peak number of
goroutines.
Also, in buildutil.ForEachPackage, make the concurrency limiting
semaphore global, since I/O parallelism is a process-wide resource.
Change-Id: I282b717c50603361826e5675077c9f464c874132
Reviewed-on: https://go-review.googlesource.com/18215
Reviewed-by: Michael Matloob <matloob@golang.org>
The user may specify the diff tool using the -diffcmd flag.
+ test.
Also:
- eliminate redundant DryRun flag
- simplify Verbose messages using log.SetPrefix
Fixes issue #13355
Change-Id: I917edc73e31ddf0f5d5b9b30c43f826465529da1
Reviewed-on: https://go-review.googlesource.com/18208
Reviewed-by: Michael Matloob <matloob@golang.org>
Each string in build.Package.{,Test,XTest}Imports must now be
interpreted relative to the Package.Dir. This adds a ton of
redundant I/O.
Also:
- use a counting semaphore to limit concurrent I/O calls
(Fixesgolang/go#10306)
- remove obsolete call to runtime.GOMAXPROCS from the test.
Change-Id: Ic556c4cf41cce7a88c0158800c992e66f354c484
Reviewed-on: https://go-review.googlesource.com/18050
Reviewed-by: Russ Cox <rsc@golang.org>
Add an ;;;###autoload magic comment, so that the go-rename command can be used
without need to explicitly (require 'go-rename) first.
Change-Id: Ibdf9886fe98c55e1d948469aac972b568649f910
Reviewed-on: https://go-review.googlesource.com/16327
Reviewed-by: Alan Donovan <adonovan@google.com>
It is possible to reconstruct the lexical environment at any point
using only Object and Scope positions; see CL 9544 for an example.
Change-Id: I1268f9490c072ceb1c4d044df2e9c49678d73dfd
Reviewed-on: https://go-review.googlesource.com/14131
Reviewed-by: Robert Griesemer <gri@golang.org>
so that we can delete that package.
lexicalLookup reconstructs the lexical scope from the existing tree of
types.Scope blocks, using source position information to determine
which prefix of declarations are visible. (Inspired by Russ's
lookupAtPos in github.com/rsc/grind/grinder.)
forEachLexicalRef implements the part of the recursion from
refactor/lexical that enumerates the ast.Idents that use lexical
lookup. (I would still like to eliminate this redundant logic by
having go/types record environments, as in CL 9493.)
Change-Id: I040ab33b508aad2dc68fd48850fe92ec072045d1
Reviewed-on: https://go-review.googlesource.com/9544
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Rename the package name of the external test package, e.g. <from>_test to <to>_test.
Rewrite the import statements of external test packages which import the renamed package.
Fixes#10507
Change-Id: Iad702189469c54776e55ed4a821610bd9977618c
Reviewed-on: https://go-review.googlesource.com/12637
Reviewed-by: Alan Donovan <adonovan@google.com>
The optional Qualifier function determines what prefix to attach to
package-level names, enabling clients to qualify packages in different
ways, for example, using only the package name instead of its complete
path, or using the locally appropriate name for package given a set of
(possibly renaming) imports.
Prior to this change, clients wanting this behavior had to copy
hundreds of lines of complex printing logic.
Fun fact: (*types.Package).Path and (*types.Package).Name are valid
Qualifier functions.
We provide the RelativeTo helper function to create Qualifiers so that
the old behavior remains a one-liner.
Fixesgolang/go#11133
Change-Id: Ibd63f639c7b3aa1738826d6165f2d810efeb8293
Reviewed-on: https://go-review.googlesource.com/11692
Reviewed-by: Robert Griesemer <gri@golang.org>
And in gomvpkg, don't stop just because some packages had errors.
This is inevitable in a large GOPATH tree.
Fixes issue golang/go#10907
Change-Id: I9a60b070228d06d44880202eeef54394e914f5d5
Reviewed-on: https://go-review.googlesource.com/10715
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Match gofmt's behaviour of closing the status buffer. Don't display the
buffer in case of success as we were going to hide it instantly again,
anyway. Also, instead of using delete-window, use
gofmt--kill-error-buffer. gofmt--kill-error-buffer uses quit-window if
there's a window for the buffer, kill-buffer otherwise.
quit-window only deletes the window if it was created explicitly for the
status buffer and if it is still displaying it. This way, we won't close
windows that the user created or repurposed himself.
Additionally, this change ensures that we don't leave a *go-rename*
buffer lying around when gorename succeeded.
Fixesgolang/go#10972.
Change-Id: Id1efb60d399f0062d870e925138aa827e12f3e58
Reviewed-on: https://go-review.googlesource.com/10453
Reviewed-by: Alan Donovan <adonovan@google.com>
This was not a visible bug since the only caller discards the relevant
result, so I also deleted the result.
Fixes#9999
Change-Id: I276d6523b2891d3cb9c8137448e1aed32a5fd197
Reviewed-on: https://go-review.googlesource.com/5921
Reviewed-by: Michael Matloob <michaelmatloob@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
This avoids littering the tree, and confusing some editors (e.g. Atom)
that expect the inode number to remain constant.
Change-Id: I2faeda1ed1b01e5e4cc720744ea3c99ab29e7333
Reviewed-on: https://go-review.googlesource.com/7664
Reviewed-by: Robert Griesemer <gri@golang.org>
The callbacks are intentionally concurrent, making this function very
easy to misuse (most clients so far have got it wrong, even my own).
Using a channel in the API makes the concurrency obvious, the
correct usage easy, and the client control flow simpler.
Change-Id: Ied38c3ed5c98b40eb1b322a984ed9dc092ac0918
Reviewed-on: https://go-review.googlesource.com/3250
Reviewed-by: Sameer Ajmani <sameer@golang.org>
...since the zero value is more useful by far.
This is a breaking API change, obviously. (One or two tests in this
CL have intentional been left using the zero value, i.e., they now
load source.)
Change-Id: I42287bfcdb1afef8ee84e5eac12534dd0a1fd5d2
Reviewed-on: https://go-review.googlesource.com/5653
Reviewed-by: Robert Griesemer <gri@golang.org>
The top-level moved package was skipped when doing import rewrites.
Don't skip that package.
Fixes#9811
Change-Id: I1c524ed44606586b5231e5adb6168079aa0e0228
Reviewed-on: https://go-review.googlesource.com/4470
Reviewed-by: Alan Donovan <adonovan@google.com>
Before this change, many kinds of error would cause the loader to stop.
making it brittle when analyzing large codebases, as in "godoc -analysis".
This change moves operations that used to occur during
configuration---(*build.Context).Import, loading, and parsing of
initial packages---into the Load call, and ensures that all failures
during Loading are reported at the end so that the maximum amount of
progress is made.
Also: redesign the tests and add many new cases.
Change-Id: Ia8cd99416af7c5d4a5fe133908adfa83676d401f
Reviewed-on: https://go-review.googlesource.com/3626
Reviewed-by: Robert Griesemer <gri@golang.org>
In the example, we use backslashes (not single quotes) to escape
double-quotes since it works on both Windows and POSIX.
Change-Id: Id883f5457bec4d8a36d5b12c759ad385125a98a6
Reviewed-on: https://go-review.googlesource.com/2862
Reviewed-by: Robert Griesemer <gri@golang.org>
- use import path not file path in go/buildutil.FakeContext OpenFile;
- use regexp to compare error messages in TestErrors, because
they contain windows file paths;
- use OS file path (not unix path), when checking move results
in TestMoves.
Change-Id: Ib62d344acb551fb612d8a0773ae1ab5f18341294
Reviewed-on: https://go-review.googlesource.com/3171
Reviewed-by: Alan Donovan <adonovan@google.com>
...to avoid namespace conflicts.
Also make its name "main", since it defines func main().
And fix 2 typos.
Change-Id: I7cf7894d6bed134907b3d2742255e5a82426071b
Reviewed-on: https://go-review.googlesource.com/3150
Reviewed-by: Robert Griesemer <gri@golang.org>
This refactoring of the tests of go/loader and refactor/rename made it
possible to write some loader tests I wanted, but the new tests reveal
bugs so they're commented out for now. I will fix them in a follow-up.
Change-Id: Iae3a20681a0a0791076debd4b82bb5ed74b0c577
Reviewed-on: https://go-review.googlesource.com/2825
Reviewed-by: Robert Griesemer <gri@golang.org>
This change adds a command mvpkg that will move a given package and
update all its imports. It uses similar logic to gorename to update
the imports.
Change-Id: Iebbd0b4c93c2302b0a71c3b99c68f6778106012a
Reviewed-on: https://go-review.googlesource.com/1973
Reviewed-by: Alan Donovan <adonovan@google.com>