ast

package
v0.0.0-...-4776b94 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFilesFuncDecls

func FindFilesFuncDecls(files []*ast.File) []*ast.FuncDecl

func FindFuncDeclByName

func FindFuncDeclByName(file *ast.File, funcName string) (*ast.FuncDecl, error)

func FindFuncDecls

func FindFuncDecls(file *ast.File) []*ast.FuncDecl

func GetFunc

func GetFunc(pkg *packages.Package, funcName string) (*ast.FuncDecl, error)

func GetFuncs

func GetFuncs(pkg *packages.Package) []*ast.FuncDecl

func GetPackage

func GetPackage(folder, packageName string) (*packages.Package, error)

func GetPackages

func GetPackages(folder string) ([]*packages.Package, error)

func GetType

func GetType(pkg *packages.Package, target ast.Expr) (*types.TypeAndValue, error)

func Inspect

func Inspect(node ast.Node, pre func(ast.Node), f func(ast.Node) bool, post func(ast.Node))

func ParseFile

func ParseFile(code string) (*ast.File, error)

func Walk

func Walk(v Visitor, node ast.Node)

Walk traverses an AST in depth-first order: It starts by calling v.Visit(node); node must not be nil. If the visitor w returned by v.Visit(node) is not nil, Walk is invoked recursively with visitor w for each of the non-nil children of node, followed by a call of w.Visit(nil).

Types

type Visitor

type Visitor interface {
	Pre(node ast.Node)
	Visit(node ast.Node) (w Visitor)
	Post(node ast.Node)
}

A Visitor's Visit method is invoked for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor w, followed by a call of w.Visit(nil).

Jump to

Keyboard shortcuts

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