pipeline

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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 LoadPackages

func LoadPackages(config *Config) ([]*packages.Package, error)

func NewAnalysisPass

func NewAnalysisPass(pkg *packages.Package, store FactStore) *analysis.Pass

func PackageLoaderConfig

func PackageLoaderConfig(dir string) *packages.Config

func Run

func Run(config *Config) (result []*analysis.Pass, pkgs []*packages.Package, err error)

func TestingConfig

func TestingConfig(dir string) *packages.Config

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 (c *Config) WithAnalyzers(analyzers []*analysis.Analyzer) *Config

func (*Config) WithDir

func (c *Config) WithDir(dir string) *Config

func (*Config) WithFactStore

func (c *Config) WithFactStore(factStore FactStore) *Config

func (*Config) WithLoaderConfig

func (c *Config) WithLoaderConfig(loaderConfig *packages.Config) *Config

func (*Config) WithLogger

func (c *Config) WithLogger(logger *slog.Logger) *Config

func (*Config) WithPatterns

func (c *Config) WithPatterns(patterns []string) *Config

func (*Config) WithRunDespiteErrors

func (c *Config) WithRunDespiteErrors(runDespiteErrors bool) *Config

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 (n NoOpFactStore) ImportObjectFact(obj types.Object, fact analysis.Fact) bool

func (NoOpFactStore) ImportPackageFact

func (n NoOpFactStore) ImportPackageFact(pkg *types.Package, fact analysis.Fact) bool

func (NoOpFactStore) ReadFile

func (n NoOpFactStore) ReadFile(filename string) ([]byte, error)

func (NoOpFactStore) Report

func (n NoOpFactStore) Report(diagnostic analysis.Diagnostic)

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(analyzers ...*analysis.Analyzer) *Runner

func (*Runner) Execute

func (r *Runner) Execute(pass *analysis.Pass) error

Jump to

Keyboard shortcuts

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