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

Function ReverseCloseExpression

analytical_engine/misc/cpplint.py:2199–2234  ·  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

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

Callers 4

CheckOperatorSpacingFunction · 0.85
IsDecltypeFunction · 0.85
CheckTrailingSemicolonFunction · 0.85

Calls 1

Tested by

no test coverage detected