MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / ReverseCloseExpression

Function ReverseCloseExpression

src/tests/coding/cpplint.py:2195–2230  ·  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. linenum: The nu

(clean_lines, linenum, pos)

Source from the content-addressed store, hash-verified

2193
2194
2195def ReverseCloseExpression(clean_lines, linenum, pos):
2196 """If input points to ) or } or ] or >, finds the position that opens it.
2197
2198 If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the
2199 linenum/pos that correspond to the opening of the expression.
2200
2201 Args:
2202 clean_lines: A CleansedLines instance containing the file.
2203 linenum: The number of the line to check.
2204 pos: A position on the line.
2205
2206 Returns:
2207 A tuple (line, linenum, pos) pointer *at* the opening brace, or
2208 (line, 0, -1) if we never find the matching opening brace. Note
2209 we ignore strings and comments when matching; and the line we
2210 return is the 'cleansed' line at linenum.
2211 """
2212 line = clean_lines.elided[linenum]
2213 if line[pos] not in ')}]>':
2214 return (line, 0, -1)
2215
2216 # Check last line
2217 (start_pos, stack) = FindStartOfExpressionInLine(line, pos, [])
2218 if start_pos > -1:
2219 return (line, linenum, start_pos)
2220
2221 # Continue scanning backward
2222 while stack and linenum > 0:
2223 linenum -= 1
2224 line = clean_lines.elided[linenum]
2225 (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack)
2226 if start_pos > -1:
2227 return (line, linenum, start_pos)
2228
2229 # Did not find start of expression before beginning of file, give up
2230 return (line, 0, -1)
2231
2232
2233def CheckForCopyright(filename, lines, error):

Callers 4

CheckOperatorSpacingFunction · 0.85
IsDecltypeFunction · 0.85
CheckTrailingSemicolonFunction · 0.85

Calls 1

Tested by

no test coverage detected