@@ 3853-3873 (lines=21) @@ | ||
3850 | '"%s:" should be preceded by a blank line' % matched.group(1)) |
|
3851 | ||
3852 | ||
3853 | def GetPreviousNonBlankLine(clean_lines, linenum): |
|
3854 | """Return the most recent non-blank line and its line number. |
|
3855 | ||
3856 | Args: |
|
3857 | clean_lines: A CleansedLines instance containing the file contents. |
|
3858 | linenum: The number of the line to check. |
|
3859 | ||
3860 | Returns: |
|
3861 | A tuple with two elements. The first element is the contents of the last |
|
3862 | non-blank line before the current line, or the empty string if this is the |
|
3863 | first non-blank line. The second is the line number of that line, or -1 |
|
3864 | if this is the first non-blank line. |
|
3865 | """ |
|
3866 | ||
3867 | prevlinenum = linenum - 1 |
|
3868 | while prevlinenum >= 0: |
|
3869 | prevline = clean_lines.elided[prevlinenum] |
|
3870 | if not IsBlankLine(prevline): # if not a blank line... |
|
3871 | return (prevline, prevlinenum) |
|
3872 | prevlinenum -= 1 |
|
3873 | return ('', -1) |
|
3874 | ||
3875 | ||
3876 | def CheckBraces(filename, clean_lines, linenum, error): |
@@ 3853-3873 (lines=21) @@ | ||
3850 | '"%s:" should be preceded by a blank line' % matched.group(1)) |
|
3851 | ||
3852 | ||
3853 | def GetPreviousNonBlankLine(clean_lines, linenum): |
|
3854 | """Return the most recent non-blank line and its line number. |
|
3855 | ||
3856 | Args: |
|
3857 | clean_lines: A CleansedLines instance containing the file contents. |
|
3858 | linenum: The number of the line to check. |
|
3859 | ||
3860 | Returns: |
|
3861 | A tuple with two elements. The first element is the contents of the last |
|
3862 | non-blank line before the current line, or the empty string if this is the |
|
3863 | first non-blank line. The second is the line number of that line, or -1 |
|
3864 | if this is the first non-blank line. |
|
3865 | """ |
|
3866 | ||
3867 | prevlinenum = linenum - 1 |
|
3868 | while prevlinenum >= 0: |
|
3869 | prevline = clean_lines.elided[prevlinenum] |
|
3870 | if not IsBlankLine(prevline): # if not a blank line... |
|
3871 | return (prevline, prevlinenum) |
|
3872 | prevlinenum -= 1 |
|
3873 | return ('', -1) |
|
3874 | ||
3875 | ||
3876 | def CheckBraces(filename, clean_lines, linenum, error): |