MCPcopy Index your code
hub / github.com/cpplint/cpplint / ReverseCloseExpression

Function ReverseCloseExpression

cpplint.py:2397–2432  ·  view source on GitHub ↗

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. linen

(clean_lines, linenum, pos)

Source from the content-addressed store, hash-verified

2395
2396
2397def ReverseCloseExpression(clean_lines, linenum, pos):
2398 """If input points to ) or } or ] or >, finds the position that opens it.
2399
2400 If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the
2401 linenum/pos that correspond to the opening of the expression.
2402
2403 Args:
2404 clean_lines: A CleansedLines instance containing the file.
2405 linenum: The number of the line to check.
2406 pos: A position on the line.
2407
2408 Returns:
2409 A tuple (line, linenum, pos) pointer *at* the opening brace, or
2410 (line, 0, -1) if we never find the matching opening brace. Note
2411 we ignore strings and comments when matching; and the line we
2412 return is the 'cleansed' line at linenum.
2413 """
2414 line = clean_lines.elided[linenum]
2415 if line[pos] not in ")}]>":
2416 return (line, 0, -1)
2417
2418 # Check last line
2419 (start_pos, stack) = FindStartOfExpressionInLine(line, pos, [])
2420 if start_pos > -1:
2421 return (line, linenum, start_pos)
2422
2423 # Continue scanning backward
2424 while stack and linenum > 0:
2425 linenum -= 1
2426 line = clean_lines.elided[linenum]
2427 (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack)
2428 if start_pos > -1:
2429 return (line, linenum, start_pos)
2430
2431 # Did not find start of expression before beginning of file, give up
2432 return (line, 0, -1)
2433
2434
2435def CheckForCopyright(filename, lines, error):

Callers 4

CheckOperatorSpacingFunction · 0.85
IsDecltypeFunction · 0.85
CheckTrailingSemicolonFunction · 0.85

Calls 1

Tested by

no test coverage detected