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
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.
type Option ¶
type Option func(*Processor)
Option configures a Processor.
func WithDryRun ¶
WithDryRun enables dry run mode (no file writes).
func WithFunctions ¶ added in v0.6.0
WithFunctions sets function filtering options.
func WithPackageRegexps ¶ added in v0.6.0
WithPackageRegexps sets regex patterns for filtering packages.
func WithRemove ¶
WithRemove enables remove mode (remove generated statements instead of adding).
type ProcessResult ¶
type ProcessResult struct {
FilesProcessed int
FilesModified int
// FilesHeld counts the files left as they are because they hold a
// ctxweaver directive with a warning.
FilesHeld int
Errors []error
// Warnings are problems that do not fail the run, such as a malformed
// directive. Each one starts with its file:line position.
Warnings []string
}
ProcessResult holds the result of processing.
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor handles code transformation.
Its behavior is implemented across process.go, candidate.go and action.go, so the fields are shared with the whole package.