matcher

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

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

Matcher handles pattern matching for files and content based on configuration rules. It caches compiled regular expressions for performance and supports multiple matching strategies.

func NewMatcher

func NewMatcher(cfg *config.Config) *Matcher

NewMatcher creates a new matcher with the given configuration. The matcher will use the provided config to determine matching rules and strategies.

func (*Matcher) GetMatchedGuides

func (m *Matcher) GetMatchedGuides(
	patterns []config.Pattern, isDiff bool,
) []string

GetMatchedGuides returns the appropriate guide files for the given matched patterns. Uses diff_context guides if isDiff is true, otherwise uses regular context guides.

func (*Matcher) MatchFile

func (m *Matcher) MatchFile(filename string) ([]config.Pattern, error)

MatchFile determines which patterns match a given filename. Only evaluates filename-based patterns, not content patterns.

func (*Matcher) MatchFileContent

func (m *Matcher) MatchFileContent(
	filename string, content []byte,
) ([]config.Pattern, error)

MatchFileContent determines which patterns match based on both filename and file content. Evaluates all patterns and applies the appropriate content scanning strategy for each.

func (*Matcher) ScanFile

func (m *Matcher) ScanFile(filename string) ([]config.Pattern, error)

ScanFile reads a file from disk and returns which patterns match. Convenience method that combines file reading with pattern matching.

func (*Matcher) ScanFileLines

func (m *Matcher) ScanFileLines(
	filename string, maxLines int,
) ([]config.Pattern, error)

ScanFileLines reads a file line by line up to maxLines for memory efficiency. Useful for large files where full content scanning would be expensive.

Jump to

Keyboard shortcuts

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