|
17 | 17 | _SWIFT_FUNC_RE = re.compile(r"^\s*(?:\w+\s+|@\w+\s+)*func\s+(\w+)\s*[(]", re.MULTILINE) |
18 | 18 | _SWIFT_TYPEALIAS_RE = re.compile(r"^\s*(?:public\s+|private\s+|internal\s+|fileprivate\s+)*typealias\s+(\w+)", re.MULTILINE) |
19 | 19 |
|
20 | | -_SWIFT_CONFORMANCE_RE = re.compile(r"(?:class|struct|enum)\s+\w+\s*(?:<[^>]+>)?\s*:\s*([^{\n]{1,500})", re.MULTILINE) |
21 | | -_SWIFT_TYPE_REF_RE = re.compile(r"(?<![a-z_])([A-Z]\w*)\b") |
22 | | -_SWIFT_FUNC_CALL_RE = re.compile(r"(?<!\w)([a-z]\w*)\s*\(") |
| 20 | +_SWIFT_CONFORMANCE_RE = re.compile( |
| 21 | + r"(?:class|struct|enum)\s{1,10}\w{1,100}\s{0,10}(?:<[^>]{1,200}>)?\s{0,10}:\s{0,10}([^{\n]{1,500})", re.MULTILINE |
| 22 | +) |
| 23 | +_SWIFT_TYPE_REF_RE = re.compile(r"(?<![a-z_])([A-Z]\w{0,100})\b") |
| 24 | +_SWIFT_FUNC_CALL_RE = re.compile(r"(?<!\w)([a-z]\w{0,100})\s{0,10}\(") |
23 | 25 | _SWIFT_DOT_CALL_RE = re.compile(r"(\w+)\.([a-z][a-zA-Z0-9]*)\s*\(") |
24 | 26 |
|
25 | 27 |
|
@@ -51,8 +53,8 @@ def _extract_conformances(content: str) -> set[str]: |
51 | 53 | inheritance = match.group(1) |
52 | 54 | for part in inheritance.split(","): |
53 | 55 | part = part.strip() |
54 | | - part = re.sub(r"<[^>]+>", "", part) |
55 | | - part = re.sub(r"\s+where\s+[^\n]*", "", part) |
| 56 | + part = re.sub(r"<[^>]{1,200}>", "", part) |
| 57 | + part = re.sub(r"\s{1,20}where\s{1,20}[^\n]{0,300}", "", part) |
56 | 58 | if part and part[0].isupper(): |
57 | 59 | conformances.add(part.strip()) |
58 | 60 | return conformances |
|
0 commit comments