pub struct IgnorePatternSet { /* private fields */ }Expand description
The discovery ignore set with its ! exceptions.
matches_into and len read only the ignore globs, in the index layout
that crate::DEFAULT_IGNORE_PATTERNS documents. is_match applies the
exceptions too, so every caller that asks “is this path ignored” gets the
same answer.
Implementations§
Source§impl IgnorePatternSet
impl IgnorePatternSet
Sourcepub fn new(patterns: GlobSet, exception_bodies: &[&str]) -> Self
pub fn new(patterns: GlobSet, exception_bodies: &[&str]) -> Self
Build a set from ignore globs and ! exception bodies (without the
!). Exception bodies that do not compile are dropped, because config
load validates them first.
Sourcepub fn with_user_patterns(self, patterns: Vec<String>) -> Self
pub fn with_user_patterns(self, patterns: Vec<String>) -> Self
Name the project’s own globs, which are the first patterns.len()
globs of the set, as written in ignorePatterns.
Sourcepub fn user_pattern_count(&self) -> usize
pub fn user_pattern_count(&self) -> usize
Number of the project’s own globs at the front of the set.
Sourcepub fn credit_user_matches(&self, indices: &[usize])
pub fn credit_user_matches(&self, indices: &[usize])
Credit the project’s own globs among indices (from
Self::excluded_matches_into for one excluded path), unless a
built-in glob is among them too: the built-in excludes the path anyway.
Sourcepub fn excludes(&self, path: impl AsRef<Path>) -> bool
pub fn excludes(&self, path: impl AsRef<Path>) -> bool
Self::is_match, and when the path is ignored, credit the
project’s own globs that match it, as Self::credit_user_matches
does.
Sourcepub fn mark_walked(&self)
pub fn mark_walked(&self)
Record that source discovery ran with this set.
Sourcepub fn redundant_user_patterns(&self) -> Vec<&str>
pub fn redundant_user_patterns(&self) -> Vec<&str>
The project’s own globs that excluded no path that the run would otherwise keep, in config order. Empty until source discovery ran.
A glob that names a hidden directory (.cache/**) is never in the
list. The walk does not open most hidden directories, so it cannot
credit such a glob, but the glob still silences the
skipped-source-dotdir advisory for that directory.
Sourcepub fn is_match(&self, path: impl AsRef<Path>) -> bool
pub fn is_match(&self, path: impl AsRef<Path>) -> bool
True when the path is ignored: an ignore glob matches it and no !
exception lifts it.
Sourcepub fn excluded_matches_into(
&self,
path: impl AsRef<Path>,
into: &mut Vec<usize>,
)
pub fn excluded_matches_into( &self, path: impl AsRef<Path>, into: &mut Vec<usize>, )
Indices of the ignore globs that match the path, without the
exceptions. Callers use it only for a path that is_match rejected,
so it also credits the project’s own globs among the indices.
Sourcepub fn matches(&self, path: impl AsRef<Path>) -> Vec<usize>
pub fn matches(&self, path: impl AsRef<Path>) -> Vec<usize>
Indices of the ignore globs that match the path, without the exceptions.
Sourcepub fn has_exceptions(&self) -> bool
pub fn has_exceptions(&self) -> bool
True when the project wrote at least one ! exception.
Sourcepub fn is_lifted(&self, path: impl AsRef<Path>) -> bool
pub fn is_lifted(&self, path: impl AsRef<Path>) -> bool
True when a ! exception matches the path and the path is not under
node_modules or .git.
True when the walk must open the hidden directory dir (a path
relative to the project root) because a ! exception can match a file
inside it. The walk keeps only the files that an exception matches.