We really only use dependency ASTs for finding definitions and documentation, and we can avoid extra work and AST traversal by precomputing what we need. In most cases, dependencies are only type-checked once. I propose this alternative:
We type-check all packages in "full" mode (allowing us to use the type information for analyses).
Instead of having different parse modes for files, we have different modes for PackageHandles, one for workspace packages (PackageHandle) and one for dependencies (ExportedPackageHandle). PackageHandle remains the same as it is now, while ExportedPackageHandle does not contain references to the package's ParseGoHandles. Rather, it contains a pre-computed table of information that can be used for various features. My guess is that it will be a table of token.Pos -> documentation, but I'm sure I missed things.
A while back, @findleyr and I discussed a related topic which might allow us to get accurate analysis results for dependencies without the memory cost of keeping full ASTs in memory. Rob suggested that we could try pruning the ASTs after analysis runs, so the facts generated by analyses would be correct, but we would not pay the cost of keeping the full ASTs in memory.