lib

package
v0.0.0-...-1e3363d Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// const that tells whether package should be imported.
	Add importaction = iota
	// or removed.
	Remove
)

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 Contains

func Contains(a []FuncDescriptor, x FuncDescriptor) bool

Contains.

func FindFuncDecls

func FindFuncDecls(projectPath string, packagePattern string, interfaces map[string]bool) map[FuncDescriptor]bool

FindFuncDecls looks for all function declarations.

func FindInterfaces

func FindInterfaces(projectPath string, packagePattern string) map[string]bool

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

func GetPkgNameFromDefsTable(pkg *packages.Package, ident *ast.Ident) string

GetPkgNameFromDefsTable gets package name from uses table.

func GetPkgNameFromUsesTable

func GetPkgNameFromUsesTable(pkg *packages.Package, ident *ast.Ident) string

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

func GetSelectorPkgPath(sel *ast.SelectorExpr, pkg *packages.Package, pkgPath string) string

GetSelectorPkgPath builds packages path according to selector expr.

func SearchFiles

func SearchFiles(root string, ext string) []string

SearchFiles.

Types

type ContextPropagationPass

type ContextPropagationPass struct{}

ContextPropagationPass.

func (*ContextPropagationPass) Execute

func (pass *ContextPropagationPass) Execute(
	node *ast.File,
	analysis *PackageAnalysis,
	pkg *packages.Package,
	pkgs []*packages.Package,
) []Import

Execute.

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

type FuncDescriptor struct {
	Id              string
	DeclType        string
	CustomInjection bool
}

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

type Import struct {
	NamedPackage string
	Package      string
	ImportAction importaction
}

Stores an information about operations on packages. Currently packages can be imported with an aliases or without.

type InstrumentationPass

type InstrumentationPass struct{}

InstrumentationPass.

func (*InstrumentationPass) Execute

func (pass *InstrumentationPass) Execute(
	node *ast.File,
	analysis *PackageAnalysis,
	pkg *packages.Package,
	pkgs []*packages.Package,
) []Import

Execute.

type OtelPruner

type OtelPruner struct{}

OtelPruner.

func (*OtelPruner) Execute

func (pass *OtelPruner) Execute(
	node *ast.File,
	analysis *PackageAnalysis,
	pkg *packages.Package,
	pkgs []*packages.Package,
) []Import

Execute.

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.

Jump to

Keyboard shortcuts

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