fixed PY-11058 False positive Statement expected, found statement break

This commit is contained in:
Ekaterina Tuzova
2013-10-11 17:05:05 +04:00
parent bfaf87bc5a
commit ec5f16c8e0
4 changed files with 32 additions and 0 deletions

View 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()) {

View File

@@ -0,0 +1,2 @@
if True:
import tmp2; import tmp1

View File

@@ -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')

View 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;