Return the most recent non-blank line and its line number. Args: clean_lines: A CleansedLines instance containing the file contents. linenum: The number of the line to check. Returns: A tuple with two elements. The first element is the contents of the last non-blank line befor
(clean_lines, linenum)
| 3044 | |
| 3045 | |
| 3046 | def GetPreviousNonBlankLine(clean_lines, linenum): |
| 3047 | """Return the most recent non-blank line and its line number. |
| 3048 | |
| 3049 | Args: |
| 3050 | clean_lines: A CleansedLines instance containing the file contents. |
| 3051 | linenum: The number of the line to check. |
| 3052 | |
| 3053 | Returns: |
| 3054 | A tuple with two elements. The first element is the contents of the last |
| 3055 | non-blank line before the current line, or the empty string if this is the |
| 3056 | first non-blank line. The second is the line number of that line, or -1 |
| 3057 | if this is the first non-blank line. |
| 3058 | """ |
| 3059 | |
| 3060 | prevlinenum = linenum - 1 |
| 3061 | while prevlinenum >= 0: |
| 3062 | prevline = clean_lines.elided[prevlinenum] |
| 3063 | if not IsBlankLine(prevline): # if not a blank line... |
| 3064 | return (prevline, prevlinenum) |
| 3065 | prevlinenum -= 1 |
| 3066 | return ('', -1) |
| 3067 | |
| 3068 | |
| 3069 | def CheckBraces(filename, clean_lines, linenum, error): |
no test coverage detected