Documentation
¶
Index ¶
- func GetCaller(n *ast.CallExpr) (string, bool)
- func GetExprTypeName(expr ast.Expr) string
- func GetFunctionChain(n *ast.CallExpr) string
- func GetPackageImportPaths(f *ast.File) map[string]string
- func GetReceiverTypeName(fn *ast.FuncDecl, ignorePointer ...bool) string
- func GetStructInfo(n *ast.GenDecl) (string, *ast.StructType, bool)
- func GetVarDeclsFromFile(file *ast.File) map[string]*ast.ValueSpec
- func GetVarDeclsFromFunc(body *ast.BlockStmt) map[string]*ast.ValueSpec
- func GetVarTypes(node ast.Node) map[string]string
- func InspectPackage(srcDir string, excludeDirs []string) (map[string]*Package, error)
- func MatchCall(n *ast.CallExpr, signature *CallSignature, imports map[string]string) bool
- func MatchFunction(fn *ast.FuncDecl, signature *FunctionSignature) bool
- func ParseFunctionCallChain(n *ast.CallExpr) []string
- func ResolveVarType(expr ast.Expr) string
- type ASTUtils
- type Annotation
- type CallSignature
- type Function
- type FunctionSignature
- type Package
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPackageImportPaths ¶
GetPackageImportPaths 获取包导入路径
func GetReceiverTypeName ¶
GetReceiverTypeName 获取函数的receiver类型, 如果ignorePointer为true, 则去除前面的*号 e,g: (*Person) hello() {}, 传入hello的ast.FuncDecl, 返回Person
func GetStructInfo ¶
GetStructInfo 获取结构信息
func GetVarDeclsFromFile ¶
GetVarDeclsFromFile 查找变量声明
func GetVarDeclsFromFunc ¶
GetVarDeclsFromFunc 从函数体中提取所有 *ast.ValueSpec 提取函数体内所有ValueSpec(包括转换短声明)
func InspectPackage ¶
InspectPackage 从源代码目录中获取包的信息, 包相对路径=>包信息
func MatchFunction ¶
func MatchFunction(fn *ast.FuncDecl, signature *FunctionSignature) bool
func ParseFunctionCallChain ¶
ParseFunctionCallChain 递归解析链式函数调用,最近的Ident.Name作为包名,最先调用的函数在slice的最前面
func ResolveVarType ¶
ResolveVarType 解析表达式的实际类型名(如 v2_captcha)
Types ¶
type CallSignature ¶
type Function ¶
type Function struct {
Receiver string
Function string
Annotations map[string]*Annotation // annotationName->*AstAnnotation
PlainComments []string // 去除注解后的注释
}
type FunctionSignature ¶
Click to show internal directories.
Click to hide internal directories.