goose: s/Use/Build/

Fixes google/go-cloud#6
This commit is contained in:
Ross Light
2018-05-24 14:29:05 -07:00
parent cc91a772b0
commit 962288c10a
32 changed files with 45 additions and 45 deletions

View File

@@ -92,8 +92,8 @@ func generateInjectors(g *gen, pkgInfo *loader.PackageInfo) (injectorFiles []*as
if !ok {
continue
}
useCall := isInjector(&pkgInfo.Info, fn)
if useCall == nil {
buildCall := isInjector(&pkgInfo.Info, fn)
if buildCall == nil {
continue
}
if len(injectorFiles) == 0 || injectorFiles[len(injectorFiles)-1] != f {
@@ -103,7 +103,7 @@ func generateInjectors(g *gen, pkgInfo *loader.PackageInfo) (injectorFiles []*as
g.p("// Injectors from %s:\n\n", name)
injectorFiles = append(injectorFiles, f)
}
set, err := oc.processNewSet(pkgInfo, useCall)
set, err := oc.processNewSet(pkgInfo, buildCall)
if err != nil {
return nil, fmt.Errorf("%v: %v", g.prog.Fset.Position(fn.Pos()), err)
}

View File

@@ -31,7 +31,7 @@ import (
// A ProviderSet describes a set of providers. The zero value is an empty
// ProviderSet.
type ProviderSet struct {
// Pos is the position of the call to goose.NewSet or goose.Use that
// Pos is the position of the call to goose.NewSet or goose.Build that
// created the set.
Pos token.Pos
// PkgPath is the import path of the package that declared this set.
@@ -316,7 +316,7 @@ type structProviderPair struct {
}
func (oc *objectCache) processNewSet(pkg *loader.PackageInfo, call *ast.CallExpr) (*ProviderSet, error) {
// Assumes that call.Fun is goose.NewSet or goose.Use.
// Assumes that call.Fun is goose.NewSet or goose.Build.
pset := &ProviderSet{
Pos: call.Pos(),
@@ -558,7 +558,7 @@ func processValue(fset *token.FileSet, info *types.Info, call *ast.CallExpr) (*V
}
// isInjector checks whether a given function declaration is an
// injector template, returning the goose.Use call. It returns nil if
// injector template, returning the goose.Build call. It returns nil if
// the function is not an injector template.
func isInjector(info *types.Info, fn *ast.FuncDecl) *ast.CallExpr {
if fn.Body == nil {
@@ -595,15 +595,15 @@ func isInjector(info *types.Info, fn *ast.FuncDecl) *ast.CallExpr {
if len(panicCall.Args) != 1 {
return nil
}
useCall, ok := panicCall.Args[0].(*ast.CallExpr)
buildCall, ok := panicCall.Args[0].(*ast.CallExpr)
if !ok {
return nil
}
useObj := qualifiedIdentObject(info, useCall.Fun)
if !isGooseImport(useObj.Pkg().Path()) || useObj.Name() != "Use" {
buildObj := qualifiedIdentObject(info, buildCall.Fun)
if !isGooseImport(buildObj.Pkg().Path()) || buildObj.Name() != "Build" {
return nil
}
return useCall
return buildCall
}
func isGooseImport(path string) bool {

View File

@@ -21,5 +21,5 @@ import (
)
func injectFooBar() FooBar {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectBar() (*Bar, func()) {
panic(goose.Use(provideFoo, provideBar))
panic(goose.Build(provideFoo, provideBar))
}

View File

@@ -35,5 +35,5 @@ func provideMessage() string {
}
func injectedMessage() string {
panic(goose.Use(provideMessage))
panic(goose.Build(provideMessage))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectedMessage() string {
panic(goose.Use(myFakeSet))
panic(goose.Build(myFakeSet))
}

View File

@@ -22,5 +22,5 @@ import (
)
func injectedMessage() string {
panic(goose.Use(bar.Value))
panic(goose.Build(bar.Value))
}

View File

@@ -24,5 +24,5 @@ import (
)
func injectedFile() *os.File {
panic(goose.Use(bar.Value))
panic(goose.Build(bar.Value))
}

View File

@@ -22,5 +22,5 @@ import (
)
func injectFooer() foo.Fooer {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectFooBar(foo Foo) FooBar {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectBar(foo Foo) Bar {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectFooer() Fooer {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,7 +21,7 @@ import (
)
func injectFooBar() FooBar {
panic(goose.Use(
panic(goose.Build(
provideBar,
provideFooBar,
goose.Bind(Fooer(nil), (*Bar)(nil))))

View File

@@ -23,5 +23,5 @@ import (
)
func inject(context stdcontext.Context, err struct{}) (context, error) {
panic(goose.Use(provide))
panic(goose.Build(provide))
}

View File

@@ -51,7 +51,7 @@ func Provide(context2 stdcontext.Context) (context, error) {
}
func inject(context stdcontext.Context, err struct{}) (context, error) {
panic(goose.Use(Provide))
panic(goose.Build(Provide))
}
func (context) Provide() {

View File

@@ -21,5 +21,5 @@ import (
)
func injectedMessage() string {
panic(goose.Use(provideMessage))
panic(goose.Build(provideMessage))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectedMessage() string {
panic(goose.Use(goose.Value("Hello, World!")))
panic(goose.Build(goose.Value("Hello, World!")))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectFooer() Fooer {
panic(goose.Use(provideBar))
panic(goose.Build(provideBar))
}

View File

@@ -26,5 +26,5 @@ import (
// parameter names on the inject stub.
func inject(stdcontext.Context, struct{}) (context, error) {
panic(goose.Use(provide))
panic(goose.Build(provide))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectBaz() (Baz, func(), error) {
panic(goose.Use(provideFoo, provideBar, provideBaz))
panic(goose.Build(provideFoo, provideBar, provideBaz))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectFooBar() FooBar {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectFoo() (Foo, error) {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectFooBar() FooBar {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectFooBar() *FooBar {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectFooBar() FooBar {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -22,5 +22,5 @@ import (
)
func injectedMessage() string {
panic(goose.Use(bar.Value))
panic(goose.Build(bar.Value))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectFooBar() FooBar {
panic(goose.Use(Set))
panic(goose.Build(Set))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectedMessage() Foo {
panic(goose.Use(goose.Value(Foo("Hello, World!"))))
panic(goose.Build(goose.Value(Foo("Hello, World!"))))
}

View File

@@ -21,5 +21,5 @@ import (
)
func injectedMessage() string {
panic(goose.Use(goose.Value(msg)))
panic(goose.Build(goose.Value(msg)))
}

View File

@@ -22,5 +22,5 @@ import (
)
func injectedMessage() string {
panic(goose.Use(bar.ProvideMessage))
panic(goose.Build(bar.ProvideMessage))
}