Documentation ¶
Index ¶
- Constants
- func BuildCallGraph(projectPath string, packagePattern string, funcDecls map[FuncDescriptor]bool, ...) map[FuncDescriptor][]FuncDescriptor
- func Contains(a []FuncDescriptor, x FuncDescriptor) bool
- func FindFuncDecls(projectPath string, packagePattern string, interfaces map[string]bool) map[FuncDescriptor]bool
- func FindInterfaces(projectPath string, packagePattern string) map[string]bool
- func GetMostInnerAstIdent(inSel *ast.SelectorExpr) *ast.Ident
- func GetPkgNameFromDefsTable(pkg *packages.Package, ident *ast.Ident) string
- func GetPkgNameFromUsesTable(pkg *packages.Package, ident *ast.Ident) string
- func GetPkgPathForFunction(pkg *packages.Package, pkgs []*packages.Package, funDecl *ast.FuncDecl, ...) string
- func GetPkgPathFromFunctionRecv(pkg *packages.Package, pkgs []*packages.Package, funDeclNode *ast.FuncDecl, ...) string
- func GetPkgPathFromRecvInterface(pkg *packages.Package, pkgs []*packages.Package, funDeclNode *ast.FuncDecl, ...) string
- func GetSelectorPkgPath(sel *ast.SelectorExpr, pkg *packages.Package, pkgPath string) string
- func SearchFiles(root string, ext string) []string
- type ContextPropagationPass
- type FileAnalysisPass
- type FuncDescriptor
- type Import
- type InstrumentationPass
- type OtelPruner
- type PackageAnalysis
Constants ¶
const ( // const that tells whether package should be imported. Add importaction = iota // or removed. Remove )
const LoadMode packages.LoadMode = packages.NeedName | packages.NeedTypes | packages.NeedSyntax | packages.NeedTypesInfo | packages.NeedFiles
LoadMode. Tells about needed information during analysis.
Variables ¶
This section is empty.
Functions ¶
func BuildCallGraph ¶
func BuildCallGraph( projectPath string, packagePattern string, funcDecls map[FuncDescriptor]bool, interfaces map[string]bool, ) map[FuncDescriptor][]FuncDescriptor
BuildCallGraph builds an information about flow graph in the following form child->parent.
func FindFuncDecls ¶
func FindFuncDecls(projectPath string, packagePattern string, interfaces map[string]bool) map[FuncDescriptor]bool
FindFuncDecls looks for all function declarations.
func FindInterfaces ¶
FindInterfaces looks for all interfaces.
func GetMostInnerAstIdent ¶
func GetMostInnerAstIdent(inSel *ast.SelectorExpr) *ast.Ident
GetMostInnerAstIdent takes most inner identifier used for function call. For a.b.foo(), `b` will be the most inner identifier.
func GetPkgNameFromDefsTable ¶
GetPkgNameFromDefsTable gets package name from uses table.
func GetPkgNameFromUsesTable ¶
GetPkgNameFromUsesTable gets package name from uses table.
func GetPkgPathForFunction ¶
func GetPkgPathForFunction(pkg *packages.Package, pkgs []*packages.Package, funDecl *ast.FuncDecl, interfaces map[string]bool, ) string
GetPkgPathForFunction builds package path, delegates work to other helper functions defined above.
func GetPkgPathFromFunctionRecv ¶
func GetPkgPathFromFunctionRecv(pkg *packages.Package, pkgs []*packages.Package, funDeclNode *ast.FuncDecl, interfaces map[string]bool, ) string
GetPkgPathFromFunctionRecv build package path taking function receiver parameters.
func GetPkgPathFromRecvInterface ¶
func GetPkgPathFromRecvInterface(pkg *packages.Package, pkgs []*packages.Package, funDeclNode *ast.FuncDecl, interfaces map[string]bool, ) string
GetPkgPathFromRecvInterface builds package path taking receiver interface into account.
func GetSelectorPkgPath ¶
GetSelectorPkgPath builds packages path according to selector expr.
Types ¶
type FileAnalysisPass ¶
type FileAnalysisPass interface { Execute(node *ast.File, analysis *PackageAnalysis, pkg *packages.Package, pkgs []*packages.Package) []Import }
FileAnalysisPass executes an analysis for specific file node - translation unit.
type FuncDescriptor ¶
FuncDescriptor stores an information about id, type and if function requires custom instrumentation.
func FindRootFunctions ¶
func FindRootFunctions(projectPath string, packagePattern string, functionLabel string) []FuncDescriptor
FindRootFunctions looks for all root functions eg. entry points. Currently an entry point is a function that contains call of function passed as functionLabel paramaterer.
func InferRootFunctionsFromGraph ¶
func InferRootFunctionsFromGraph(callgraph map[FuncDescriptor][]FuncDescriptor) []FuncDescriptor
InferRootFunctionsFromGraph tries to infer entry points from passed call graph.
func (FuncDescriptor) TypeHash ¶
func (fd FuncDescriptor) TypeHash() string
Function TypeHash. Each function is itentified by its id and type.
type Import ¶
Stores an information about operations on packages. Currently packages can be imported with an aliases or without.
type PackageAnalysis ¶
type PackageAnalysis struct { ProjectPath string PackagePattern string RootFunctions []FuncDescriptor FuncDecls map[FuncDescriptor]bool Callgraph map[FuncDescriptor][]FuncDescriptor Interfaces map[string]bool Debug bool }
PackageAnalysis analyze all package set accrding to passed pattern. It requires an information about path, pattern, root functions - entry points, function declarations, and so on.
func (*PackageAnalysis) Execute ¶
func (analysis *PackageAnalysis) Execute(pass FileAnalysisPass, fileSuffix string) ([]*ast.File, error)
Execute function, main entry point to analysis process.