Documentation
¶
Index ¶
- func ExtractFunctionDefinitionCode(source []byte, funcDecl *ast.FuncDecl) string
- func ExtractFunctions(astFile *ast.File) (functions []*ast.FuncDecl)
- func ExtractFunctionsByReceiverName(functions []*ast.FuncDecl, receiverName string, onlyExport bool) (filteredFunctions []*ast.FuncDecl)
- func FindArrayTypeByName(astFile *ast.File, arrayName string) *ast.ArrayType
- func FindClassesAndFunctions(astFile *ast.File) (functions []*ast.FuncDecl, types []*ast.TypeSpec, values []*ast.ValueSpec)
- func FindFunctionByName(astFile *ast.File, functionName string) (function *ast.FuncDecl)
- func FindFunctionByNameWithCheck(astFile *ast.File, functionName string) (result *ast.FuncDecl, found bool)
- func FindFunctionByReceiverAndName(astFile *ast.File, receiverName string, functionName string) (result *ast.FuncDecl, found bool)
- func FindFunctions(astFile *ast.File) (functions []*ast.FuncDecl)
- func FindFunctionsByReceiverName(astFile *ast.File, receiverName string, onlyExport bool) (matchingFunctions []*ast.FuncDecl)
- func FindInterfaceTypes(astFile *ast.File) (interfaceTypesMap map[string]*ast.InterfaceType)
- func FindMainFunction(astFile *ast.File) (mainFunction *ast.FuncDecl)
- func FindStructDeclarationByName(astFile *ast.File, structName string) (structDeclaration *ast.GenDecl, found bool)
- func FindStructTypeByName(astFile *ast.File, structName string) (structContent *ast.StructType, found bool)
- func FindTypes(astFile *ast.File) (types []*ast.TypeSpec)
- func GetFunctionComment(funcDecl *ast.FuncDecl) string
- func GetFunctionReceiverNameAndType(astFunc *ast.FuncDecl, source []byte) (receiverName string, receiverType string)
- func IsFunctionReceiverName(funcDecl *ast.FuncDecl, receiverName string) bool
- func MapStructDeclarationsByName(astFile *ast.File) map[string]*ast.GenDecl
- func MapStructTypesByName(astFile *ast.File) map[string]*ast.StructType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractFunctionDefinitionCode ¶
ExtractFunctionDefinitionCode extracts the code definition of the specified function from the source byte slice. ExtractFunctionDefinitionCode 从源字节切片中提取指定函数的代码定义。
func ExtractFunctions ¶
ExtractFunctions extracts all functions from the given AST file. ExtractFunctions 从给定的AST文件中提取所有函数
func ExtractFunctionsByReceiverName ¶
func ExtractFunctionsByReceiverName(functions []*ast.FuncDecl, receiverName string, onlyExport bool) (filteredFunctions []*ast.FuncDecl)
ExtractFunctionsByReceiverName extracts functions with the specified receiver name from the provided list of functions. ExtractFunctionsByReceiverName 从提供的函数列表中提取具有指定接收者名称的函数
func FindArrayTypeByName ¶
FindArrayTypeByName finds an array type by its name in the given AST file and returns its content (including brackets). FindArrayTypeByName 根据名称查找数组类型,返回结构体内数组的内容(含括号)。
func FindClassesAndFunctions ¶
func FindClassesAndFunctions(astFile *ast.File) (functions []*ast.FuncDecl, types []*ast.TypeSpec, values []*ast.ValueSpec)
FindClassesAndFunctions finds all functions, types, and values in the given AST file. FindClassesAndFunctions 查找给定AST文件中的所有函数、类型和变量。
func FindFunctionByName ¶
FindFunctionByName finds a function by its name in the given AST file and returns the function declaration. FindFunctionByName 根据名称查找函数,返回该函数的声明。
func FindFunctionByNameWithCheck ¶
func FindFunctionByNameWithCheck(astFile *ast.File, functionName string) (result *ast.FuncDecl, found bool)
FindFunctionByNameWithCheck finds a function by name with a check for its existence in the given AST file. FindFunctionByNameWithCheck 查找给定AST文件中指定名称的函数,并检查是否存在
func FindFunctionByReceiverAndName ¶
func FindFunctionByReceiverAndName(astFile *ast.File, receiverName string, functionName string) (result *ast.FuncDecl, found bool)
FindFunctionByReceiverAndName finds a function by both its receiver name and function name in the given AST file. FindFunctionByReceiverAndName 查找给定AST文件中具有指定接收者名称和函数名称的函数
func FindFunctions ¶
FindFunctions finds all function declarations in the given AST file. FindFunctions 查找给定AST文件中的所有函数声明。
func FindFunctionsByReceiverName ¶
func FindFunctionsByReceiverName(astFile *ast.File, receiverName string, onlyExport bool) (matchingFunctions []*ast.FuncDecl)
FindFunctionsByReceiverName finds all functions with the specified receiver name in the given AST file. FindFunctionsByReceiverName 查找给定AST文件中具有指定接收者名称的所有函数
func FindInterfaceTypes ¶
func FindInterfaceTypes(astFile *ast.File) (interfaceTypesMap map[string]*ast.InterfaceType)
FindInterfaceTypes finds all interface types in the given AST file and returns a map of interface names to their corresponding interface content. FindInterfaceTypes 查找给定AST文件中的所有接口类型,并返回一个接口名称到其对应接口内容的映射。
func FindMainFunction ¶
FindMainFunction finds the main function in the given AST file. FindMainFunction 查找给定AST文件中的main函数
func FindStructDeclarationByName ¶ added in v0.0.37
func FindStructDeclarationByName(astFile *ast.File, structName string) (structDeclaration *ast.GenDecl, found bool)
FindStructDeclarationByName finds a struct type by its name in the given AST file and returns its declaration and content (including type and brackets). FindStructDeclarationByName 根据名称查找结构体类型,返回结构体的定义和内容(含type开头和括号结尾)。
func FindStructTypeByName ¶
func FindStructTypeByName(astFile *ast.File, structName string) (structContent *ast.StructType, found bool)
FindStructTypeByName finds a struct type by its name in the given AST file and returns its content (including brackets). FindStructTypeByName 根据名称查找结构体类型,返回结构体内的内容(含括号)。
func FindTypes ¶
FindTypes finds all type declarations in the given AST file. FindTypes 查找给定AST文件中的所有类型声明。
func GetFunctionComment ¶ added in v0.0.41
GetFunctionComment extracts the documentation comment of the specified function. GetFunctionComment 提取指定函数的文档注释。
func GetFunctionReceiverNameAndType ¶
func GetFunctionReceiverNameAndType(astFunc *ast.FuncDecl, source []byte) (receiverName string, receiverType string)
GetFunctionReceiverNameAndType gets the receiver name and type of the given function declaration. GetFunctionReceiverNameAndType 获取给定函数声明的接收者名称和类型
func IsFunctionReceiverName ¶
IsFunctionReceiverName checks if the specified receiver name matches the receiver of the function. IsFunctionReceiverName 检查指定的接收者名称是否与函数的接收者匹配。
func MapStructDeclarationsByName ¶ added in v0.0.37
MapStructDeclarationsByName finds all struct types in the given AST file and returns a map of struct names to their complete declarations (from type to closing bracket). MapStructDeclarationsByName 查找给定AST文件中的所有结构体类型,并返回一个结构体名称到其完整声明(从type开始到闭括号结束)的映射。
func MapStructTypesByName ¶
func MapStructTypesByName(astFile *ast.File) map[string]*ast.StructType
MapStructTypesByName finds all struct types in the given AST file and returns a map of struct names to their corresponding struct content (including brackets). MapStructTypesByName 查找给定AST文件中的所有结构体类型,并返回一个结构体名称到其对应结构体内容(含括号)的映射。
Types ¶
This section is empty.