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

118 Commits

Author SHA1 Message Date
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
Alan Donovan
c90cb9e042 refactor/satisfy: enumerate interface satisfaction constraints induced by Go syntax.
The type checker does not currently report the set of pairs of
types that are tested for assignability (though gri and I
agree that it should).  This information is useful for many
applications.  For example, refactoring tool needs to know the
minimal set of interface satisfaction constraints that must be
preserved during a refactoring.

This package is a stopgap measure to deduce the same
information using another pass.  Unlike go/types, it is not
robust against inputs containing type errors.

LGTM=sameer
R=gri, sameer
CC=golang-codereviews
https://golang.org/cl/136470043
2014-09-22 16:19:29 -04:00
Alan Donovan
897f6677ae refactor/lexical: understand the structure of the lexical environment.
The Uses, Defs and Scope information provided by go/types is
inadequate for answering "what if?" queries about the
structure of the lexical environment.

In this code, for example,

        var x int

        func f() {
                print(x)
                x := ""
                print(x)
        }

the two referring Idents x appear at the same lexical depth,
inside the function f's Scope object, yet they resolve to
different objects.

This package associates a lexical.Environment instance with
every reference to capture these differences.  Each
environment is a linked list of enclosing Blocks, and for each
block, a number indicating what prefix of its bindings are
visible.  (Zero for the first 'x' reference above, 1 for the
second.)

+ Smoke test over stdlib.

This functionality could be integrated with the type checker
in lieu of the not-so-useful types.Info.Scopes data, at little
extra cost in code or in running time/space.  We should talk
about that.

LGTM=sameer
R=gri, sameer
CC=golang-codereviews
https://golang.org/cl/143790043
2014-09-19 13:11:01 -04:00
Alan Donovan
fec4d1f60d refactor/importgraph: add test of cycles
Nodes in a strongly connected component (which includes most
stdlib packages) appear in results of both "forward" and
"reverse" searches from any other node in the same SCC.

LGTM=sameer
R=sameer
CC=golang-codereviews, gri
https://golang.org/cl/136470044
2014-09-18 10:05:26 -04:00
Alan Donovan
66176e290c go/buildutil: rename AllPackages{,List} -> {ForEachPackage,AllPackages}.
This CL is the first refactoring automated by "gorename". :)
Though I had to update the comments and run 'hg gofmt'.   :(

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/142930043
2014-09-11 14:33:37 -04:00
Alan Donovan
3cded4a933 refactor/importgraph: a utility for computing the import graph.
Refactoring tools can use this to determine an upper bound on
the set of packages potentially affected by a refactoring.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/141310043
2014-09-09 18:39:26 -04:00
Robert Griesemer
5dca7d8bd1 go.tools/go/types: LookupFieldOrMethod checks method set
LookupFieldOrMethod now also decides whether a found
method is actually in the method set. Simplifies call
sites. Added corresponding API tests.

TODO (separate CL): Decide what the correct value for
the indirect result should be (as required for code
generation). For now, the result value for indirect
is unchanged from before if a field/method is found.

Fixes golang/go#8584.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/132260043
2014-08-28 13:03:13 -07:00
Alan Donovan
4abc8436bc cmd/eg: add -beforeedit flag, which specifies a command to run before editing a file.
e.g. chmod +w, checkout.

Also: add a TIPS section to the documentation.

LGTM=crawshaw
R=crawshaw, gri
CC=golang-codereviews
https://golang.org/cl/136780044
2014-08-26 15:52:40 -04:00
Paul Nasrat
89156360f9 go.tools/refactor/eg: Support promoted fields and methods.
As per http://golang.org/ref/spec#Struct_types enable eg tool
to wildcard match against promoted fields and methods.

LGTM=adonovan
R=adonovan, gordon.klaus
CC=golang-codereviews
https://golang.org/cl/129260043
2014-08-25 16:26:54 -04:00
Alan Donovan
f2db24a319 go.tools/go/loader: use new types.TypeAndValue mode predicates.
PackageInfo:
- deleted IsType
- inlined + deleted: ValueOf, TypeCaseVar, ImportSpecPkg
- on failure, TypeOf accessor now returns nil (was: panic)

go/ssa: avoid extra map lookups by using Uses or Defs directly when safe to do so,
and keeping the TypeAndValue around in expr0().

LGTM=gri
R=gri, pcc
CC=golang-codereviews
https://golang.org/cl/107650043
2014-07-11 10:50:09 +01:00
Alan Donovan
d014be43ae go.tools/go/types: remove PackageObj Selection - not needed
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/105920043
2014-06-12 18:05:33 -04:00
Rob Pike
a8c8f48be3 go.tools/all: the the thes are too frequent, it's clear that that's not what we want
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/98380043
2014-05-19 09:48:30 -07:00
Robert Griesemer
30b1abe2f7 go.tools: fix various typos
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/97920045
2014-05-02 14:38:08 -07:00
Alan Donovan
8eccac8f9a go.tools/refactor/eg: avoid nonstandard 'diff -N' option.
(To fix broken Solaris test)

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/90080044
2014-04-21 18:35:16 -04:00
Alan Donovan
066bab1496 go.tools/refactor/eg: move misplaced comment
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/88100046
2014-04-16 16:50:19 -04:00
Alan Donovan
ccb0e9ab88 go.tools/.hgignore: don't ignore test-generated files, clean them up.
(Includes rollback of CL 83680043.)

LGTM=gri
R=gri
CC=golang-codereviews, rsc
https://golang.org/cl/86430045
2014-04-10 13:17:20 -04:00
Alan Donovan
14aef25050 go.tools/refactor/eg: remove debugging code accidentally committed.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/83650043
2014-04-02 12:39:10 -04:00
Alan Donovan
bfcffc697d go.tools/refactor/eg: an example-based refactoring tool.
See refactor/eg/eg.go for details.

LGTM=crawshaw
R=crawshaw, gri, kamil.kisiel, josharian
CC=golang-codereviews
https://golang.org/cl/81010043
2014-04-02 12:24:55 -04:00