Code Duplication    Length = 42-42 lines in 2 locations

core/build-support/cpplint.py 1 location

@@ 1767-1808 (lines=42) @@
1764
  return (-1, stack)
1765
1766
1767
def CloseExpression(clean_lines, linenum, pos):
1768
  """If input points to ( or { or [ or <, finds the position that closes it.
1769
1770
  If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the
1771
  linenum/pos that correspond to the closing of the expression.
1772
1773
  TODO(unknown): cpplint spends a fair bit of time matching parentheses.
1774
  Ideally we would want to index all opening and closing parentheses once
1775
  and have CloseExpression be just a simple lookup, but due to preprocessor
1776
  tricks, this is not so easy.
1777
1778
  Args:
1779
    clean_lines: A CleansedLines instance containing the file.
1780
    linenum: The number of the line to check.
1781
    pos: A position on the line.
1782
1783
  Returns:
1784
    A tuple (line, linenum, pos) pointer *past* the closing brace, or
1785
    (line, len(lines), -1) if we never find a close.  Note we ignore
1786
    strings and comments when matching; and the line we return is the
1787
    'cleansed' line at linenum.
1788
  """
1789
1790
  line = clean_lines.elided[linenum]
1791
  if (line[pos] not in '({[<') or Match(r'<[<=]', line[pos:]):
1792
    return (line, clean_lines.NumLines(), -1)
1793
1794
  # Check first line
1795
  (end_pos, stack) = FindEndOfExpressionInLine(line, pos, [])
1796
  if end_pos > -1:
1797
    return (line, linenum, end_pos)
1798
1799
  # Continue scanning forward
1800
  while stack and linenum < clean_lines.NumLines() - 1:
1801
    linenum += 1
1802
    line = clean_lines.elided[linenum]
1803
    (end_pos, stack) = FindEndOfExpressionInLine(line, 0, stack)
1804
    if end_pos > -1:
1805
      return (line, linenum, end_pos)
1806
1807
  # Did not find end of expression before end of file, give up
1808
  return (line, clean_lines.NumLines(), -1)
1809
1810
1811
def FindStartOfExpressionInLine(line, endpos, stack):

sdk/build-support/cpplint.py 1 location

@@ 1767-1808 (lines=42) @@
1764
  return (-1, stack)
1765
1766
1767
def CloseExpression(clean_lines, linenum, pos):
1768
  """If input points to ( or { or [ or <, finds the position that closes it.
1769
1770
  If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the
1771
  linenum/pos that correspond to the closing of the expression.
1772
1773
  TODO(unknown): cpplint spends a fair bit of time matching parentheses.
1774
  Ideally we would want to index all opening and closing parentheses once
1775
  and have CloseExpression be just a simple lookup, but due to preprocessor
1776
  tricks, this is not so easy.
1777
1778
  Args:
1779
    clean_lines: A CleansedLines instance containing the file.
1780
    linenum: The number of the line to check.
1781
    pos: A position on the line.
1782
1783
  Returns:
1784
    A tuple (line, linenum, pos) pointer *past* the closing brace, or
1785
    (line, len(lines), -1) if we never find a close.  Note we ignore
1786
    strings and comments when matching; and the line we return is the
1787
    'cleansed' line at linenum.
1788
  """
1789
1790
  line = clean_lines.elided[linenum]
1791
  if (line[pos] not in '({[<') or Match(r'<[<=]', line[pos:]):
1792
    return (line, clean_lines.NumLines(), -1)
1793
1794
  # Check first line
1795
  (end_pos, stack) = FindEndOfExpressionInLine(line, pos, [])
1796
  if end_pos > -1:
1797
    return (line, linenum, end_pos)
1798
1799
  # Continue scanning forward
1800
  while stack and linenum < clean_lines.NumLines() - 1:
1801
    linenum += 1
1802
    line = clean_lines.elided[linenum]
1803
    (end_pos, stack) = FindEndOfExpressionInLine(line, 0, stack)
1804
    if end_pos > -1:
1805
      return (line, linenum, end_pos)
1806
1807
  # Did not find end of expression before end of file, give up
1808
  return (line, clean_lines.NumLines(), -1)
1809
1810
1811
def FindStartOfExpressionInLine(line, endpos, stack):