Split into (iface_text, iface_offset, impl_text, impl_offset). Files without interface/implementation sections (dpr/lpr/inc) return the whole text as impl with offset 0.
(text: str)
| 13123 | |
| 13124 | |
| 13125 | def _pascal_split_sections(text: str) -> tuple[str, int, str, int]: |
| 13126 | """Split into (iface_text, iface_offset, impl_text, impl_offset). |
| 13127 | Files without interface/implementation sections (dpr/lpr/inc) return |
| 13128 | the whole text as impl with offset 0. |
| 13129 | """ |
| 13130 | iface_m = re.search(r"\binterface\b", text, re.IGNORECASE) |
| 13131 | impl_m = re.search(r"\bimplementation\b", text, re.IGNORECASE) |
| 13132 | if iface_m and impl_m: |
| 13133 | iface_off = iface_m.end() |
| 13134 | impl_off = impl_m.end() |
| 13135 | end_m = re.search( |
| 13136 | r"\b(initialization|finalization)\b", text[impl_off:], re.IGNORECASE |
| 13137 | ) |
| 13138 | impl_end = impl_off + end_m.start() if end_m else len(text) |
| 13139 | return text[iface_off:impl_m.start()], iface_off, text[impl_off:impl_end], impl_off |
| 13140 | return "", 0, text, 0 |
| 13141 | |
| 13142 | |
| 13143 | def _pascal_split_uses(s: str) -> list[str]: |
no test coverage detected