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)
| 4969 | |
| 4970 | |
| 4971 | def IsInitializerList(clean_lines, linenum): |
| 4972 | """Check if current line is inside constructor initializer list. |
| 4973 | |
| 4974 | Args: |
| 4975 | clean_lines: A CleansedLines instance containing the file. |
| 4976 | linenum: The number of the line to check. |
| 4977 | Returns: |
| 4978 | True if current line appears to be inside constructor initializer |
| 4979 | list, False otherwise. |
| 4980 | """ |
| 4981 | for i in xrange(linenum, 1, -1): |
| 4982 | line = clean_lines.elided[i] |
| 4983 | if i == linenum: |
| 4984 | remove_function_body = Match(r'^(.*)\{\s*$', line) |
| 4985 | if remove_function_body: |
| 4986 | line = remove_function_body.group(1) |
| 4987 | |
| 4988 | if Search(r'\s:\s*\w+[({]', line): |
| 4989 | # A lone colon tend to indicate the start of a constructor |
| 4990 | # initializer list. It could also be a ternary operator, which |
| 4991 | # also tend to appear in constructor initializer lists as |
| 4992 | # opposed to parameter lists. |
| 4993 | return True |
| 4994 | if Search(r'\}\s*,\s*$', line): |
| 4995 | # A closing brace followed by a comma is probably the end of a |
| 4996 | # brace-initialized member in constructor initializer list. |
| 4997 | return True |
| 4998 | if Search(r'[{};]\s*$', line): |
| 4999 | # Found one of the following: |
| 5000 | # - A closing brace or semicolon, probably the end of the previous |
| 5001 | # function. |
| 5002 | # - An opening brace, probably the start of current class or namespace. |
| 5003 | # |
| 5004 | # Current line is probably not inside an initializer list since |
| 5005 | # we saw one of those things without seeing the starting colon. |
| 5006 | return False |
| 5007 | |
| 5008 | # Got to the beginning of the file without seeing the start of |
| 5009 | # constructor initializer list. |
| 5010 | return False |
| 5011 | |
| 5012 | |
| 5013 | def CheckForNonConstReference(filename, clean_lines, linenum, |
no test coverage detected
searching dependent graphs…