Skip to main content

Module matcher

Module matcher 

Source
Expand description

Path exclusion matching with mixed glob + prefix semantics.

This module provides two reusable helpers used by the rest of the workspace:

  • [build_glob_set] compiles a list of glob-pattern strings into a globset::GlobSet using the project’s GlobSettings. The file loader (crate::loader) uses this for source.excludes entries that are pure glob patterns.
  • ExclusionMatcher layers on top of build_glob_set, splitting an input list into glob patterns and plain prefixes.

§Pattern semantics used by ExclusionMatcher

Each pattern in the input list is classified as either a glob pattern or a plain prefix based on whether it contains any glob metacharacters (*, ?, [, {):

  • Glob patterns (e.g. src/**/*.php, tests/fixtures/*) are compiled via the globset crate using the supplied GlobSettings and matched against the full file path.
  • Plain prefixes (e.g. src, tests/fixtures/) use the pre-existing directory-prefix semantics: a pattern X matches X, X/anything, or (if the pattern already ends with /) any path starting with X/.

This split keeps existing exclude = ["src/foo"] configurations working exactly as before while adding full glob support for anyone who needs it.

Structs§

ExclusionMatcher
Compiled matcher for a list of exclusion patterns.

Functions§

contains_glob_metacharacters
Returns true if the string contains any character that would make it a glob pattern rather than a literal path.