Check if current position is inside template argument list. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. pos: position just after the suspected template argument. Returns: True if (
(self, clean_lines, linenum, pos)
| 3356 | return len(self.stack) > 0 and not isinstance(self.stack[-1], _NamespaceInfo) |
| 3357 | |
| 3358 | def InTemplateArgumentList(self, clean_lines, linenum, pos): |
| 3359 | """Check if current position is inside template argument list. |
| 3360 | |
| 3361 | Args: |
| 3362 | clean_lines: A CleansedLines instance containing the file. |
| 3363 | linenum: The number of the line to check. |
| 3364 | pos: position just after the suspected template argument. |
| 3365 | Returns: |
| 3366 | True if (linenum, pos) is inside template arguments. |
| 3367 | """ |
| 3368 | while linenum < clean_lines.NumLines(): |
| 3369 | # Find the earliest character that might indicate a template argument |
| 3370 | line = clean_lines.elided[linenum] |
| 3371 | match = re.match(r"^[^{};=\[\]\.<>]*(.)", line[pos:]) |
| 3372 | if not match: |
| 3373 | linenum += 1 |
| 3374 | pos = 0 |
| 3375 | continue |
| 3376 | token = match.group(1) |
| 3377 | pos += len(match.group(0)) |
| 3378 | |
| 3379 | # These things do not look like template argument list: |
| 3380 | # class Suspect { |
| 3381 | # class Suspect x; } |
| 3382 | if token in ("{", "}", ";"): |
| 3383 | return False |
| 3384 | |
| 3385 | # These things look like template argument list: |
| 3386 | # template <class Suspect> |
| 3387 | # template <class Suspect = default_value> |
| 3388 | # template <class Suspect[]> |
| 3389 | # template <class Suspect...> |
| 3390 | if token in (">", "=", "[", "]", "."): |
| 3391 | return True |
| 3392 | |
| 3393 | # Check if token is an unmatched '<'. |
| 3394 | # If not, move on to the next character. |
| 3395 | if token != "<": |
| 3396 | pos += 1 |
| 3397 | if pos >= len(line): |
| 3398 | linenum += 1 |
| 3399 | pos = 0 |
| 3400 | continue |
| 3401 | |
| 3402 | # We can't be sure if we just find a single '<', and need to |
| 3403 | # find the matching '>'. |
| 3404 | (_, end_line, end_pos) = CloseExpression(clean_lines, linenum, pos - 1) |
| 3405 | if end_pos < 0: |
| 3406 | # Not sure if template argument list or syntax error in file |
| 3407 | return False |
| 3408 | linenum = end_line |
| 3409 | pos = end_pos |
| 3410 | return False |
| 3411 | |
| 3412 | def UpdatePreprocessor(self, line): |
| 3413 | """Update preprocessor stack. |
no test coverage detected