go.mobile/cmd/gobind: use go/loader to load packages

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/127050043
This commit is contained in:
David Crawshaw 2014-08-12 14:09:08 -04:00
parent e8dea067be
commit d58b149990
1 changed files with 12 additions and 8 deletions

View File

@ -15,8 +15,7 @@ import (
"go/token"
"code.google.com/p/go.mobile/bind"
_ "code.google.com/p/go.tools/go/gcimporter"
"code.google.com/p/go.tools/go/types"
"code.google.com/p/go.tools/go/loader"
)
func genPkg(pkg *build.Package) {
@ -30,15 +29,20 @@ func genPkg(pkg *build.Package) {
return // some error has been reported
}
conf := types.Config{
Error: func(err error) {
errorf("%v", err)
},
conf := loader.Config{
SourceImports: true,
Fset: fset,
}
p, err := conf.Check(pkg.ImportPath, fset, files, nil)
conf.TypeChecker.Error = func(err error) {
errorf("%v", err)
}
conf.CreateFromFiles(pkg.ImportPath, files...)
program, err := conf.Load()
if err != nil {
return // printed above
errorf("%v", err)
return
}
p := program.Created[0].Pkg
switch *lang {
case "java":