shouldIgnore method

bool shouldIgnore(
  1. String name,
  2. Set<String> defaultIgnored, {
  3. String? relativePath,
  4. bool isDirectory = false,
})

Checks if an entry should be ignored.

name is the basename of the entry. relativePath is the path relative to the root for path-based matching. defaultIgnored is a set of names that are always ignored. isDirectory indicates if the entry is a directory.

Implementation

bool shouldIgnore(
  String name,
  Set<String> defaultIgnored, {
  String? relativePath,
  bool isDirectory = false,
}) {
  // Negation patterns can override defaults
  if (_negations.contains(name)) {
    return false;
  }

  // Check default ignored list
  if (defaultIgnored.contains(name)) {
    return true;
  }

  // Use relativePath for path-based patterns, otherwise use name
  final pathToMatch = relativePath ?? name;

  // Check glob patterns
  for (final pattern in _patterns) {
    if (pattern.matches(pathToMatch, isDirectory: isDirectory)) {
      return true;
    }
  }

  return false;
}