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)
| 5219 | |
| 5220 | |
| 5221 | def IsInitializerList(clean_lines, linenum): |
| 5222 | """Check if current line is inside constructor initializer list. |
| 5223 | |
| 5224 | Args: |
| 5225 | clean_lines: A CleansedLines instance containing the file. |
| 5226 | linenum: The number of the line to check. |
| 5227 | Returns: |
| 5228 | True if current line appears to be inside constructor initializer |
| 5229 | list, False otherwise. |
| 5230 | """ |
| 5231 | for i in xrange(linenum, 1, -1): |
| 5232 | line = clean_lines.elided[i] |
| 5233 | if i == linenum: |
| 5234 | remove_function_body = Match(r'^(.*)\{\s*$', line) |
| 5235 | if remove_function_body: |
| 5236 | line = remove_function_body.group(1) |
| 5237 | |
| 5238 | if Search(r'\s:\s*\w+[({]', line): |
| 5239 | # A lone colon tend to indicate the start of a constructor |
| 5240 | # initializer list. It could also be a ternary operator, which |
| 5241 | # also tend to appear in constructor initializer lists as |
| 5242 | # opposed to parameter lists. |
| 5243 | return True |
| 5244 | if Search(r'\}\s*,\s*$', line): |
| 5245 | # A closing brace followed by a comma is probably the end of a |
| 5246 | # brace-initialized member in constructor initializer list. |
| 5247 | return True |
| 5248 | if Search(r'[{};]\s*$', line): |
| 5249 | # Found one of the following: |
| 5250 | # - A closing brace or semicolon, probably the end of the previous |
| 5251 | # function. |
| 5252 | # - An opening brace, probably the start of current class or namespace. |
| 5253 | # |
| 5254 | # Current line is probably not inside an initializer list since |
| 5255 | # we saw one of those things without seeing the starting colon. |
| 5256 | return False |
| 5257 | |
| 5258 | # Got to the beginning of the file without seeing the start of |
| 5259 | # constructor initializer list. |
| 5260 | return False |
| 5261 | |
| 5262 | |
| 5263 | def CheckForNonConstReference(filename, clean_lines, linenum, |
no test coverage detected