Documentation
¶
Index ¶
- type AnalyzerContext
- func (ctx *AnalyzerContext) ClearIssues()
- func (ctx *AnalyzerContext) GetCustom(key string) (any, bool)
- func (ctx *AnalyzerContext) GetFset() *token.FileSet
- func (ctx *AnalyzerContext) GetIssues() []result.Issue
- func (ctx *AnalyzerContext) Info() *types.Info
- func (ctx *AnalyzerContext) RegisterRule(rule *Rule)
- func (ctx *AnalyzerContext) Report(issue result.Issue)
- func (ctx *AnalyzerContext) SetCustom(key string, value any)
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalyzerContext ¶
type AnalyzerContext struct {
// Fset holds the parsed file set for position information.
Fset *token.FileSet
// Types contains type-checker results.
Types *types.Info
// SSA contains the SSA function representation of the current package.
SSA *ssa.Package
// Filename represents the absolute or relative path of the file being analyzed.
Filename string
// PackageName is the Go package name.
PackageName string
// Source holds the entire source code of the file (optional, useful for highlighting).
Source []byte
// CustomData is a generic key-value map that allows analyzers to store state.
CustomData map[string]any
// Rules stores registered rules for analysis
Rules []*Rule
// Issues stores found issues during analysis
Issues []result.Issue
}
AnalyzerContext represents the shared context used during all analysis phases.
func NewAnalyzerContext ¶
func NewAnalyzerContext( fset *token.FileSet, typesInfo *types.Info, ssaPkg *ssa.Package, filename string, packageName string, source []byte, ) *AnalyzerContext
NewAnalyzerContext creates a new AnalyzerContext instance.
func (*AnalyzerContext) ClearIssues ¶
func (ctx *AnalyzerContext) ClearIssues()
ClearIssues clears all reported issues.
func (*AnalyzerContext) GetCustom ¶
func (ctx *AnalyzerContext) GetCustom(key string) (any, bool)
GetCustom retrieves a value from the CustomData map.
func (*AnalyzerContext) GetFset ¶
func (ctx *AnalyzerContext) GetFset() *token.FileSet
GetFset returns the file set for position information.
func (*AnalyzerContext) GetIssues ¶
func (ctx *AnalyzerContext) GetIssues() []result.Issue
GetIssues returns all reported issues.
func (*AnalyzerContext) Info ¶
func (ctx *AnalyzerContext) Info() *types.Info
Info returns the types info.
func (*AnalyzerContext) RegisterRule ¶
func (ctx *AnalyzerContext) RegisterRule(rule *Rule)
RegisterRule registers a rule with the analyzer context.
func (*AnalyzerContext) Report ¶
func (ctx *AnalyzerContext) Report(issue result.Issue)
Report reports an issue found during analysis.
func (*AnalyzerContext) SetCustom ¶
func (ctx *AnalyzerContext) SetCustom(key string, value any)
SetCustom sets a value in the CustomData map.
Click to show internal directories.
Click to hide internal directories.