loader

package
v0.0.0-...-a2136ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package loader wraps golang.org/x/tools/go/packages with utility types and methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Program

type Program struct {
	// Fset contains the entire program Fset
	Fset *token.FileSet

	// AllPackages is the list of all loaded packages for a program.
	// It is this exposed this way to match the old loader API.
	AllPackages map[*types.Package]*packages.Package
}

Program provides access to various elements of a type checked set of packages. Fset and AllPackages are not so easily combined, we often need to query the entire program ast which contains all packages, often needing additional information within any given package after that.

func Load

func Load(conf *packages.Config, errorH func(error), args ...string) (*Program, error)

Load loads a package, calling packages.Load

func (*Program) PathEnclosingInterval

func (prog *Program) PathEnclosingInterval(start, end token.Pos) (pkg *packages.Package, path []ast.Node, exact bool)

PathEnclosingInterval returns the PackageInfo and ast.Node that contain source interval [start, end), and all the node's ancestors up to the AST root. It searches all ast.Files of all packages in prog. exact is defined as for astutil.PathEnclosingInterval.

The zero value is returned if not found.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL