internal/lsp/cache: return error when no packages found

Change-Id: Ia11f0c428cffdd42eab5c4322e9ff6f0a38870fc
Reviewed-on: https://go-review.googlesource.com/c/156777
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go
index 812fa1d..aff5988 100644
--- a/internal/lsp/cache/view.go
+++ b/internal/lsp/cache/view.go
@@ -104,7 +104,11 @@
 		}
 		return err
 	}
+
 	for _, pkg := range pkgs {
+		if len(pkg.Syntax) == 0 {
+			return fmt.Errorf("no syntax trees for %s", pkg.PkgPath)
+		}
 		// Add every file in this package to our cache.
 		for _, fAST := range pkg.Syntax {
 			// TODO: If a file is in multiple packages, which package do we store?