|
52 | 52 | import string
|
53 | 53 | import sys
|
54 | 54 | import unicodedata
|
| 55 | +import itertools |
55 | 56 |
|
56 | 57 |
|
57 | 58 | _USAGE = """
|
@@ -6121,6 +6122,32 @@ def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error):
|
6121 | 6122 | 'For C++11-compatibility, omit template arguments from make_pair'
|
6122 | 6123 | ' OR use pair directly OR if appropriate, construct a pair directly')
|
6123 | 6124 |
|
| 6125 | +def AssembleString(clean_lines, start_lineno, start_linepos, end_lineno, end_linepos): |
| 6126 | + """ |
| 6127 | + Concatenates all the strings between the starting line position and |
| 6128 | + the ending line position. |
| 6129 | +
|
| 6130 | + Note: this operated on the elided (no strings and comments) view of the |
| 6131 | + code. |
| 6132 | +
|
| 6133 | + Args: |
| 6134 | + clean_lines: All the lines |
| 6135 | + start_lineno: The starting line number |
| 6136 | + start_linepos: The index of the first character to include |
| 6137 | + end_lineno: The last line |
| 6138 | + end_linepos: The index of the first character not to include |
| 6139 | + """ |
| 6140 | + if end_lineno < start_lineno: |
| 6141 | + return '' |
| 6142 | + |
| 6143 | + if start_lineno == end_lineno: |
| 6144 | + return clean_lines.elided[start_lineno][start_linepos : end_linepos] |
| 6145 | + |
| 6146 | + full_string = clean_lines.elided[start_lineno][start_linepos:] |
| 6147 | + for line in itertools.islice(clean_lines.elided, start_lineno + 1, end_lineno): |
| 6148 | + full_string += line |
| 6149 | + full_string += clean_lines.elided[end_lineno][:end_linepos] |
| 6150 | + return full_string |
6124 | 6151 |
|
6125 | 6152 | def CheckRedundantVirtual(filename, clean_lines, linenum, error):
|
6126 | 6153 | """Check if line contains a redundant "virtual" function-specifier.
|
|
0 commit comments