Documentation
¶
Index ¶
- Constants
- func DecoratorFilter(m mutator.Mutator, name string, filters ...filter.NodeFilter) mutator.Mutator
- func HandleBlockStmt(node ast.Stmt) bool
- type BaseCollector
- type ChainCollector
- type FunctionAnnotation
- type LineAnnotation
- type NextLineAnnotationCollector
- type Processor
- type RegexAnnotation
- type RegexAnnotationCollector
Constants ¶
const ( FuncAnnotation = "// mutator-disable-func" RegexpAnnotation = "// mutator-disable-regexp" NextLineAnnotation = "// mutator-disable-next-line" )
Annotation constants define the comment patterns used to disable mutations
Variables ¶
This section is empty.
Functions ¶
func DecoratorFilter ¶
DecoratorFilter creates a mutator that applies one or more filters before executing the provided mutator.
func HandleBlockStmt ¶
HandleBlockStmt is a temporary workaround specifically for handling BlockStmt nodes in AST. It performs cleanup and transfers collected annotation data to statement nodes within blocks. This is a tactical solution to handle edge cases where mutators only look at nodes inside block statements. A more robust architectural solution should be implemented in future versions.
Types ¶
type BaseCollector ¶
type BaseCollector struct {
// contains filtered or unexported fields
}
BaseCollector provides default chain handling behavior
func (*BaseCollector) Handle ¶
func (h *BaseCollector) Handle(name string, comment *ast.Comment, fset *token.FileSet, file *ast.File, fileAbs string)
Handle implements the default chain behavior by delegating to the next handler.
func (*BaseCollector) SetNext ¶
func (h *BaseCollector) SetNext(next ChainCollector)
SetNext sets the next handler in the chain of responsibility.
type ChainCollector ¶
type ChainCollector interface { // Handle processes an annotation if it matches the handler's type, // otherwise delegates to the next handler in the chain. Handle(name string, comment *ast.Comment, fset *token.FileSet, file *ast.File, fileAbs string) // SetNext establishes the next handler in the chain of responsibility. SetNext(next ChainCollector) }
ChainCollector defines the interface for handlers in the annotation processing chain. Implementations should handle specific annotation types and pass unhandled cases to the next handler in the chain.
type FunctionAnnotation ¶
FunctionAnnotation represents a collection of exclusions of function declarations.
type LineAnnotation ¶
LineAnnotation represents a collection of exclusions based on lines in the file.
type NextLineAnnotationCollector ¶
type NextLineAnnotationCollector struct { BaseCollector Processor LineAnnotation }
NextLineAnnotationCollector implements the ChainCollector interface for "mutator-disable-next-line" annotations.
type Processor ¶
type Processor struct { FunctionAnnotation FunctionAnnotation RegexAnnotation RegexAnnotation LineAnnotation LineAnnotation }
Processor handles mutation exclusion logic based on source code annotations.
func NewProcessor ¶
func NewProcessor() *Processor
NewProcessor creates and returns a new initialized Processor.
type RegexAnnotation ¶
RegexAnnotation represents a collection of exclusions based on regex pattern matches.
type RegexAnnotationCollector ¶
type RegexAnnotationCollector struct { BaseCollector Processor RegexAnnotation }
RegexAnnotationCollector implements the ChainCollector interface for "mutator-disable-regexp" annotations.