MCPcopy Index your code
hub / github.com/nodejs/node / ReverseCloseExpression

Function ReverseCloseExpression

tools/cpplint.py:2442–2477  ·  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

2440
2441
2442def ReverseCloseExpression(clean_lines, linenum, pos):
2443 """If input points to ) or } or ] or >, finds the position that opens it.
2444
2445 If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the
2446 linenum/pos that correspond to the opening of the expression.
2447
2448 Args:
2449 clean_lines: A CleansedLines instance containing the file.
2450 linenum: The number of the line to check.
2451 pos: A position on the line.
2452
2453 Returns:
2454 A tuple (line, linenum, pos) pointer *at* the opening brace, or
2455 (line, 0, -1) if we never find the matching opening brace. Note
2456 we ignore strings and comments when matching; and the line we
2457 return is the 'cleansed' line at linenum.
2458 """
2459 line = clean_lines.elided[linenum]
2460 if line[pos] not in ")}]>":
2461 return (line, 0, -1)
2462
2463 # Check last line
2464 (start_pos, stack) = FindStartOfExpressionInLine(line, pos, [])
2465 if start_pos > -1:
2466 return (line, linenum, start_pos)
2467
2468 # Continue scanning backward
2469 while stack and linenum > 0:
2470 linenum -= 1
2471 line = clean_lines.elided[linenum]
2472 (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack)
2473 if start_pos > -1:
2474 return (line, linenum, start_pos)
2475
2476 # Did not find start of expression before beginning of file, give up
2477 return (line, 0, -1)
2478
2479
2480def CheckForCopyright(filename, lines, error):

Callers 4

CheckOperatorSpacingFunction · 0.85
IsDecltypeFunction · 0.85
CheckTrailingSemicolonFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…