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

Function ensure_include

ci/tools/add_fl_noexcept.py:210–232  ·  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

208
209
210def ensure_include(lines: list[str]) -> bool:
211 """Add #include "fl/stl/noexcept.h" if not present. Returns True if added."""
212 content = "\n".join(lines)
213 if NOEXCEPT_INCLUDE in content:
214 return False
215
216 # Find last #include line
217 last_idx = -1
218 for i, line in enumerate(lines):
219 if line.strip().startswith("#include"):
220 last_idx = i
221
222 if last_idx >= 0:
223 lines.insert(last_idx + 1, NOEXCEPT_INCLUDE)
224 else:
225 # After #pragma once
226 for i, line in enumerate(lines):
227 if "#pragma once" in line:
228 lines.insert(i + 1, NOEXCEPT_INCLUDE)
229 return True
230 lines.insert(0, NOEXCEPT_INCLUDE)
231
232 return True
233
234
235# ============================================================================

Callers 1

mainFunction · 0.85

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected