Documentation
¶
Overview ¶
Package extractor is a package, that extracts type specs and methods from given ast tree.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractMethodsFromPackage ¶
ExtractMethodsFromPackage is a function to extract methods from package.
func ExtractRecvTypeName ¶
ExtractRecvTypeName is a helper function to extract receiver type name (string) from method.
func ExtractTypeSpecsFromPackage ¶
ExtractTypeSpecsFromPackage extracts type specs from a ast tree.
Types ¶
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer is an analyzer, that extracts type specs and methods from package and groups them for quick access.
func NewAnalyzerFromPackage ¶
NewAnalyzerFromPackage parses ast tree for TypeSpecs and associated methods.
func (Analyzer) PackageName ¶
PackageName returns package name of analyzed package.
func (Analyzer) PackagePath ¶
PackagePath returns package path of analyzed package.
func (Analyzer) TypeSpecEntryByName ¶
func (a Analyzer) TypeSpecEntryByName(name string) (*TypeSpecEntry, bool)
TypeSpecEntryByName returns TypeSpecEntry entry by name.
type Package ¶
Package is an interface that provides access to package data. It's used to abstract away the `packages.Package` type.
func NewPackage ¶
NewPackage creates a new Package from a packages.Package.
type TypeSpecEntry ¶
type TypeSpecEntry struct { Name string Methods []string // contains filtered or unexported fields }
TypeSpecEntry is an entry, that defines ast's TypeSpec and contains type name and methods.
func (TypeSpecEntry) HasMethod ¶
func (e TypeSpecEntry) HasMethod(name string) bool
HasMethod returns true if type spec has method with given name.