parser

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGenerated

func IsGenerated(f *ast.File) bool

IsGenerated checks if a file contains the "Code generated" comment.

Types

type MutationTarget

type MutationTarget struct {
	File     string
	Line     int
	Column   int
	EndLine  int
	EndCol   int
	NodeType string    // e.g., "BinaryExpr", "UnaryExpr", "IfStmt"
	Original string    // original source text
	Node     ast.Node  // the AST node (for mutation application)
	StartPos token.Pos // start position in file
	EndPos   token.Pos // end position in file
}

MutationTarget represents a location in source code that can be mutated.

type Parser

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

Parser handles parsing Go source files and identifying mutation targets.

func New

func New(excludeGenerated, excludeVendor bool) *Parser

New creates a new Parser with the given options.

func (*Parser) Fset

func (p *Parser) Fset() *token.FileSet

Fset returns the file set used by this parser.

func (*Parser) ParseFile

func (p *Parser) ParseFile(path string) (*SourceFile, error)

ParseFile parses a single Go file and identifies mutation targets.

func (*Parser) ParsePackages

func (p *Parser) ParsePackages(pattern string) ([]*SourceFile, error)

ParsePackages parses all Go files in the given package pattern.

type SourceFile

type SourceFile struct {
	Path    string
	Package string
	Fset    *token.FileSet
	AST     *ast.File
	Content []byte // original file content for mutation
	Targets []MutationTarget
}

SourceFile represents a parsed Go source file with mutation targets.

Jump to

Keyboard shortcuts

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