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

Function IsInitializerList

tools/cpplint.py:6414–6453  ·  view source on GitHub ↗

Check if current line is inside constructor initializer list. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line appears to be inside constructor initializer list, False otherwise.

(clean_lines, linenum)

Source from the content-addressed store, hash-verified

6412
6413
6414def IsInitializerList(clean_lines, linenum):
6415 """Check if current line is inside constructor initializer list.
6416
6417 Args:
6418 clean_lines: A CleansedLines instance containing the file.
6419 linenum: The number of the line to check.
6420 Returns:
6421 True if current line appears to be inside constructor initializer
6422 list, False otherwise.
6423 """
6424 for i in range(linenum, 1, -1):
6425 line = clean_lines.elided[i]
6426 if i == linenum:
6427 remove_function_body = re.match(r"^(.*)\{\s*$", line)
6428 if remove_function_body:
6429 line = remove_function_body.group(1)
6430
6431 if re.search(r"\s:\s*\w+[({]", line):
6432 # A lone colon tend to indicate the start of a constructor
6433 # initializer list. It could also be a ternary operator, which
6434 # also tend to appear in constructor initializer lists as
6435 # opposed to parameter lists.
6436 return True
6437 if re.search(r"\}\s*,\s*$", line):
6438 # A closing brace followed by a comma is probably the end of a
6439 # brace-initialized member in constructor initializer list.
6440 return True
6441 if re.search(r"[{};]\s*$", line):
6442 # Found one of the following:
6443 # - A closing brace or semicolon, probably the end of the previous
6444 # function.
6445 # - An opening brace, probably the start of current class or namespace.
6446 #
6447 # Current line is probably not inside an initializer list since
6448 # we saw one of those things without seeing the starting colon.
6449 return False
6450
6451 # Got to the beginning of the file without seeing the start of
6452 # constructor initializer list.
6453 return False
6454
6455
6456def CheckForNonConstReference(filename, clean_lines, linenum, nesting_state, error):

Callers 1

Calls 3

matchMethod · 0.65
rangeFunction · 0.50
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…