names

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	PathToName map[string]string    // path -> local name
	NameToPath map[string]string    // local name -> path
	Idents     map[*ast.Ident]*Name // ident -> resolved
	Calls      []*ast.CallExpr
}

File provides file-level name resolution results.

type Name

type Name struct {
	Package    bool   // package symbol
	Local      bool   // locally defined symbol
	ImportPath string // non-zero indicates it resolves to the package with the given import path
}

Name provides metadata for a single identifier.

type PkgDecl

type PkgDecl struct {
	Name string
	File *est.File
	Pos  token.Pos
	Type token.Token   // CONST, TYPE, VAR, FUNC
	Func *ast.FuncDecl // for Type == FUNC
	Spec ast.Spec      // for other types
	Doc  string
}

PkgDecl provides metadata for a package-level declaration.

type Resolution

type Resolution struct {
	Decls map[string]*PkgDecl // package-level declarations, keyed by name
	Files map[*est.File]*File
}

Resolution represents the name resolution results.

func Resolve

func Resolve(fset *token.FileSet, track TrackedPackages, pkg *est.Package) (*Resolution, error)

Resolve resolves information about the names (idents) in the given package. The reported error is of type scanner.ErrorList if non-nil.

type TrackedPackages

type TrackedPackages map[string]string

TrackedPackages defines the set of packages to track, defined as a map from import path to package name.

It is used to allow Resolve to efficiently determine the name of a package given its import path, as one otherwise needs to parse the package source to find it.

Jump to

Keyboard shortcuts

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