mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-11476 No error given for mismatched accolade and squarebracket
This commit is contained in:
@@ -637,6 +637,7 @@ PARSE.expected.comma=',' expected
|
||||
PARSE.expected.colon=':' expected
|
||||
PARSE.expected.rpar=')' expected
|
||||
PARSE.expected.lpar='(' expected
|
||||
PARSE.expected.rbrace='}' expected
|
||||
PARSE.expected.tick='`' (backtick) expected
|
||||
PARSE.expected.name=name expected
|
||||
PARSE.expected.colon.or.rbracket=':' or ']' expected
|
||||
|
||||
@@ -236,7 +236,7 @@ public class ExpressionParsing extends Parsing {
|
||||
break;
|
||||
}
|
||||
}
|
||||
myBuilder.advanceLexer();
|
||||
checkMatches(PyTokenTypes.RBRACE, message("PARSE.expected.rbrace"));
|
||||
startMarker.done(PyElementTypes.DICT_LITERAL_EXPRESSION);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class ExpressionParsing extends Parsing {
|
||||
break;
|
||||
}
|
||||
}
|
||||
myBuilder.advanceLexer();
|
||||
checkMatches(PyTokenTypes.RBRACE, message("PARSE.expected.rbrace"));
|
||||
startMarker.done(PyElementTypes.SET_LITERAL_EXPRESSION);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
a = {
|
||||
'b': 'c',
|
||||
]
|
||||
@@ -0,0 +1,24 @@
|
||||
PyFile:NotClosedBraceDict.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: a
|
||||
PsiElement(Py:IDENTIFIER)('a')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyDictLiteralExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyKeyValueExpression
|
||||
PyStringLiteralExpression: b
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)(''b'')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression: c
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)(''c'')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiErrorElement:'}' expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
PsiErrorElement:Statement expected, found Py:RBRACKET
|
||||
<empty list>
|
||||
@@ -0,0 +1 @@
|
||||
a = {'b',]
|
||||
@@ -0,0 +1,17 @@
|
||||
PyFile:NotClosedBraceSet.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: a
|
||||
PsiElement(Py:IDENTIFIER)('a')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PySetLiteralExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyStringLiteralExpression: b
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)(''b'')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiErrorElement:'}' expected
|
||||
<empty list>
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
PsiErrorElement:Statement expected, found Py:RBRACKET
|
||||
<empty list>
|
||||
@@ -430,6 +430,14 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotClosedBraceDict() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotClosedBraceSet() {
|
||||
doTest(LanguageLevel.PYTHON33);
|
||||
}
|
||||
|
||||
public void doTest(LanguageLevel languageLevel) {
|
||||
LanguageLevel prev = myLanguageLevel;
|
||||
myLanguageLevel = languageLevel;
|
||||
|
||||
Reference in New Issue
Block a user