mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
accept trailing comma in list literal
This commit is contained in:
@@ -106,6 +106,9 @@ public class ExpressionParsing extends Parsing {
|
||||
if (!matchToken(PyTokenTypes.COMMA)) {
|
||||
builder.error("expected ',' or ']'");
|
||||
}
|
||||
if (atToken(PyTokenTypes.RBRACKET)) {
|
||||
break;
|
||||
}
|
||||
if (!parseSingleExpression(isTargetExpression)) {
|
||||
builder.error(message("PARSE.expected.expr.or.comma.or.bracket"));
|
||||
break;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
x = ['a','b',]
|
||||
@@ -0,0 +1,16 @@
|
||||
PyFile:TrailingCommaInList.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: x
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyListLiteralExpression
|
||||
PsiElement(Py:LBRACKET)('[')
|
||||
PyStringLiteralExpression: a
|
||||
PsiElement(Py:STRING_LITERAL)(''a'')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PyStringLiteralExpression: b
|
||||
PsiElement(Py:STRING_LITERAL)(''b'')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
@@ -218,6 +218,10 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTrailingCommaInList() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void doTest() {
|
||||
doTest(LanguageLevel.PYTHON25);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user