ackFingerprint function

String? ackFingerprint(
  1. String ruleName,
  2. String? locale,
  3. String key,
  4. DialectProject project,
)

Compute the ack fingerprint for ruleName on key/locale from the current project state, or null if it can't be resolved (unknown rule, missing key/translation). Used both to match acks at check-time and to write a fresh ack via dialect check --ack.

Implementation

String? ackFingerprint(
  String ruleName,
  String? locale,
  String key,
  DialectProject project,
) {
  final hashesSource = _ackableHashesSource[ruleName];
  if (hashesSource == null) return null;

  if (hashesSource) {
    final entry = project.source.entryFor(key);
    if (entry == null) return null;
    return computeSourceHash(entry.value);
  } else {
    if (locale == null) return null;
    final arb = project.translations[locale];
    final entry = arb?.entryFor(key);
    if (entry == null) return null;
    return computeSourceHash(entry.value);
  }
}