PY-17017 Comments with greater indent are still included inside suite

This commit is contained in:
Mikhail Golubev
2017-10-02 15:20:24 +03:00
parent f6a325b3de
commit 9c3aa66ca4
10 changed files with 37 additions and 57 deletions
@@ -412,7 +412,7 @@ public class PythonIndentingProcessor extends MergingLexerAdapter {
for (int i = anchorIndex; i < myTokenQueue.size(); i++) {
final PendingToken token = myTokenQueue.get(i);
if (token instanceof PendingCommentToken) {
if (((PendingCommentToken)token).getIndent() != indent) {
if (((PendingCommentToken)token).getIndent() < indent) {
break;
}
result = i + 1;
@@ -1,4 +0,0 @@
def f():
def g():
pass
# comment
@@ -1,25 +0,0 @@
PyFile:CommentAtTheEndOfBlock.py
PyFunction('f')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('f')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyFunction('g')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('g')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# comment')
@@ -1,7 +0,0 @@
def foo():
def bar():
def baz():
pass
# baz
# bar
# foo
@@ -1,8 +0,0 @@
def foo():
def bar():
def baz():
pass
# baz
# bar
# foo
pass
@@ -0,0 +1,9 @@
def foo():
def bar():
def baz():
pass
# baz 1
# baz 2
# baz 3
# bar
# foo
@@ -1,4 +1,4 @@
PyFile:RaggedTrailingComments.py
PyFile:TrailingBlockCommentsAtEndOfFile.py
PyFunction('foo')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
@@ -32,8 +32,12 @@ PyFile:RaggedTrailingComments.py
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz 1')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz 2')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz 3')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# bar')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# foo')
@@ -0,0 +1,10 @@
def foo():
def bar():
def baz():
pass
# baz 1
# baz 2
# baz 3
# bar
# foo
pass
@@ -1,4 +1,4 @@
PyFile:RaggedTrailingCommentsWithTrailingStatement.py
PyFile:TrailingBlockCommentsFollowedByStatement.py
PyFunction('foo')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
@@ -32,8 +32,12 @@ PyFile:RaggedTrailingCommentsWithTrailingStatement.py
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz 1')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz 2')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz 3')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# bar')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# foo')
@@ -546,15 +546,12 @@ public class PythonParsingTest extends ParsingTestCase {
}
// PY-17017
public void testCommentAtTheEndOfBlock() {
public void testTrailingBlockCommentsAtEndOfFile() {
doTest();
}
public void testRaggedTrailingComments() {
doTest();
}
public void testRaggedTrailingCommentsWithTrailingStatement() {
// PY-17017
public void testTrailingBlockCommentsFollowedByStatement() {
doTest();
}