Documentation
¶
Index ¶
- Constants
- type DBStore
- type FuncEdge
- type FuncNode
- type ProgramAnalysis
- func (p *ProgramAnalysis) Analysis() error
- func (p *ProgramAnalysis) GetMainPackage(pkgs []*ssa.Package) ([]*ssa.Package, error)
- func (p *ProgramAnalysis) GetModuleName() (string, error)
- func (p *ProgramAnalysis) GetNode(key string) *FuncNode
- func (p *ProgramAnalysis) NodeIsExist(key string) bool
- func (p *ProgramAnalysis) SaveData(ctx context.Context) error
- func (p *ProgramAnalysis) SetTree() error
- type ProgramOption
Constants ¶
View Source
const ( DefaultOutput = "./default.png" DefaultCache = "./cachePath.json" CallGraphTypeStatic = "static" CallGraphTypeCha = "cha" CallGraphTypeRta = "rta" // 默认使用 CallGraphTypeVta = "vta" )
常量定义
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBStore ¶
type DBStore interface { // SaveFuncNode 保存函数节点 SaveFuncNode(node *FuncNode) error // SaveFuncEdge 保存函数调用关系 SaveFuncEdge(edge *FuncEdge) error // GetFuncNodeByKey 根据Key获取函数节点 GetFuncNodeByKey(key string) (*FuncNode, error) // GetCallerEdges 获取调用该函数的所有边 GetCallerEdges(calleeKey string) ([]*FuncNode, error) // GetCalleeEdges 获取该函数调用的所有边 GetCalleeEdges(callerKey string) ([]*FuncNode, error) }
添加用于存储的方法
type FuncNode ¶
type FuncNode struct { Key string `json:"key"` // 唯一标识 Pkg string `json:"pkg"` // 包名 Name string `json:"name"` // 函数名 Parent []string `json:"parent"` // 父节点索引 Children []string `json:"children"` // 子节点索引 }
FuncNode 表示函数节点
type ProgramAnalysis ¶
type ProgramAnalysis struct { Dir string // 项目目录 // contains filtered or unexported fields }
ProgramAnalysis 定义程序分析的主要结构
func NewProgramAnalysis ¶
func NewProgramAnalysis(dir string, logger log.Logger, data DBStore, opts ...ProgramOption) *ProgramAnalysis
NewProgramAnalysis 创建新的程序分析实例
func (*ProgramAnalysis) GetMainPackage ¶
func (*ProgramAnalysis) GetModuleName ¶
func (p *ProgramAnalysis) GetModuleName() (string, error)
GetModuleName 从go.mod文件中获取模块名
func (*ProgramAnalysis) GetNode ¶
func (p *ProgramAnalysis) GetNode(key string) *FuncNode
GetNode 获取节点
func (*ProgramAnalysis) NodeIsExist ¶
func (p *ProgramAnalysis) NodeIsExist(key string) bool
func (*ProgramAnalysis) SaveData ¶
func (p *ProgramAnalysis) SaveData(ctx context.Context) error
SaveData 异步保存数据到数据库
func (*ProgramAnalysis) SetTree ¶
func (p *ProgramAnalysis) SetTree() error
SetTree
@Description: 生成项目整体的语法树 @receiver p @return error
type ProgramOption ¶
type ProgramOption func(p *ProgramAnalysis)
ProgramOption 定义程序分析的配置选项函数类型
func WithAlgo ¶
func WithAlgo(algo string) ProgramOption
func WithCacheDir ¶
func WithCacheDir(cache string) ProgramOption
func WithCacheFlag ¶
func WithCacheFlag(flag bool) ProgramOption
func WithIgnorePaths ¶
func WithIgnorePaths(ignorePath string) ProgramOption
func WithOnlyPkg ¶
func WithOnlyPkg(onlyPkg string) ProgramOption
func WithOutputDir ¶
func WithOutputDir(output string) ProgramOption
Click to show internal directories.
Click to hide internal directories.