Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { Name string // file name ("foo.go") Pkg *Package // package it belongs to FSPath paths.FS // where the file lives on disk Imports map[paths.Pkg]ast.Node // imports in the file, keyed by import path pointed at the import spec TestFile bool // whether the file is a test file // contains filtered or unexported fields }
func (*File) ASTInspector ¶
ASTInspector returns an AST inspector that's optimized for finding nodes of particular types. See inspector.Inspector for more information.
type FileNames ¶
type FileNames struct {
// contains filtered or unexported fields
}
FileNames contains name resolution results for a single file.
func (*FileNames) ResolvePkgLevelRef ¶
func (f *FileNames) ResolvePkgLevelRef(expr ast.Expr) (name QualifiedName, ok bool)
ResolvePkgLevelRef resolves the node to the package-level reference it refers to. Expr must be either *ast.Ident or *ast.SelectorExpr. If it doesn't refer to a package-level reference it returns ok == false.
type IdentInfo ¶
type IdentInfo struct { Package bool // package symbol Local bool // locally defined symbol ImportPath paths.Pkg // non-zero indicates it resolves to the package with the given import path }
IdentInfo provides metadata for a single identifier.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
A Loader provides lazy loading of package information.
func (*Loader) LoadPkg ¶
LoadPkg loads a package. If the package contains no Go files to build, it returns (nil, false).
func (*Loader) MainModule ¶
MainModule returns the parsed main module.
type Module ¶
type Module struct { RootDir paths.FS // the dir containing go.mod Path paths.Mod // module path Version string // module version // contains filtered or unexported fields }
Module describes a Go module.
type Package ¶
type PkgDeclInfo ¶
type PkgDeclInfo struct { Name string File *File Pos token.Pos Doc string // Type describes what type of declaration this is. // It's one of CONST, TYPE, VAR, or FUNC. Type token.Token // Spec is the spec for this declaration and GenDecl the declaration block // it belongs to. They are set only when Type != FUNC. Spec ast.Spec GenDecl *ast.GenDecl // Func is the function declaration, if Type == FUNC. Func *ast.FuncDecl // for Type == FUNC // Recv is the receiver type, if Type == FUNC and the function is a method. Recv *PkgDeclInfo }
PkgDeclInfo provides metadata for a package-level declaration.
type PkgNames ¶
type PkgNames struct { // PkgDecls contains package-level declarations, keyed by name. PkgDecls map[string]*PkgDeclInfo // Funcs are all the func declarations. Funcs []*PkgDeclInfo // contains filtered or unexported fields }
PkgNames contains name information that's package-global.
type QualifiedName ¶
A QualifiedName is the combination of a package path and a package-level name. It can be used to uniquely reference a package-level declaration.
func Q ¶
func Q(pkgPath paths.Pkg, name string) QualifiedName
Q is a helper function to construct a QualifiedName.
func (QualifiedName) NaiveDisplayName ¶
func (q QualifiedName) NaiveDisplayName() string
NaiveDisplayName returns the name as "pkgname.Name" by assuming the package name is equal to the last path component.