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

Function _ensure_include

ci/lint/clang_tidy/noexcept_platforms.py:227–252  ·  view source on GitHub ↗

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

(lines: list[str])

Source from the content-addressed store, hash-verified

225
226
227def _ensure_include(lines: list[str]) -> bool:
228 """Add #include "fl/stl/noexcept.h" if not already present.
229
230 Returns True if added.
231 """
232 content = "\n".join(lines)
233 if _NOEXCEPT_INCLUDE in content:
234 return False
235
236 # Insert after the last existing #include
237 last_idx = -1
238 for i, line in enumerate(lines):
239 if line.strip().startswith("#include"):
240 last_idx = i
241
242 if last_idx >= 0:
243 lines.insert(last_idx + 1, _NOEXCEPT_INCLUDE)
244 else:
245 # Fallback: after #pragma once
246 for i, line in enumerate(lines):
247 if "#pragma once" in line:
248 lines.insert(i + 1, _NOEXCEPT_INCLUDE)
249 return True
250 lines.insert(0, _NOEXCEPT_INCLUDE)
251
252 return True
253
254
255# ============================================================================

Callers 1

_apply_fixesFunction · 0.70

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected