Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 66330d8

Browse files
bradfitzbroady
authored andcommittedJan 13, 2016
go/types: rename Importer2 to ImporterFrom
Per https://groups.google.com/forum/#!topic/golang-dev/javNmryAh0I Change-Id: I08d7cbc94da4fc61c848f3dbee4637bf8fcfeb01 Reviewed-on: https://go-review.googlesource.com/18630 Reviewed-by: Alan Donovan <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Chris Broadfoot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 8c9ef9d commit 66330d8

File tree

5 files changed

+30
-26
lines changed

5 files changed

+30
-26
lines changed
 

‎api/go1.6.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ pkg go/constant, func ToFloat(Value) Value
186186
pkg go/constant, func ToInt(Value) Value
187187
pkg go/constant, type Value interface, ExactString() string
188188
pkg go/types, method (*Package) SetName(string)
189+
pkg go/types, type ImportMode int
190+
pkg go/types, type ImporterFrom interface { Import, ImportFrom }
191+
pkg go/types, type ImporterFrom interface, Import(string) (*Package, error)
192+
pkg go/types, type ImporterFrom interface, ImportFrom(string, string, ImportMode) (*Package, error)
189193
pkg html/template, func IsTrue(interface{}) (bool, bool)
190194
pkg html/template, method (*Template) DefinedTemplates() string
191195
pkg image, func NewNYCbCrA(Rectangle, YCbCrSubsampleRatio) *NYCbCrA

‎src/go/importer/importer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func For(compiler string, lookup Lookup) types.Importer {
5050
}
5151

5252
// Default returns an Importer for the compiler that built the running binary.
53-
// If available, the result implements types.Importer2.
53+
// If available, the result implements types.ImporterFrom.
5454
func Default() types.Importer {
5555
return For(runtime.Compiler, nil)
5656
}
@@ -60,10 +60,10 @@ func Default() types.Importer {
6060
type gcimports map[string]*types.Package
6161

6262
func (m gcimports) Import(path string) (*types.Package, error) {
63-
return m.Import2(path, "" /* no vendoring */, 0)
63+
return m.ImportFrom(path, "" /* no vendoring */, 0)
6464
}
6565

66-
func (m gcimports) Import2(path, srcDir string, mode types.ImportMode) (*types.Package, error) {
66+
func (m gcimports) ImportFrom(path, srcDir string, mode types.ImportMode) (*types.Package, error) {
6767
if mode != 0 {
6868
panic("mode must be 0")
6969
}
@@ -78,10 +78,10 @@ type gccgoimports struct {
7878
}
7979

8080
func (m *gccgoimports) Import(path string) (*types.Package, error) {
81-
return m.Import2(path, "" /* no vendoring */, 0)
81+
return m.ImportFrom(path, "" /* no vendoring */, 0)
8282
}
8383

84-
func (m *gccgoimports) Import2(path, srcDir string, mode types.ImportMode) (*types.Package, error) {
84+
func (m *gccgoimports) ImportFrom(path, srcDir string, mode types.ImportMode) (*types.Package, error) {
8585
if mode != 0 {
8686
panic("mode must be 0")
8787
}

‎src/go/types/api.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,37 @@ func (err Error) Error() string {
5454
// An Importer resolves import paths to Packages.
5555
//
5656
// CAUTION: This interface does not support the import of locally
57-
// vendored packages. See also https://golang.org/s/go15vendor.
58-
// If possible, external implementations should implement Importer2.
57+
// vendored packages. See https://golang.org/s/go15vendor.
58+
// If possible, external implementations should implement ImporterFrom.
5959
type Importer interface {
6060
// Import returns the imported package for the given import
6161
// path, or an error if the package couldn't be imported.
62-
// Two calls to Import with the same path and srcDir return
63-
// the same package.
62+
// Two calls to Import with the same path return the same
63+
// package.
6464
Import(path string) (*Package, error)
6565
}
6666

6767
// ImportMode is reserved for future use.
6868
type ImportMode int
6969

70-
// An Importer2 resolves import paths to packages; it
70+
// An ImporterFrom resolves import paths to packages; it
7171
// supports vendoring per https://golang.org/s/go15vendor.
72-
// Use go/importer to obtain an Importer2 implementation.
73-
type Importer2 interface {
72+
// Use go/importer to obtain an ImporterFrom implementation.
73+
type ImporterFrom interface {
7474
// Importer is present for backward-compatibility. Calling
75-
// Import(path) is the same as calling Import(path, "", 0);
75+
// Import(path) is the same as calling ImportFrom(path, "", 0);
7676
// i.e., locally vendored packages may not be found.
77-
// The types package does not call Import if an Importer2
77+
// The types package does not call Import if an ImporterFrom
7878
// is present.
7979
Importer
8080

81-
// Import2 returns the imported package for the given import
81+
// ImportFrom returns the imported package for the given import
8282
// path when imported by the package in srcDir, or an error
8383
// if the package couldn't be imported. The mode value must
8484
// be 0; it is reserved for future use.
85-
// Two calls to Import2 with the same path and srcDir return
85+
// Two calls to ImportFrom with the same path and srcDir return
8686
// the same package.
87-
Import2(path, srcDir string, mode ImportMode) (*Package, error)
87+
ImportFrom(path, srcDir string, mode ImportMode) (*Package, error)
8888
}
8989

9090
// A Config specifies the configuration for type checking.
@@ -114,8 +114,8 @@ type Config struct {
114114

115115
// An importer is used to import packages referred to from
116116
// import declarations.
117-
// If the installed importer implements Importer2, the type
118-
// checker calls Import2 instead of Import.
117+
// If the installed importer implements ImporterFrom, the type
118+
// checker calls ImportFrom instead of Import.
119119
// The type checker reports an error if an importer is needed
120120
// but none was installed.
121121
Importer Importer

‎src/go/types/resolver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ func (check *Checker) collectObjects() {
187187
// ordinary import
188188
if importer := check.conf.Importer; importer == nil {
189189
err = fmt.Errorf("Config.Importer not installed")
190-
} else if importer2, ok := importer.(Importer2); ok {
191-
imp, err = importer2.Import2(path, srcDir, 0)
190+
} else if importerFrom, ok := importer.(ImporterFrom); ok {
191+
imp, err = importerFrom.ImportFrom(path, srcDir, 0)
192192
if imp == nil && err == nil {
193-
err = fmt.Errorf("Config.Importer.Import2(%s, %s, 0) returned nil but no error", path, pkg.path)
193+
err = fmt.Errorf("Config.Importer.ImportFrom(%s, %s, 0) returned nil but no error", path, pkg.path)
194194
}
195195
} else {
196196
imp, err = importer.Import(path)

‎src/go/types/resolver_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ import (
1818
)
1919

2020
type resolveTestImporter struct {
21-
importer Importer2
21+
importer ImporterFrom
2222
imported map[string]bool
2323
}
2424

2525
func (imp *resolveTestImporter) Import(string) (*Package, error) {
2626
panic("should not be called")
2727
}
2828

29-
func (imp *resolveTestImporter) Import2(path, srcDir string, mode ImportMode) (*Package, error) {
29+
func (imp *resolveTestImporter) ImportFrom(path, srcDir string, mode ImportMode) (*Package, error) {
3030
if mode != 0 {
3131
panic("mode must be 0")
3232
}
3333
if imp.importer == nil {
34-
imp.importer = importer.Default().(Importer2)
34+
imp.importer = importer.Default().(ImporterFrom)
3535
imp.imported = make(map[string]bool)
3636
}
37-
pkg, err := imp.importer.Import2(path, srcDir, mode)
37+
pkg, err := imp.importer.ImportFrom(path, srcDir, mode)
3838
if err != nil {
3939
return nil, err
4040
}

0 commit comments

Comments
 (0)
Please sign in to comment.