mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
report colon with no following statement list as error (PY-2790)
This commit is contained in:
@@ -714,8 +714,13 @@ public class StatementParsing extends Parsing implements ITokenTypeRemapper {
|
||||
}
|
||||
else {
|
||||
myBuilder.advanceLexer();
|
||||
while (!myBuilder.eof() && myBuilder.getTokenType() != PyTokenTypes.DEDENT) {
|
||||
parseStatement();
|
||||
if (myBuilder.eof()) {
|
||||
myBuilder.error("indented block expected");
|
||||
}
|
||||
else {
|
||||
while (!myBuilder.eof() && myBuilder.getTokenType() != PyTokenTypes.DEDENT) {
|
||||
parseStatement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,11 +739,16 @@ public class StatementParsing extends Parsing implements ITokenTypeRemapper {
|
||||
}
|
||||
else {
|
||||
final PsiBuilder.Marker marker = myBuilder.mark();
|
||||
parseSimpleStatement(true);
|
||||
while (matchToken(PyTokenTypes.SEMICOLON)) {
|
||||
if (matchToken(PyTokenTypes.STATEMENT_BREAK))
|
||||
break;
|
||||
if (myBuilder.eof()) {
|
||||
myBuilder.error("statement expected");
|
||||
}
|
||||
else {
|
||||
parseSimpleStatement(true);
|
||||
while (matchToken(PyTokenTypes.SEMICOLON)) {
|
||||
if (matchToken(PyTokenTypes.STATEMENT_BREAK))
|
||||
break;
|
||||
parseSimpleStatement(true);
|
||||
}
|
||||
}
|
||||
marker.done(PyElementTypes.STATEMENT_LIST);
|
||||
if (endMarker != null) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
for a in b:
|
||||
@@ -0,0 +1,16 @@
|
||||
PyFile:ColonBeforeEof.py
|
||||
PyForStatement
|
||||
PyForPart
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: a
|
||||
PsiElement(Py:IDENTIFIER)('a')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: b
|
||||
PsiElement(Py:IDENTIFIER)('b')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PyStatementList
|
||||
PsiErrorElement:statement expected
|
||||
<empty list>
|
||||
@@ -251,6 +251,10 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testColonBeforeEof() { // PY-2790
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void doTest() {
|
||||
doTest(LanguageLevel.PYTHON25);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user