Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PropagateAnalysis ¶
func PropagateAnalysis(allInfo []*Info)
PropagateAnalysis will propagate analysis information across package boundaries to finish the analysis of a whole project.
Types ¶
type FuncInfo ¶
type FuncInfo struct { // HasDefer indicates if any defer statement exists in the function. HasDefer bool // Nodes are "flattened" into a switch-case statement when we need to be able // to jump into an arbitrary position in the code with a GOTO statement, or // resume a goroutine after a blocking call unblocks. Flattened map[ast.Node]bool // Blocking indicates that either the AST node itself or its descendant may // block goroutine execution (for example, a channel operation). Blocking map[ast.Node]bool // GotoLabel indicates a label referenced by a goto statement, rather than a // named loop. GotoLabel map[*types.Label]bool // contains filtered or unexported fields }
func (*FuncInfo) IsBlocking ¶
IsBlocking indicates if this function may block goroutine execution.
For example, a channel operation in a function or a call to another possibly blocking function may block the function.
type Info ¶
type Info struct { *types.Info Pkg *types.Package InstanceSets *typeparams.PackageInstanceSets HasPointer map[*types.Var]bool InitFuncInfo *FuncInfo // Context for package variable initialization. // contains filtered or unexported fields }
func AnalyzePkg ¶
func AnalyzePkg(files []*ast.File, fileSet *token.FileSet, typesInfo *types.Info, typeCtx *types.Context, typesPkg *types.Package, instanceSets *typeparams.PackageInstanceSets, infoImporter InfoImporter) *Info
AnalyzePkg analyzes the given package for blocking calls, defers, etc.
Note that at the end of this call the analysis information has NOT been propagated across packages yet. Once all the packages have been analyzed, call PropagateAnalysis to propagate the information.
func (*Info) FuncInfo ¶
func (info *Info) FuncInfo(inst typeparams.Instance) *FuncInfo
FuncInfo returns information about the given function declaration instance, or nil if not found.
func (*Info) FuncLitInfo ¶
FuncLitInfo returns information about the given function literal, or nil if not found. The given type arguments are used to identify the correct instance of the function literal in the case the literal was defined inside a generic function.
func (*Info) IsBlocking ¶
func (info *Info) IsBlocking(inst typeparams.Instance) bool
IsBlocking returns true if the function may contain blocking calls or operations. If inst is from a different package, this will use the getImportInfo function to lookup the information from the other package.
type InfoImporter ¶
InfoImporter is used to get the `Info` for another package. The path is the resolved import path of the package to get the `Info` for.