MCPcopy Create free account
hub / github.com/FastLED/FastLED / _ensure_include

Function _ensure_include

ci/refactor/add_fl_noexcept.py:360–380  ·  view source on GitHub ↗

Add #include "fl/stl/noexcept.h" if not present. Returns True if added.

(lines: list[str])

Source from the content-addressed store, hash-verified

358
359
360def _ensure_include(lines: list[str]) -> bool:
361 """Add #include "fl/stl/noexcept.h" if not present. Returns True if added."""
362 content = "\n".join(lines)
363 if _NOEXCEPT_INCLUDE in content:
364 return False
365
366 last_include = -1
367 for i, line in enumerate(lines):
368 if line.strip().startswith("#include"):
369 last_include = i
370
371 if last_include >= 0:
372 lines.insert(last_include + 1, _NOEXCEPT_INCLUDE)
373 else:
374 for i, line in enumerate(lines):
375 if "#pragma once" in line:
376 lines.insert(i + 1, _NOEXCEPT_INCLUDE)
377 return True
378 lines.insert(0, _NOEXCEPT_INCLUDE)
379
380 return True
381
382
383# ============================================================================

Callers 1

_apply_fixesFunction · 0.70

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected