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

7 Commits

Author SHA1 Message Date
Alan Donovan
c6ec5ea66d cmd/gorename: support renaming of methods with consequences for other types, iff initiated at an abstract method.
Previously, gorename rejected all method renamings if it would
change the assignability relation.

Now, so long as the renaming was initiated at an abstract
method, the renaming proceeds, changing concrete methods (and
possibly other abstract methods) as needed.  The user
intention is clear.

The intention of a renaming initiated at a concrete method is
less clear, so we still reject it if it would change the
assignability relation.  The diagnostic advises the user to
rename the abstract method if that was the intention.

Additional safety checks are required: for each
satisfy.Constraint that couples a concrete type C and an
interface type I, we must treat it just like a set of implicit
selections C.f, one per abstract method f of I, and ensure the
selections' meanings are unchanged.

The satisfy package no longer canonicalizes types, since this
substitutes one interface for another (equivalent) one, which
is sound, but makes the type names random and the error
messages confusing.

Also, fixed a bug in 'satisfy' relating to map keys.

+ Lots more tests.

LGTM=sameer
R=sameer
CC=golang-codereviews
https://golang.org/cl/173430043
2014-12-04 09:37:50 -05:00
Alan Donovan
fb44a24d4c refactor/rename: fix crash when renaming anonymous struct field that's a qualified reference
(or a pointer, or both).

+ test

Fixes bug 8924

LGTM=sameer
R=dominik.honnef, sameer
CC=<dominik.honnef, golang-codereviews
https://golang.org/cl/158920043
2014-11-10 16:03:40 -05:00
Alan Donovan
d73c11bfcb refactor/rename: make -from syntax support string literals for complex import paths.
(They may contain any character, after all.)

Also, allow but don't require parens and stars.
e.g. (*"encoding/json".Decoder).Decode or "encoding/json".Decoder.Decode
     but not encoding/json.Decoder.Decode.

Since -from queries are now Go expressions, we use the Go parser.
(Thanks to Rog Peppe for the suggestion.)

LGTM=sameer
R=sameer
CC=golang-codereviews, gri, rogpeppe
https://golang.org/cl/154610043
2014-10-31 15:39:22 -04:00
Alex Brainman
181e280a22 refactor/rename: use filepath.ToSlash everywhere to fix windows tests
Fixes golang/go#8823.

LGTM=adonovan
R=golang-codereviews, gobot, adonovan
CC=golang-codereviews
https://golang.org/cl/142660043
2014-10-23 09:45:47 +11:00
Alan Donovan
3fc6159fa3 refactor/rename: attempt to fix windows test, 2nd attempt.
Windows doesn't regard "/go/src" as an absolute path,
so we must explicitly define the virtual IsAbsPath method.

LGTM=gri
R=gri, sameer
CC=golang-codereviews
https://golang.org/cl/147100043
2014-09-24 16:38:46 -04:00
Alan Donovan
e94ae77171 refactor: minor no-op fixes
- fix typos and mistakes in docstrings, usage message and comments.
- remove 'backup' parameter to rewriteFile

LGTM=sameer
R=sameer
CC=golang-codereviews
https://golang.org/cl/147980043
2014-09-23 15:17:49 -04:00
Alan Donovan
74021b4175 cmd/gorename: a precise, type-aware renaming tool for Go identifiers.
See the usage message in main.go for orientation.

To the best of my knowledge, the tool implements all required
soundness checks, except:
- the dynamic behaviour of reflection is obviously undecidable.
- it rejects method renamings that change the "implements" relation.
  It should probably be more aggressive.
- actually it only checks the part of the "implements" relation
  needed for compilation.  Understanding the dynamic behaviour
  of interfaces is obviously undecidable.
- a couple of minor gaps are indicated by TODO comments.

Also:
- Emacs integration.
- tests of all safety checks and (some) successful rewrites.

LGTM=dominik.honnef, sameer
R=gri, sameer, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/139150044
2014-09-23 10:23:04 -04:00