-
Notifications
You must be signed in to change notification settings - Fork 46
Closed
Closed
Copy link
Description
type Analyzer struct {
// Requires is a set of analyzers that must run successfully
// before this one on a given package. This analyzer may inspect
// the outputs produced by each analyzer in Requires.
// The graph over analyzers implied by Requires edges must be acyclic.
//
// Requires establishes a "horizontal" dependency between
// analysis passes (different analyzers, same package).
Requires []*Analyzer
}Requires analyzers may be run to compute scope trees, CFGs etc before analysis begins.
For the Run function of dependency analyzers to be able to return value, they must be able to specify the return type. For example, the following analyzer:
var ScopeTreeBuilder = &analysis.Analyzer{
Run: func(pass *analysis.Pass) (interface{}, error) {
// calculate scope tree
// ......
return scopeTree, nil
},
}In the above example, we need to know the concrete type of the value returned, so that we can use it. Thus, the struct needs a new field, ReturnType, of type reflect.Type.
type Analyzer struct {
Requires []*Analyzer
ReturnType reflect.Type
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request