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

Function IsInitializerList

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

5513
5514
5515def IsInitializerList(clean_lines, linenum):
5516 """Check if current line is inside constructor initializer list.
5517
5518 Args:
5519 clean_lines: A CleansedLines instance containing the file.
5520 linenum: The number of the line to check.
5521 Returns:
5522 True if current line appears to be inside constructor initializer
5523 list, False otherwise.
5524 """
5525 for i in xrange(linenum, 1, -1):
5526 line = clean_lines.elided[i]
5527 if i == linenum:
5528 remove_function_body = Match(r'^(.*)\{\s*$', line)
5529 if remove_function_body:
5530 line = remove_function_body.group(1)
5531
5532 if Search(r'\s:\s*\w+[({]', line):
5533 # A lone colon tend to indicate the start of a constructor
5534 # initializer list. It could also be a ternary operator, which
5535 # also tend to appear in constructor initializer lists as
5536 # opposed to parameter lists.
5537 return True
5538 if Search(r'\}\s*,\s*$', line):
5539 # A closing brace followed by a comma is probably the end of a
5540 # brace-initialized member in constructor initializer list.
5541 return True
5542 if Search(r'[{};]\s*$', line):
5543 # Found one of the following:
5544 # - A closing brace or semicolon, probably the end of the previous
5545 # function.
5546 # - An opening brace, probably the start of current class or namespace.
5547 #
5548 # Current line is probably not inside an initializer list since
5549 # we saw one of those things without seeing the starting colon.
5550 return False
5551
5552 # Got to the beginning of the file without seeing the start of
5553 # constructor initializer list.
5554 return False
5555
5556
5557def CheckForNonConstReference(filename, clean_lines, linenum,

Callers 1

Calls 3

SearchFunction · 0.85
MatchFunction · 0.70
groupMethod · 0.45

Tested by

no test coverage detected