Ensure ``#include "fl/stl/noexcept.h"`` is present when FL_NOEXCEPT is used.
(content: str)
| 385 | |
| 386 | |
| 387 | def _ensure_include(content: str) -> str: |
| 388 | """Ensure ``#include "fl/stl/noexcept.h"`` is present when FL_NOEXCEPT is used.""" |
| 389 | if "fl/stl/noexcept.h" in content: |
| 390 | return content |
| 391 | if "FL_NOEXCEPT" not in content: |
| 392 | return content |
| 393 | |
| 394 | lines = content.split("\n") |
| 395 | insert_idx = 0 |
| 396 | for i, ln in enumerate(lines): |
| 397 | stripped = ln.strip() |
| 398 | if stripped.startswith("#include"): |
| 399 | insert_idx = i + 1 |
| 400 | elif stripped == "#pragma once" and insert_idx == 0: |
| 401 | insert_idx = i + 1 |
| 402 | lines.insert(insert_idx, _NOEXCEPT_INCLUDE) |
| 403 | return "\n".join(lines) |
| 404 | |
| 405 | |
| 406 | def fix_file(path: Path, dry_run: bool = False) -> tuple[int, list[str]]: |