// NarrowestMetadataForFile returns metadata for the narrowest package // (the one with the fewest files) that encloses the specified file. // The result may be a test variant, but never an intermediate test variant. func NarrowestMetadataForFile(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) (*metadata.Package, error) { … } // NarrowestPackageForFile is a convenience function that selects the narrowest // non-ITV package to which this file belongs, type-checks it in the requested // mode (full or workspace), and returns it, along with the parse tree of that // file. // // The "narrowest" package is the one with the fewest number of files that // includes the given file. This solves the problem of test variants, as the // test will have more files than the non-test package. // // An intermediate test variant (ITV) package has identical source to a regular // package but resolves imports differently. gopls should never need to // type-check them. // // Type-checking is expensive. Call snapshot.ParseGo if all you need is a parse // tree, or snapshot.MetadataForFile if you only need metadata. func NarrowestPackageForFile(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) (*cache.Package, *parsego.File, error) { … } // WidestPackageForFile is a convenience function that selects the widest // non-ITV package to which this file belongs, type-checks it in the requested // mode (full or workspace), and returns it, along with the parse tree of that // file. // // The "widest" package is the one with the most number of files that includes // the given file. Which is the test variant if one exists. // // An intermediate test variant (ITV) package has identical source to a regular // package but resolves imports differently. gopls should never need to // type-check them. // // Type-checking is expensive. Call snapshot.ParseGo if all you need is a parse // tree, or snapshot.MetadataForFile if you only need metadata. func WidestPackageForFile(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) (*cache.Package, *parsego.File, error) { … } func selectPackageForFile(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI, selector func([]*metadata.Package) *metadata.Package) (*cache.Package, *parsego.File, error) { … } type PackageID … type PackagePath … type PackageName … type ImportPath … type unit …