shouldIgnore static method

Future<IgnoreResult> shouldIgnore(
  1. File file,
  2. String relativePath,
  3. List<String> patterns,
  4. List<String> exactFiles, {
  5. CommentStyle style = CommentStyle.cStyle,
})

Check if a file should be ignored based on all criteria

Implementation

static Future<IgnoreResult> shouldIgnore(
  File file,
  String relativePath,
  List<String> patterns,
  List<String> exactFiles, {
  CommentStyle style = CommentStyle.cStyle,
}) async {
  // First check patterns (fast, no I/O)
  final patternReason = getIgnoreReason(
    relativePath,
    null,
    patterns,
    exactFiles,
    style: style,
  );
  if (patternReason != null) {
    return IgnoreResult(true, patternReason);
  }

  // Then check file content for generated markers (requires I/O)
  try {
    final content = await file.readAsString();
    if (hasGeneratedMarker(content, style)) {
      return const IgnoreResult(true, 'Contains generated file marker');
    }
  } catch (e) {
    return IgnoreResult(true, 'Could not read file: $e');
  }

  return const IgnoreResult(false, null);
}