INNER CODE UNIT · Python

_apply_indent

Cooler2/ApusGameEngine · tools/normalize_indent.py:211

def _apply_indent(line, old_n, new_n, flag_above):
    """Return (new_line, flagged)."""
    stripped = line.lstrip(' ')
    flagged  = (old_n > flag_above)
    return ' ' * new_n + stripped, flagged


def transform_file(lines, flag_above):
    """
    Returns (new_lines, changed_count, flagged_lines).
    flagged_lines: list of (line_no, old_indent, line_content)

    Two corrections on top of plain 2x:
      1. Nested proc bodies: subtract accumulated reduction before multiplying.
      2. `uses` continuations: pin to the indent of the `uses` keyword.
    """
    reductions    = _compute_reductions(lines)
    new_lines     = []

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…