Check if the given line is a constructor. Args: line: Line to check. class_name: If line checked is inside of a class block, a str of the class's name; otherwise, None.
(self, line: str, linenum: int, class_name: str | None = None)
| 3454 | return line |
| 3455 | |
| 3456 | def _UpdateConstructor(self, line: str, linenum: int, class_name: str | None = None): |
| 3457 | """ |
| 3458 | Check if the given line is a constructor. |
| 3459 | Args: |
| 3460 | line: Line to check. |
| 3461 | class_name: If line checked is inside of a class block, a str of the class's name; |
| 3462 | otherwise, None. |
| 3463 | """ |
| 3464 | if not class_name: |
| 3465 | if not re.match(r"\s*(\w*)\s*::\s*\1\s*\(", line): |
| 3466 | return |
| 3467 | elif not re.match(rf"\s*{re.escape(class_name)}\s*\(", line): |
| 3468 | return |
| 3469 | |
| 3470 | self.stack.append(_ConstructorInfo(linenum)) |
| 3471 | |
| 3472 | # TODO(google): Update() is too long, but we will refactor later. |
| 3473 | def Update(self, filename: str, clean_lines: CleansedLines, linenum: int, error): |