MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / _inject_or_diag

Function _inject_or_diag

Scripts/codegen/generate_ue_components.py:233–258  ·  view source on GitHub ↗

Inject ``body`` between the ``CODEGEN_ `` markers in ``text``. When the markers are missing AND the body is non-empty, fire a diagnostic that names the host kind (e.g. 'subclass header'), the path, the tag, and what didn't land. Returns (new_text, ok). This collapses ~12 near-id

(
    text: str,
    tag: str,
    body: str,
    *,
    host_path: str,
    host_kind: str,
    block_label: str,
    diag_source: str,
)

Source from the content-addressed store, hash-verified

231
232
233def _inject_or_diag(
234 text: str,
235 tag: str,
236 body: str,
237 *,
238 host_path: str,
239 host_kind: str,
240 block_label: str,
241 diag_source: str,
242) -> Tuple[str, bool]:
243 """Inject ``body`` between the ``CODEGEN_<tag>`` markers in ``text``.
244 When the markers are missing AND the body is non-empty, fire a
245 diagnostic that names the host kind (e.g. 'subclass header'), the
246 path, the tag, and what didn&#x27;t land. Returns (new_text, ok).
247
248 This collapses ~12 near-identical try-inject-then-diag stanzas
249 that used to live in the emit_*_class_injection callers."""
250 new_text, ok = inject_between_tags(text, tag, body, balance_source=diag_source)
251 if not ok and body.strip():
252 _diag_add(
253 f"[diagnostic] {host_kind} '{host_path}' is missing the "
254 f"CODEGEN_{tag}_START/END marker pair; {block_label} was "
255 f"NOT injected.",
256 source=diag_source,
257 )
258 return new_text, ok
259
260
261def _guarded_export(toggle: str, body: str,

Callers 4

emit_subclass_filesFunction · 0.85
emit_multi_uclassFunction · 0.85
emit_bind_h_injectionFunction · 0.85

Calls 2

inject_between_tagsFunction · 0.90
_diag_addFunction · 0.90

Tested by

no test coverage detected