MCPcopy Create free account
hub / github.com/alibaba/GraphScope / GetPreviousNonBlankLine

Function GetPreviousNonBlankLine

analytical_engine/misc/cpplint.py:4212–4232  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

4210
4211
4212def GetPreviousNonBlankLine(clean_lines, linenum):
4213 """Return the most recent non-blank line and its line number.
4214
4215 Args:
4216 clean_lines: A CleansedLines instance containing the file contents.
4217 linenum: The number of the line to check.
4218
4219 Returns:
4220 A tuple with two elements. The first element is the contents of the last
4221 non-blank line before the current line, or the empty string if this is the
4222 first non-blank line. The second is the line number of that line, or -1
4223 if this is the first non-blank line.
4224 """
4225
4226 prevlinenum = linenum - 1
4227 while prevlinenum >= 0:
4228 prevline = clean_lines.elided[prevlinenum]
4229 if not IsBlankLine(prevline): # if not a blank line...
4230 return (prevline, prevlinenum)
4231 prevlinenum -= 1
4232 return ('', -1)
4233
4234
4235def CheckBraces(filename, clean_lines, linenum, error):

Callers 3

CheckBracesFunction · 0.85
CheckTrailingSemicolonFunction · 0.85
CheckStyleFunction · 0.85

Calls 1

IsBlankLineFunction · 0.85

Tested by

no test coverage detected