gotools/gopls/internal/cache/typerefs/pkgrefs_test.go

var dir

var query

var verify

type packageName

type PackageID

type ImportPath

type PackagePath

type Metadata

type MetadataSource

// TestBuildPackageGraph tests the BuildPackageGraph constructor, which uses
// the reference analysis of the Refs function to build a graph of
// relationships between packages.
//
// It simulates the operation of gopls at startup: packages are loaded via
// go/packages, and their syntax+metadata analyzed to determine which packages
// are reachable from others.
//
// The test then verifies that the 'load' graph (the graph of relationships in
// export data) is a subgraph of the 'reach' graph constructed by
// BuildPackageGraph. While doing so, it constructs some statistics about the
// relative sizes of these graphs, along with the 'transitive imports' graph,
// to report the effectiveness of the reachability analysis.
//
// The following flags affect this test:
//   - dir sets the dir from which to run go/packages
//   - query sets the go/packages query to load
//   - verify toggles the verification w.r.t. the load graph (which may be
//     prohibitively expensive with large queries).
func TestBuildPackageGraph(t *testing.T) {}

func importMap(id PackageID, meta MetadataSource) map[PackagePath]PackageID {}

func importFromExportData(pkgPath, exportFile string) (*types.Package, error) {}

func BenchmarkBuildPackageGraph(b *testing.B) {}

type memoizedParser

type futureParse

func newParser() *memoizedParser {}

func (p *memoizedParser) parse(ctx context.Context, uri protocol.DocumentURI) (*parsego.File, error) {}

type mapMetadataSource

func (s mapMetadataSource) Metadata(id PackageID) *Metadata {}

// This function is a compressed version of snapshot.load from the
// internal/cache package, for use in testing.
//
// TODO(rfindley): it may be valuable to extract this logic from the snapshot,
// since it is otherwise standalone.
func loadPackages(query string, needExport bool) (map[PackageID]string, MetadataSource, error) {}