Documentation ¶
Index ¶
- func EachType(pkg *Package, cb TypeCallback)
- func ErrFromNode(err error, node Node) error
- func MaybeErrList(errs []error) error
- func NonVendorPath(rawPath string) string
- func ParseAstTag(tag *ast.BasicLit) reflect.StructTag
- type ErrList
- type Loader
- type Node
- type NodeFilter
- type Package
- type PositionedError
- type TypeCallback
- type TypeChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EachType ¶
func EachType(pkg *Package, cb TypeCallback)
EachType calls the given callback for each (gendecl, typespec) combo in the given package. Generally, using markers.EachType is better when working with marker data, and has a more convinient representation.
func ErrFromNode ¶
ErrFromNode returns the given error, with additional information attaching it to the given AST node. It will automatically map over error lists.
func MaybeErrList ¶
MaybeErrList constructs an ErrList if the given list of errors has any errors, otherwise returning nil.
func NonVendorPath ¶
NonVendorPath returns a package path that does not include anything before the last vendor directory. This is useful for when using vendor directories, and using go/types.Package.Path(), which returns the full path including vendor.
If you're using this, make sure you really need it -- it's better to index by the actual Package object when you can.
Types ¶
type ErrList ¶
type ErrList []error
ErrList is a list of errors aggregated together into a single error.
type Loader ¶
func NewWithConfig ¶
loader loads packages and their imports. Loaded packages will have type size, imports, and exports file information populated.
type NodeFilter ¶
NodeFilter filters nodes, accepting them for reference collection when true is returned and rejecting them when false is returned.
type Package ¶
Package is a single, unique Go package that can be lazily parsed and type-checked. Packages should not be constructed directly -- instead, use LoadRoots.
func (*Package) EachType ¶
func (p *Package) EachType(cb TypeCallback)
EachType calls the given callback for each (gendecl, typespec) combo in the given package. Generally, using markers.EachType is better when working with marker data, and has a more convinient representation.
func (*Package) Imports ¶
Imports returns the imports for the given package, indexed by package path (*not* name in any particular file).
func (*Package) NeedSyntax ¶
func (p *Package) NeedSyntax()
NeedSyntax indicates that a parsed AST is needed for this package. Actual ASTs can be accessed via the Syntax field.
func (*Package) NeedTypesInfo ¶
func (p *Package) NeedTypesInfo()
NeedTypesInfo indicates that type-checking information is needed for this package. Actual type-checking information can be accessed via the Types and TypesInfo fields.
type PositionedError ¶
PositionedError represents some error with an associated position. The position is tied to some external token.FileSet.
type TypeCallback ¶
TypeCallback is a callback called for each raw AST (gendecl, typespec) combo.
type TypeChecker ¶
type TypeChecker interface {
Check(rootPkg *Package)
}
func NewTypeChecker ¶
func NewTypeChecker() TypeChecker