fixed PY-11058 False positive Statement expected, found statement break
authorEkaterina Tuzova <Ekaterina.Tuzova@jetbrains.com>
Fri, 11 Oct 2013 13:05:05 +0000 (17:05 +0400)
committerEkaterina Tuzova <Ekaterina.Tuzova@jetbrains.com>
Fri, 11 Oct 2013 13:05:05 +0000 (17:05 +0400)
python/src/com/jetbrains/python/parsing/StatementParsing.java
python/testData/psi/ResetAfterSemicolon.py [new file with mode: 0644]
python/testData/psi/ResetAfterSemicolon.txt [new file with mode: 0644]
python/testSrc/com/jetbrains/python/PythonParsingTest.java

index becf374a19fc8004d622a4f0715887c49fab139d..32d39c4b1a54a173bef79f030b2a44b917818c65 100644 (file)
@@ -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 (file)
index 0000000..4e3d90d
--- /dev/null
@@ -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 (file)
index 0000000..6ad8568
--- /dev/null
@@ -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
index 6b6f6de68bfdfe8bcba7ad21677800f0518cfed2..a7033f19cf7d5d6de3cacbe515a39a7f51da6970 100644 (file)
@@ -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;