@@ 1888-1923 (lines=36) @@ | ||
1885 | return (-1, stack) |
|
1886 | ||
1887 | ||
1888 | def ReverseCloseExpression(clean_lines, linenum, pos): |
|
1889 | """If input points to ) or } or ] or >, finds the position that opens it. |
|
1890 | ||
1891 | If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the |
|
1892 | linenum/pos that correspond to the opening of the expression. |
|
1893 | ||
1894 | Args: |
|
1895 | clean_lines: A CleansedLines instance containing the file. |
|
1896 | linenum: The number of the line to check. |
|
1897 | pos: A position on the line. |
|
1898 | ||
1899 | Returns: |
|
1900 | A tuple (line, linenum, pos) pointer *at* the opening brace, or |
|
1901 | (line, 0, -1) if we never find the matching opening brace. Note |
|
1902 | we ignore strings and comments when matching; and the line we |
|
1903 | return is the 'cleansed' line at linenum. |
|
1904 | """ |
|
1905 | line = clean_lines.elided[linenum] |
|
1906 | if line[pos] not in ')}]>': |
|
1907 | return (line, 0, -1) |
|
1908 | ||
1909 | # Check last line |
|
1910 | (start_pos, stack) = FindStartOfExpressionInLine(line, pos, []) |
|
1911 | if start_pos > -1: |
|
1912 | return (line, linenum, start_pos) |
|
1913 | ||
1914 | # Continue scanning backward |
|
1915 | while stack and linenum > 0: |
|
1916 | linenum -= 1 |
|
1917 | line = clean_lines.elided[linenum] |
|
1918 | (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack) |
|
1919 | if start_pos > -1: |
|
1920 | return (line, linenum, start_pos) |
|
1921 | ||
1922 | # Did not find start of expression before beginning of file, give up |
|
1923 | return (line, 0, -1) |
|
1924 | ||
1925 | ||
1926 | def CheckForCopyright(filename, lines, error): |
@@ 1888-1923 (lines=36) @@ | ||
1885 | return (-1, stack) |
|
1886 | ||
1887 | ||
1888 | def ReverseCloseExpression(clean_lines, linenum, pos): |
|
1889 | """If input points to ) or } or ] or >, finds the position that opens it. |
|
1890 | ||
1891 | If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the |
|
1892 | linenum/pos that correspond to the opening of the expression. |
|
1893 | ||
1894 | Args: |
|
1895 | clean_lines: A CleansedLines instance containing the file. |
|
1896 | linenum: The number of the line to check. |
|
1897 | pos: A position on the line. |
|
1898 | ||
1899 | Returns: |
|
1900 | A tuple (line, linenum, pos) pointer *at* the opening brace, or |
|
1901 | (line, 0, -1) if we never find the matching opening brace. Note |
|
1902 | we ignore strings and comments when matching; and the line we |
|
1903 | return is the 'cleansed' line at linenum. |
|
1904 | """ |
|
1905 | line = clean_lines.elided[linenum] |
|
1906 | if line[pos] not in ')}]>': |
|
1907 | return (line, 0, -1) |
|
1908 | ||
1909 | # Check last line |
|
1910 | (start_pos, stack) = FindStartOfExpressionInLine(line, pos, []) |
|
1911 | if start_pos > -1: |
|
1912 | return (line, linenum, start_pos) |
|
1913 | ||
1914 | # Continue scanning backward |
|
1915 | while stack and linenum > 0: |
|
1916 | linenum -= 1 |
|
1917 | line = clean_lines.elided[linenum] |
|
1918 | (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack) |
|
1919 | if start_pos > -1: |
|
1920 | return (line, linenum, start_pos) |
|
1921 | ||
1922 | # Did not find start of expression before beginning of file, give up |
|
1923 | return (line, 0, -1) |
|
1924 | ||
1925 | ||
1926 | def CheckForCopyright(filename, lines, error): |