Documentation
¶
Overview ¶
Package detect provides symbol detection and type resolution for Go packages.
Index ¶
- func CollectStructMethods(astFiles []*dst.File, fset *token.FileSet, structName string) map[string]*dst.FuncType
- func ExtractPackageName(qualifiedName string) string
- func FindImportPath(astFiles []*dst.File, pkgName string, pkgLoader PackageLoader) (string, error)
- func GetImportPathFromFiles(files []*dst.File, fset *token.FileSet, _ string) (string, error)
- func InferImportPathFromTestFile(goFilePath, pkgName string) (string, error)
- func IsStdlibPackage(pkgName string) bool
- type FuncTypeWithDetails
- type IfaceWithDetails
- type PackageLoader
- type StructWithDetails
- type SymbolDetails
- type SymbolType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectStructMethods ¶
func CollectStructMethods( astFiles []*dst.File, fset *token.FileSet, structName string, ) map[string]*dst.FuncType
CollectStructMethods collects all methods for a given struct type from AST files.
func ExtractPackageName ¶
ExtractPackageName extracts the package name from a fully qualified name.
func FindImportPath ¶
func FindImportPath( astFiles []*dst.File, pkgName string, pkgLoader PackageLoader, ) (string, error)
FindImportPath finds the import path for a given package name by parsing the provided AST files.
func GetImportPathFromFiles ¶
GetImportPathFromFiles determines the import path of a package by examining its loaded files.
func InferImportPathFromTestFile ¶
InferImportPathFromTestFile parses the given test file and attempts to find the import path for a package with the given name.
func IsStdlibPackage ¶
IsStdlibPackage checks if a package name is a standard library package.
Types ¶
type FuncTypeWithDetails ¶
type IfaceWithDetails ¶
type IfaceWithDetails struct {
Iface *dst.InterfaceType
TypeParams *dst.FieldList
SourceImports []*dst.ImportSpec // imports from the file containing the interface
IsStructType bool // true if this was synthesized from a struct type
}
func GetMatchingInterfaceFromAST ¶
func GetMatchingInterfaceFromAST( astFiles []*dst.File, interfaceName, pkgImportPath string, ) (IfaceWithDetails, error)
GetMatchingInterfaceFromAST extracts the target interface declaration from AST files.
type PackageLoader ¶
type StructWithDetails ¶
type StructWithDetails struct {
TypeParams *dst.FieldList
TypeName string // The name of the struct type (e.g., "Calculator")
SourceImports []*dst.ImportSpec // imports from the file containing the struct
}
type SymbolDetails ¶
type SymbolDetails struct {
Kind SymbolType
Iface IfaceWithDetails
FuncDecl *dst.FuncDecl
FuncType FuncTypeWithDetails
StructType StructWithDetails
// PkgPath tracks which package the symbol was found in.
// For symbols found via dot imports, this differs from the search package.
PkgPath string
}
func FindSymbol ¶
func FindSymbol( astFiles []*dst.File, fset *token.FileSet, symbolName, pkgImportPath string, pkgLoader PackageLoader, ) (SymbolDetails, error)
FindSymbol looks for either an interface, struct type, function type, or function/method in the given AST files.
type SymbolType ¶
type SymbolType int
const ( SymbolInterface SymbolType = iota SymbolFunction SymbolFunctionType SymbolStructType )
SymbolType values.