diff --git a/python/src/com/jetbrains/python/parsing/StatementParsing.java b/python/src/com/jetbrains/python/parsing/StatementParsing.java index becf374a19fc..32d39c4b1a54 100644 --- a/python/src/com/jetbrains/python/parsing/StatementParsing.java +++ b/python/src/com/jetbrains/python/parsing/StatementParsing.java @@ -259,6 +259,7 @@ public class StatementParsing extends Parsing implements ITokenTypeRemapper { PsiBuilder builder = myContext.getBuilder(); if (builder.getTokenType() == PyTokenTypes.STATEMENT_BREAK) { builder.advanceLexer(); + scope.setAfterSemicolon(false); } else if (builder.getTokenType() == PyTokenTypes.SEMICOLON) { if (!scope.isSuite()) { diff --git a/python/testData/psi/ResetAfterSemicolon.py b/python/testData/psi/ResetAfterSemicolon.py new file mode 100644 index 000000000000..4e3d90d85e0e --- /dev/null +++ b/python/testData/psi/ResetAfterSemicolon.py @@ -0,0 +1,2 @@ +if True: + import tmp2; import tmp1 diff --git a/python/testData/psi/ResetAfterSemicolon.txt b/python/testData/psi/ResetAfterSemicolon.txt new file mode 100644 index 000000000000..6ad856879290 --- /dev/null +++ b/python/testData/psi/ResetAfterSemicolon.txt @@ -0,0 +1,24 @@ +PyFile:ResetAfterSemicolon.py + PyIfStatement + PyIfPartIf + PsiElement(Py:IF_KEYWORD)('if') + PsiWhiteSpace(' ') + PyReferenceExpression: True + PsiElement(Py:IDENTIFIER)('True') + PsiElement(Py:COLON)(':') + PsiWhiteSpace('\n ') + PyStatementList + PyImportStatement + PsiElement(Py:IMPORT_KEYWORD)('import') + PsiWhiteSpace(' ') + PyImportElement:tmp2 + PyReferenceExpression: tmp2 + PsiElement(Py:IDENTIFIER)('tmp2') + PsiElement(Py:SEMICOLON)(';') + PsiWhiteSpace(' ') + PyImportStatement + PsiElement(Py:IMPORT_KEYWORD)('import') + PsiWhiteSpace(' ') + PyImportElement:tmp1 + PyReferenceExpression: tmp1 + PsiElement(Py:IDENTIFIER)('tmp1') \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PythonParsingTest.java b/python/testSrc/com/jetbrains/python/PythonParsingTest.java index 6b6f6de68bfd..a7033f19cf7d 100644 --- a/python/testSrc/com/jetbrains/python/PythonParsingTest.java +++ b/python/testSrc/com/jetbrains/python/PythonParsingTest.java @@ -378,6 +378,11 @@ public class PythonParsingTest extends ParsingTestCase { doTest(); } + // PY-11058 + public void testResetAfterSemicolon() { + doTest(); + } + public void doTest(LanguageLevel languageLevel) { LanguageLevel prev = myLanguageLevel; myLanguageLevel = languageLevel;