gosourcefile

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoSourceFile

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

func New

func New(relativePath string, rawContent []byte) *GoSourceFile

func (*GoSourceFile) Incubate

func (f *GoSourceFile) Incubate(viri ...viruses.Virus) []*goinfectedfile.GoInfectedFile

Incubate parses the file once and offers it to every mutator given.

It takes the whole set rather than one mutator because the parse is the expensive part and it does not depend on which mutator is asking. Called once per mutator, as it was, a source file was parsed fourteen times per release with the default set — thirteen of them producing an identical tree.

Each mutator still walks the tree in its own pass, so the mutants come out in exactly the order they did before. Only the parsing is shared.

func (*GoSourceFile) Restrict added in v0.2.0

func (f *GoSourceFile) Restrict(ranges []Range) *GoSourceFile

Restrict returns the same file mutated only within the given byte ranges.

The ranges belong to the file rather than to the run, and that is the whole point. Offsets are only meaningful against the file they were measured in — every file is parsed with its own token.FileSet, so every file's positions start from the same base — and a scope held anywhere other than beside its file cannot tell them apart. Merging several files' ranges into one set makes each file answer to all of them, which mutates code no change touched and grows the work as the square of the number of files.

func (*GoSourceFile) String

func (f *GoSourceFile) String() string

type Range added in v0.2.0

type Range struct {
	Start int
	End   int
}

Range is a half-open byte range within one file.

Jump to

Keyboard shortcuts

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