syntaxgo_search

package
v0.0.44 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFunctionDefinitionCode

func ExtractFunctionDefinitionCode(source []byte, funcDecl *ast.FuncDecl) string

ExtractFunctionDefinitionCode extracts the code definition of the specified function from the source byte slice. ExtractFunctionDefinitionCode 从源字节切片中提取指定函数的代码定义。

func ExtractFunctions

func ExtractFunctions(astFile *ast.File) (functions []*ast.FuncDecl)

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

func FindArrayTypeByName(astFile *ast.File, arrayName string) *ast.ArrayType

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

func FindFunctionByName(astFile *ast.File, functionName string) (function *ast.FuncDecl)

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

func FindFunctions(astFile *ast.File) (functions []*ast.FuncDecl)

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

func FindMainFunction(astFile *ast.File) (mainFunction *ast.FuncDecl)

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

func FindTypes(astFile *ast.File) (types []*ast.TypeSpec)

FindTypes finds all type declarations in the given AST file. FindTypes 查找给定AST文件中的所有类型声明。

func GetFunctionComment added in v0.0.41

func GetFunctionComment(funcDecl *ast.FuncDecl) string

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

func IsFunctionReceiverName(funcDecl *ast.FuncDecl, receiverName string) bool

IsFunctionReceiverName checks if the specified receiver name matches the receiver of the function. IsFunctionReceiverName 检查指定的接收者名称是否与函数的接收者匹配。

func MapStructDeclarationsByName added in v0.0.37

func MapStructDeclarationsByName(astFile *ast.File) map[string]*ast.GenDecl

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.

Jump to

Keyboard shortcuts

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