widthBudgetFor function

WidthBudgetInfo? widthBudgetFor(
  1. ArbEntry src,
  2. DialectProject project
)

Resolve the width budget for src under project, or null if the key declares none. Shared so dialect translate can show the agent the exact budget the check enforces, with no duplicated resolution logic.

Implementation

WidthBudgetInfo? widthBudgetFor(ArbEntry src, DialectProject project) {
  final slots = WidthBudgetRule._parseSlots(project);
  final b = WidthBudgetRule._resolveBudget(src, slots);
  if (b == null) return null;
  final srcLen = WidthBudgetRule._len(src.value);
  if (srcLen == 0) return null;
  return WidthBudgetInfo(
    maxChars: b.maxChars(srcLen),
    sourceChars: srcLen,
    label: b.label,
  );
}