If input points to ) or } or ] or >, finds the position that opens it. If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the linenum/pos that correspond to the opening of the expression. Args: clean_lines: A CleansedLines instance containing the file. linenum: The nu
(clean_lines, linenum, pos)
| 1721 | |
| 1722 | |
| 1723 | def ReverseCloseExpression(clean_lines, linenum, pos): |
| 1724 | """If input points to ) or } or ] or >, finds the position that opens it. |
| 1725 | |
| 1726 | If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the |
| 1727 | linenum/pos that correspond to the opening of the expression. |
| 1728 | |
| 1729 | Args: |
| 1730 | clean_lines: A CleansedLines instance containing the file. |
| 1731 | linenum: The number of the line to check. |
| 1732 | pos: A position on the line. |
| 1733 | |
| 1734 | Returns: |
| 1735 | A tuple (line, linenum, pos) pointer *at* the opening brace, or |
| 1736 | (line, 0, -1) if we never find the matching opening brace. Note |
| 1737 | we ignore strings and comments when matching; and the line we |
| 1738 | return is the 'cleansed' line at linenum. |
| 1739 | """ |
| 1740 | line = clean_lines.elided[linenum] |
| 1741 | if line[pos] not in ')}]>': |
| 1742 | return (line, 0, -1) |
| 1743 | |
| 1744 | # Check last line |
| 1745 | (start_pos, stack) = FindStartOfExpressionInLine(line, pos, []) |
| 1746 | if start_pos > -1: |
| 1747 | return (line, linenum, start_pos) |
| 1748 | |
| 1749 | # Continue scanning backward |
| 1750 | while stack and linenum > 0: |
| 1751 | linenum -= 1 |
| 1752 | line = clean_lines.elided[linenum] |
| 1753 | (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack) |
| 1754 | if start_pos > -1: |
| 1755 | return (line, linenum, start_pos) |
| 1756 | |
| 1757 | # Did not find start of expression before beginning of file, give up |
| 1758 | return (line, 0, -1) |
| 1759 | |
| 1760 | |
| 1761 | def CheckForCopyright(filename, lines, error): |
no test coverage detected