Documentation
¶
Overview ¶
Package meta provides functionalities for parsing Go files ASTs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMethodNotFound = errors.New("method not found in ASTs")
var PackagesASTsMap map[string]PackageASTs = map[string]PackageASTs{}
Packages ASTs map built on embedded Go source files. It's built on init.
Functions ¶
func MethodBodySource ¶
func MethodBodySource( astMap map[string]PackageASTs, typeName, methodName string, ) (*ast.BlockStmt, string, error)
MethodBodySource finds given method for given type in the AST and return it's body AST and source code as string. If given type or method does not exist in given ASTs map, then non nil error would be returned.
func ParseASTs ¶
ParseASTs parses ASTs for packages and its Go files based on given FS. Parsed object is assigned to PackagesASTsMap. It's enough to call this function just once at the program start.
func ParsePackagesASTs ¶
func ParsePackagesASTs(fs embed.FS) (map[string]PackageASTs, error)
ParsePackagesASTs parses all packages under ./src/ in this project in form of map from package ID to PackageASTs (metadata plus mapping file -> AST).
Types ¶
type PackageASTs ¶
PackageASTs represents single Go package metadata with FileToAST field which is a mapping from package file name to its parsed AST.