From ab1b92fc435bcbd8ff53c3c72388b1afdc870689 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Mon, 6 Apr 2015 15:11:42 -0400 Subject: [PATCH] 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 --- oracle/referrers.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/oracle/referrers.go b/oracle/referrers.go index 04859508..893668b3 100644 --- a/oracle/referrers.go +++ b/oracle/referrers.go @@ -10,7 +10,6 @@ import ( "go/ast" "go/token" "io/ioutil" - "os" "sort" "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 // 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 // main package. if pass2 || !obj.Exported() { @@ -71,13 +73,8 @@ func referrers(q *Query) error { } // Scan the workspace and build the import graph. - _, rev, errors := importgraph.Build(q.Build) - if len(errors) > 0 { - 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") - } + // Ignore broken packages. + _, rev, _ := importgraph.Build(q.Build) // Re-load the larger program. // Create a new file set so that ...