internal/lsp: add back check that a package was found for a given file
Added this check in golang.org/cl/161077 and unintentionally removed it in
golang.org/cl/161497.
Change-Id: I66bd2b616f4b41c25f134f6e9457c97bbcd3f72b
Reviewed-on: https://go-review.googlesource.com/c/162398
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go
index f0ab523..e4458e9 100644
--- a/internal/lsp/cache/view.go
+++ b/internal/lsp/cache/view.go
@@ -121,6 +121,7 @@
}
return err
}
+ var foundPkg bool // true if we found the package for uri
for _, pkg := range pkgs {
imp := &importer{
entries: make(map[string]*entry),
@@ -150,12 +151,18 @@
continue
}
fURI := source.ToURI(tok.Name())
+ if fURI == uri {
+ foundPkg = true
+ }
f := imp.v.getFile(fURI)
f.token = tok
f.ast = file
f.pkg = pkg
}
}
+ if !foundPkg {
+ return fmt.Errorf("no package found for %v", uri)
+ }
return nil
}