Documentation ¶
Index ¶
- Variables
- func LoadPackages(config *Config) ([]*packages.Package, error)
- func NewAnalysisPass(pkg *packages.Package, store FactStore) *analysis.Pass
- func PackageLoaderConfig(dir string) *packages.Config
- func Run(config *Config) (result []*analysis.Pass, pkgs []*packages.Package, err error)
- func TestingConfig(dir string) *packages.Config
- type Config
- func (c *Config) WithAnalyzers(analyzers []*analysis.Analyzer) *Config
- func (c *Config) WithDir(dir string) *Config
- func (c *Config) WithFactStore(factStore FactStore) *Config
- func (c *Config) WithLoaderConfig(loaderConfig *packages.Config) *Config
- func (c *Config) WithLogger(logger *slog.Logger) *Config
- func (c *Config) WithPatterns(patterns []string) *Config
- func (c *Config) WithRunDespiteErrors(runDespiteErrors bool) *Config
- type FactStore
- type NoOpFactStore
- func (n NoOpFactStore) AllObjectFacts() []analysis.ObjectFact
- func (n NoOpFactStore) AllPackageFacts() []analysis.PackageFact
- func (n NoOpFactStore) ExportObjectFact(obj types.Object, fact analysis.Fact)
- func (n NoOpFactStore) ExportPackageFact(fact analysis.Fact)
- func (n NoOpFactStore) ImportObjectFact(obj types.Object, fact analysis.Fact) bool
- func (n NoOpFactStore) ImportPackageFact(pkg *types.Package, fact analysis.Fact) bool
- func (n NoOpFactStore) ReadFile(filename string) ([]byte, error)
- func (n NoOpFactStore) Report(diagnostic analysis.Diagnostic)
- type Runner
Constants ¶
This section is empty.
Variables ¶
View Source
var GraphError = errors.New("graph error")
View Source
var GraphWalkError = errors.Join(GraphError, errors.New("walk error"))
Functions ¶
func PackageLoaderConfig ¶
func TestingConfig ¶
Types ¶
type Config ¶
type Config struct { Patterns []string FactStore FactStore Analyzers []*analysis.Analyzer RunDespiteErrors bool LoaderConfig *packages.Config Logger *slog.Logger }
func ConfigDefaults ¶
func ConfigDefaults() *Config
func (*Config) WithAnalyzers ¶
func (*Config) WithFactStore ¶
func (*Config) WithLoaderConfig ¶
func (*Config) WithPatterns ¶
func (*Config) WithRunDespiteErrors ¶
type FactStore ¶
type FactStore interface { // ReadFile returns the contents of the named file. // // The only valid file names are the elements of OtherFiles // and IgnoredFiles, and names returned by // Fset.File(f.FileStart).Name() for each f in Files. // // Analyzers must use this function (if provided) instead of // accessing the file system directly. This allows a driver to // provide a virtualized file tree (including, for example, // unsaved editor buffers) and to track dependencies precisely // to avoid unnecessary computation. ReadFile(filename string) ([]byte, error) // Report reports a Diagnostic, a finding about a specific location // in the analyzed source code such as a potential mistake. // It may be called by the Run function. Report(diagnostic analysis.Diagnostic) // ImportObjectFact retrieves a fact associated with obj. // Given a value ptr of type *T, where *T satisfies Fact, // ImportObjectFact copies the value to *ptr. // // ImportObjectFact panics if called after the pass is complete. // ImportObjectFact is not concurrency-safe. ImportObjectFact(obj types.Object, fact analysis.Fact) bool // ImportPackageFact retrieves a fact associated with package pkg, // which must be this package or one of its dependencies. // See comments for ImportObjectFact. ImportPackageFact(pkg *types.Package, fact analysis.Fact) bool // ExportObjectFact associates a fact of type *T with the obj, // replacing any previous fact of that type. // // ExportObjectFact panics if it is called after the pass is // complete, or if obj does not belong to the package being analyzed. // ExportObjectFact is not concurrency-safe. ExportObjectFact(obj types.Object, fact analysis.Fact) // ExportPackageFact associates a fact with the current package. // See comments for ExportObjectFact. ExportPackageFact(fact analysis.Fact) // AllPackageFacts returns a new slice containing all package // facts of the analysis's FactTypes in unspecified order. AllPackageFacts() []analysis.PackageFact // AllObjectFacts returns a new slice containing all object // facts of the analysis's FactTypes in unspecified order. AllObjectFacts() []analysis.ObjectFact }
type NoOpFactStore ¶
type NoOpFactStore struct{}
func (NoOpFactStore) AllObjectFacts ¶
func (n NoOpFactStore) AllObjectFacts() []analysis.ObjectFact
func (NoOpFactStore) AllPackageFacts ¶
func (n NoOpFactStore) AllPackageFacts() []analysis.PackageFact
func (NoOpFactStore) ExportObjectFact ¶
func (n NoOpFactStore) ExportObjectFact(obj types.Object, fact analysis.Fact)
func (NoOpFactStore) ExportPackageFact ¶
func (n NoOpFactStore) ExportPackageFact(fact analysis.Fact)
func (NoOpFactStore) ImportObjectFact ¶
func (NoOpFactStore) ImportPackageFact ¶
func (NoOpFactStore) Report ¶
func (n NoOpFactStore) Report(diagnostic analysis.Diagnostic)
Click to show internal directories.
Click to hide internal directories.