Check if current line is inside constructor initializer list. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line appears to be inside constructor initializer list, False otherwise.
(clean_lines, linenum)
| 4891 | |
| 4892 | |
| 4893 | def IsInitializerList(clean_lines, linenum): |
| 4894 | """Check if current line is inside constructor initializer list. |
| 4895 | |
| 4896 | Args: |
| 4897 | clean_lines: A CleansedLines instance containing the file. |
| 4898 | linenum: The number of the line to check. |
| 4899 | Returns: |
| 4900 | True if current line appears to be inside constructor initializer |
| 4901 | list, False otherwise. |
| 4902 | """ |
| 4903 | for i in range(linenum, 1, -1): |
| 4904 | line = clean_lines.elided[i] |
| 4905 | if i == linenum: |
| 4906 | remove_function_body = Match(r'^(.*)\{\s*$', line) |
| 4907 | if remove_function_body: |
| 4908 | line = remove_function_body.group(1) |
| 4909 | |
| 4910 | if Search(r'\s:\s*\w+[({]', line): |
| 4911 | # A lone colon tend to indicate the start of a constructor |
| 4912 | # initializer list. It could also be a ternary operator, which |
| 4913 | # also tend to appear in constructor initializer lists as |
| 4914 | # opposed to parameter lists. |
| 4915 | return True |
| 4916 | if Search(r'\}\s*,\s*$', line): |
| 4917 | # A closing brace followed by a comma is probably the end of a |
| 4918 | # brace-initialized member in constructor initializer list. |
| 4919 | return True |
| 4920 | if Search(r'[{};]\s*$', line): |
| 4921 | # Found one of the following: |
| 4922 | # - A closing brace or semicolon, probably the end of the previous |
| 4923 | # function. |
| 4924 | # - An opening brace, probably the start of current class or namespace. |
| 4925 | # |
| 4926 | # Current line is probably not inside an initializer list since |
| 4927 | # we saw one of those things without seeing the starting colon. |
| 4928 | return False |
| 4929 | |
| 4930 | # Got to the beginning of the file without seeing the start of |
| 4931 | # constructor initializer list. |
| 4932 | return False |
| 4933 | |
| 4934 | |
| 4935 | def CheckForNonConstReference(filename, clean_lines, linenum, |
no test coverage detected