diff --git a/python/src/com/jetbrains/python/lexer/PythonIndentingProcessor.java b/python/src/com/jetbrains/python/lexer/PythonIndentingProcessor.java index 6aa84120d492..97bb3ddd9541 100644 --- a/python/src/com/jetbrains/python/lexer/PythonIndentingProcessor.java +++ b/python/src/com/jetbrains/python/lexer/PythonIndentingProcessor.java @@ -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; diff --git a/python/testData/psi/CommentAtTheEndOfBlock.py b/python/testData/psi/CommentAtTheEndOfBlock.py deleted file mode 100644 index 46d57aca7f2a..000000000000 --- a/python/testData/psi/CommentAtTheEndOfBlock.py +++ /dev/null @@ -1,4 +0,0 @@ -def f(): - def g(): - pass - # comment diff --git a/python/testData/psi/CommentAtTheEndOfBlock.txt b/python/testData/psi/CommentAtTheEndOfBlock.txt deleted file mode 100644 index f3e2c191ed63..000000000000 --- a/python/testData/psi/CommentAtTheEndOfBlock.txt +++ /dev/null @@ -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') \ No newline at end of file diff --git a/python/testData/psi/RaggedTrailingComments.py b/python/testData/psi/RaggedTrailingComments.py deleted file mode 100644 index 95811cdd3c9a..000000000000 --- a/python/testData/psi/RaggedTrailingComments.py +++ /dev/null @@ -1,7 +0,0 @@ -def foo(): - def bar(): - def baz(): - pass - # baz - # bar - # foo diff --git a/python/testData/psi/RaggedTrailingCommentsWithTrailingStatement.py b/python/testData/psi/RaggedTrailingCommentsWithTrailingStatement.py deleted file mode 100644 index 019e39d66398..000000000000 --- a/python/testData/psi/RaggedTrailingCommentsWithTrailingStatement.py +++ /dev/null @@ -1,8 +0,0 @@ -def foo(): - def bar(): - def baz(): - pass - # baz - # bar - # foo -pass \ No newline at end of file diff --git a/python/testData/psi/TrailingBlockCommentsAtEndOfFile.py b/python/testData/psi/TrailingBlockCommentsAtEndOfFile.py new file mode 100644 index 000000000000..bda8d227c901 --- /dev/null +++ b/python/testData/psi/TrailingBlockCommentsAtEndOfFile.py @@ -0,0 +1,9 @@ +def foo(): + def bar(): + def baz(): + pass + # baz 1 + # baz 2 + # baz 3 + # bar + # foo diff --git a/python/testData/psi/RaggedTrailingComments.txt b/python/testData/psi/TrailingBlockCommentsAtEndOfFile.txt similarity index 77% rename from python/testData/psi/RaggedTrailingComments.txt rename to python/testData/psi/TrailingBlockCommentsAtEndOfFile.txt index defef7b03789..5d7f0d18c5de 100644 --- a/python/testData/psi/RaggedTrailingComments.txt +++ b/python/testData/psi/TrailingBlockCommentsAtEndOfFile.txt @@ -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') \ No newline at end of file diff --git a/python/testData/psi/TrailingBlockCommentsFollowedByStatement.py b/python/testData/psi/TrailingBlockCommentsFollowedByStatement.py new file mode 100644 index 000000000000..dd29eb83b2af --- /dev/null +++ b/python/testData/psi/TrailingBlockCommentsFollowedByStatement.py @@ -0,0 +1,10 @@ +def foo(): + def bar(): + def baz(): + pass + # baz 1 + # baz 2 + # baz 3 + # bar + # foo +pass \ No newline at end of file diff --git a/python/testData/psi/RaggedTrailingCommentsWithTrailingStatement.txt b/python/testData/psi/TrailingBlockCommentsFollowedByStatement.txt similarity index 78% rename from python/testData/psi/RaggedTrailingCommentsWithTrailingStatement.txt rename to python/testData/psi/TrailingBlockCommentsFollowedByStatement.txt index 9e10290ff0de..0f217aa8594f 100644 --- a/python/testData/psi/RaggedTrailingCommentsWithTrailingStatement.txt +++ b/python/testData/psi/TrailingBlockCommentsFollowedByStatement.txt @@ -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') diff --git a/python/testSrc/com/jetbrains/python/PythonParsingTest.java b/python/testSrc/com/jetbrains/python/PythonParsingTest.java index a056afcfa89c..08fd356d0492 100644 --- a/python/testSrc/com/jetbrains/python/PythonParsingTest.java +++ b/python/testSrc/com/jetbrains/python/PythonParsingTest.java @@ -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(); }