]> Cypherpunks.ru repositories - gostls13.git/commit
go/types: change {Type,Object,Selection}String to accept a Qualifier function
authorAlan Donovan <adonovan@google.com>
Tue, 30 Jun 2015 19:07:20 +0000 (15:07 -0400)
committerAlan Donovan <adonovan@google.com>
Tue, 30 Jun 2015 21:44:42 +0000 (21:44 +0000)
commitf11109fbc93bf2f31b5a948cc29c920b31184011
tree9607ee758f25e50c4bf76e4b79639f0b1f3ebb64
parent6f80e5edf464fe5321acb2b4994951fe7edfff7e
go/types: change {Type,Object,Selection}String to accept a Qualifier function

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.

Fixes golang/go#11133

This CL is a copy of https://go-review.googlesource.com/#/c/11692/
to the golang.org/x/tools repository.

Change-Id: I26d0f3644d077a26bfe350989f9c545f018eefbf
Reviewed-on: https://go-review.googlesource.com/11790
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
src/go/internal/gccgoimporter/importer_test.go
src/go/internal/gcimporter/gcimporter_test.go
src/go/types/errors.go
src/go/types/example_test.go
src/go/types/object.go
src/go/types/operand.go
src/go/types/selection.go
src/go/types/type.go
src/go/types/typestring.go
src/go/types/typestring_test.go