1
0
mirror of https://github.com/golang/go synced 2024-09-30 14:18:32 -06:00
go/refactor
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
..
eg go.tools/go/types: LookupFieldOrMethod checks method set 2014-08-28 13:03:13 -07:00
importgraph refactor/importgraph: add test of cycles 2014-09-18 10:05:26 -04:00
lexical refactor/lexical: understand the structure of the lexical environment. 2014-09-19 13:11:01 -04:00
README go.tools/refactor/eg: an example-based refactoring tool. 2014-04-02 12:24:55 -04:00

code.google.com/p/go.tools/refactor: libraries for refactoring tools.