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)
| 2208 | |
| 2209 | |
| 2210 | def ReverseCloseExpression(clean_lines, linenum, pos): |
| 2211 | """If input points to ) or } or ] or >, finds the position that opens it. |
| 2212 | |
| 2213 | If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the |
| 2214 | linenum/pos that correspond to the opening of the expression. |
| 2215 | |
| 2216 | Args: |
| 2217 | clean_lines: A CleansedLines instance containing the file. |
| 2218 | linenum: The number of the line to check. |
| 2219 | pos: A position on the line. |
| 2220 | |
| 2221 | Returns: |
| 2222 | A tuple (line, linenum, pos) pointer *at* the opening brace, or |
| 2223 | (line, 0, -1) if we never find the matching opening brace. Note |
| 2224 | we ignore strings and comments when matching; and the line we |
| 2225 | return is the 'cleansed' line at linenum. |
| 2226 | """ |
| 2227 | line = clean_lines.elided[linenum] |
| 2228 | if line[pos] not in ')}]>': |
| 2229 | return (line, 0, -1) |
| 2230 | |
| 2231 | # Check last line |
| 2232 | (start_pos, stack) = FindStartOfExpressionInLine(line, pos, []) |
| 2233 | if start_pos > -1: |
| 2234 | return (line, linenum, start_pos) |
| 2235 | |
| 2236 | # Continue scanning backward |
| 2237 | while stack and linenum > 0: |
| 2238 | linenum -= 1 |
| 2239 | line = clean_lines.elided[linenum] |
| 2240 | (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack) |
| 2241 | if start_pos > -1: |
| 2242 | return (line, linenum, start_pos) |
| 2243 | |
| 2244 | # Did not find start of expression before beginning of file, give up |
| 2245 | return (line, 0, -1) |
| 2246 | |
| 2247 | |
| 2248 | def CheckForCopyright(filename, lines, error): |
no test coverage detected