Split inheritance list, handling generics like TList .
(s: str)
| 13152 | |
| 13153 | |
| 13154 | def _pascal_split_bases(s: str) -> list[str]: |
| 13155 | """Split inheritance list, handling generics like TList<T, U>.""" |
| 13156 | out, depth, buf = [], 0, [] |
| 13157 | for ch in s: |
| 13158 | if ch == "<": |
| 13159 | depth += 1 |
| 13160 | buf.append(ch) |
| 13161 | elif ch == ">": |
| 13162 | depth -= 1 |
| 13163 | buf.append(ch) |
| 13164 | elif ch == "," and depth == 0: |
| 13165 | name = re.sub(r"<.*$", "", "".join(buf).strip()) |
| 13166 | if name: |
| 13167 | out.append(name) |
| 13168 | buf = [] |
| 13169 | else: |
| 13170 | buf.append(ch) |
| 13171 | name = re.sub(r"<.*$", "", "".join(buf).strip()) |
| 13172 | if name: |
| 13173 | out.append(name) |
| 13174 | return [n for n in out if re.match(r"[A-Za-z_]\w*$", n)] |
| 13175 | |
| 13176 | |
| 13177 | def _pascal_find_body(text: str, start: int) -> tuple[int, int]: |
no outgoing calls
no test coverage detected