oracle: ignore errors during import graph construction
Such errors include files without package decl, or conflicting package decls. We ignore type errors, so we should ignore import errors too. Fixes #10347 Change-Id: I9011a9099a2804281ea2d989d7263a9ce691be16 Reviewed-on: https://go-review.googlesource.com/8498 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
5cf8a6b1aa
commit
ab1b92fc43
|
@ -10,7 +10,6 @@ import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"golang.org/x/tools/go/loader"
|
"golang.org/x/tools/go/loader"
|
||||||
|
@ -64,6 +63,9 @@ func referrers(q *Query) error {
|
||||||
// If the identifier is exported, we must load all packages that
|
// If the identifier is exported, we must load all packages that
|
||||||
// depend transitively upon the package that defines it.
|
// depend transitively upon the package that defines it.
|
||||||
//
|
//
|
||||||
|
// TODO(adonovan): we should do this for PkgName objects
|
||||||
|
// too, even though they're lowercase.
|
||||||
|
//
|
||||||
// TODO(adonovan): opt: skip this step if obj.Pkg() is a test or
|
// TODO(adonovan): opt: skip this step if obj.Pkg() is a test or
|
||||||
// main package.
|
// main package.
|
||||||
if pass2 || !obj.Exported() {
|
if pass2 || !obj.Exported() {
|
||||||
|
@ -71,13 +73,8 @@ func referrers(q *Query) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan the workspace and build the import graph.
|
// Scan the workspace and build the import graph.
|
||||||
_, rev, errors := importgraph.Build(q.Build)
|
// Ignore broken packages.
|
||||||
if len(errors) > 0 {
|
_, rev, _ := importgraph.Build(q.Build)
|
||||||
for path, err := range errors {
|
|
||||||
fmt.Fprintf(os.Stderr, "Package %q: %s.\n", path, err)
|
|
||||||
}
|
|
||||||
return fmt.Errorf("failed to scan import graph for workspace")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Re-load the larger program.
|
// Re-load the larger program.
|
||||||
// Create a new file set so that ...
|
// Create a new file set so that ...
|
||||||
|
|
Loading…
Reference in New Issue