processor

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package processor provides DST-based code transformation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action added in v0.6.1

type Action interface {
	// Apply executes the action on the function body.
	// Returns true if the body was modified.
	Apply(body *dst.BlockStmt, rendered string) bool
}

Action represents an operation to apply to a function body. Implementations encapsulate the logic for each action type.

type CompiledRegexps added in v0.6.0

type CompiledRegexps struct {
	Only []*regexp.Regexp
	Omit []*regexp.Regexp
}

CompiledRegexps holds compiled regex patterns for filtering.

func CompileRegexps added in v0.6.0

func CompileRegexps(r config.Regexps) CompiledRegexps

CompileRegexps compiles regex patterns from config.

func (*CompiledRegexps) Match added in v0.6.0

func (r *CompiledRegexps) Match(s string) bool

Match checks if a string matches the filter criteria. Returns true if the string should be included.

type FuncFilter added in v0.6.0

type FuncFilter struct {
	Types   []config.FuncType
	Scopes  []config.FuncScope
	Regexps CompiledRegexps
}

FuncFilter holds compiled function filter settings.

func NewFuncFilter added in v0.6.0

func NewFuncFilter(f config.Functions) *FuncFilter

NewFuncFilter creates a FuncFilter from config.Functions.

func (*FuncFilter) Match added in v0.6.0

func (f *FuncFilter) Match(funcName string, isMethod, isExported bool) bool

Match checks if a function should be processed.

type Option

type Option func(*Processor)

Option configures a Processor.

func WithDryRun

func WithDryRun(dryRun bool) Option

WithDryRun enables dry run mode (no file writes).

func WithFunctions added in v0.6.0

func WithFunctions(f config.Functions) Option

WithFunctions sets function filtering options.

func WithPackageRegexps added in v0.6.0

func WithPackageRegexps(r config.Regexps) Option

WithPackageRegexps sets regex patterns for filtering packages.

func WithRemove

func WithRemove(remove bool) Option

WithRemove enables remove mode (remove generated statements instead of adding).

func WithTest

func WithTest(test bool) Option

WithTest enables processing of test files.

func WithVerbose

func WithVerbose(verbose bool) Option

WithVerbose enables verbose output.

type ProcessResult

type ProcessResult struct {
	FilesProcessed int
	FilesModified  int
	Errors         []error
}

ProcessResult holds the result of processing.

type Processor

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

Processor handles code transformation.

func New

func New(registry *config.CarrierRegistry, tmpl *template.Template, importPaths []string, opts ...Option) *Processor

New creates a new Processor.

func (*Processor) Process

func (p *Processor) Process(patterns []string) (*ProcessResult, error)

Process processes the given package patterns.

Jump to

Keyboard shortcuts

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