MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / IsInitializerList

Function IsInitializerList

steps/cpplint.py:5525–5564  ·  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

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

Callers 1

Calls 2

MatchFunction · 0.85
SearchFunction · 0.85

Tested by

no test coverage detected