mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-31442 Shorter parser error for incomplete fragments terminated by closing quotes
In these cases one probably doesn't want to either specify a type conversion character or add a format part and has just forgotten a closing brace.
This commit is contained in:
@@ -189,7 +189,7 @@ public class ExpressionParsing extends Parsing {
|
||||
parseFStringFragmentFormatPart();
|
||||
}
|
||||
String errorMessage = "} expected";
|
||||
if (!hasFormatPart) {
|
||||
if (!hasFormatPart && !atToken(PyTokenTypes.FSTRING_END)) {
|
||||
errorMessage = ": or " + errorMessage;
|
||||
if (!hasTypeConversion) {
|
||||
errorMessage = "type conversion, " + errorMessage;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
f'{<error descr="expression expected"><error descr="Expression fragments inside f-strings cannot include backslashes">\</error>t</error>}'
|
||||
f'{<error descr="expression expected"><error descr="Expression fragments inside f-strings cannot include backslashes">\</error>t</error><error descr="type conversion, : or } expected">'</error>
|
||||
f'{<error descr="expression expected"><error descr="Expression fragments inside f-strings cannot include backslashes">\</error>t</error><error descr="} expected">'</error>
|
||||
f'{<error descr="expression expected"><error descr="Expression fragments inside f-strings cannot include backslashes">\</error>N{GREEK SMALL LETTER ALPHA}</error>}'
|
||||
f'{Formatable():\n\t}'
|
||||
f'{42:{<error descr="expression expected"><error descr="Expression fragments inside f-strings cannot include backslashes">\</error>t</error>}}'
|
||||
@@ -1,10 +1,10 @@
|
||||
f'{<error descr="expression expected">}</error>'
|
||||
f'{<error descr="expression expected"><error descr="type conversion, : or } expected">'</error></error>
|
||||
f'{<error descr="expression expected"><error descr="} expected">'</error></error>
|
||||
f'{<EOLError descr="type conversion, : or } expected"></EOLError><EOLError descr="expression expected"></EOLError><EOLError descr="' expected"></EOLError>
|
||||
f'{<error descr="expression expected">!</error>r}'
|
||||
f'{<error descr="expression expected">:</error>2.3}'
|
||||
f'{42:2.{<error descr="expression expected">}</error>}'
|
||||
f'{<error descr="expression expected"> </error>}'
|
||||
f'{42:{<error descr="expression expected"> </error>}}'
|
||||
f'{<error descr="expression expected"> </error>:{<error descr="expression expected"> </error><error descr="type conversion, : or } expected">'</error>
|
||||
f'{<error descr="expression expected"> </error>:{<error descr="expression expected"> </error><error descr="} expected">'</error>
|
||||
f'{<error descr="expression expected"> </error>!r:{<error descr="expression expected"> </error>:42}}'
|
||||
@@ -5,5 +5,5 @@ f'{42<error descr="Illegal conversion character 'z': should be one of 's', 'r',
|
||||
f'{42<error descr="Illegal conversion character 'foo': should be one of 's', 'r', 'a'">!foo</error>}'
|
||||
f'{42<error descr="Conversion character is expected: should be one of 's', 'r', 'a'">!</error>}'
|
||||
f'{42<error descr="Conversion character is expected: should be one of 's', 'r', 'a'">!</error>:2}'
|
||||
f'{42<error descr="Conversion character is expected: should be one of 's', 'r', 'a'">!</error><error descr=": or } expected">'</error>
|
||||
f'{42<error descr="Conversion character is expected: should be one of 's', 'r', 'a'">!</error><error descr="} expected">'</error>
|
||||
f'{42<error descr="Conversion character is expected: should be one of 's', 'r', 'a'">!</error><EOLError descr=": or } expected"></EOLError><EOLError descr="' expected"></EOLError>
|
||||
|
||||
@@ -3,8 +3,8 @@ f'{42!r}'
|
||||
f'{42!r:03}'
|
||||
f'{42:03}'
|
||||
f'{42!r:{y}.{z}}'
|
||||
f'{<error descr="expression expected"><error descr="type conversion, : or } expected">'</error></error>
|
||||
f'{42:{<error descr="expression expected"><error descr="type conversion, : or } expected">'</error></error>
|
||||
f'{42!r:{<error descr="expression expected"><error descr="type conversion, : or } expected">'</error></error>
|
||||
f'{<error descr="expression expected"><error descr="} expected">'</error></error>
|
||||
f'{42:{<error descr="expression expected"><error descr="} expected">'</error></error>
|
||||
f'{42!r:{<error descr="expression expected"><error descr="} expected">'</error></error>
|
||||
f'{{'
|
||||
f'{{{<error descr="expression expected"><error descr="type conversion, : or } expected">'</error></error>
|
||||
f'{{{<error descr="expression expected"><error descr="} expected">'</error></error>
|
||||
@@ -3,5 +3,5 @@ f'{x:{y:<error descr="Expression fragment inside f-string is nested too deeply">
|
||||
f'{x:{y:<error descr="Expression fragment inside f-string is nested too deeply">{z<error descr="Illegal conversion character 'z': should be one of 's', 'r', 'a'">!z</error>}</error>}}'
|
||||
f'{x:{y:<error descr="Expression fragment inside f-string is nested too deeply">{z:<error descr="Expression fragment inside f-string is nested too deeply">{42}</error>}</error>}}'
|
||||
f'{<error descr="expression expected">:</error>{<error descr="expression expected">:</error><error descr="Expression fragment inside f-string is nested too deeply">{<error descr="expression expected">:</error><error descr="Expression fragment inside f-string is nested too deeply">{<error descr="expression expected">}</error></error>}</error>}}'
|
||||
f'{x:{y:<error descr="Expression fragment inside f-string is nested too deeply">{z</error><error descr="type conversion, : or } expected">'</error>
|
||||
f'{x:{y:<error descr="Expression fragment inside f-string is nested too deeply">{z</error><error descr="} expected">'</error>
|
||||
f'{x:{y:<error descr="Expression fragment inside f-string is nested too deeply">{z</error><EOLError descr="type conversion, : or } expected"></EOLError><EOLError descr="' expected"></EOLError>
|
||||
@@ -13,6 +13,6 @@ PyFile:FStringFragmentIncompleteTypeConversionBeforeClosingQuote.py
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_TYPE_CONVERSION)('!')
|
||||
PsiErrorElement:: or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
@@ -12,6 +12,6 @@ PyFile:FStringIncompleteFragment.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
@@ -13,6 +13,6 @@ PyFile:FStringIncompleteFragmentWithTypeConversion.py
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_TYPE_CONVERSION)('!r')
|
||||
PsiErrorElement:: or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
@@ -17,7 +17,7 @@ PyFile:FStringTerminatedByQuoteInNestedLiteralPart.py
|
||||
PsiElement(Py:FSTRING_TEXT)('baz')
|
||||
PsiErrorElement:" expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiErrorElement:End of statement expected
|
||||
|
||||
@@ -16,7 +16,7 @@ PyFile:FStringTerminatedByQuoteInsideFStringLiteral.py
|
||||
PsiElement(Py:FSTRING_START)('f"')
|
||||
PsiErrorElement:" expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('"}baz'')
|
||||
@@ -21,7 +21,7 @@ PyFile:FStringTerminatedByQuoteInsideFStringLiteralInFormatPart.py
|
||||
PsiElement(Py:FSTRING_START)('f"')
|
||||
PsiErrorElement:" expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('"}}'')
|
||||
@@ -20,7 +20,7 @@ PyFile:FStringTerminatedByQuoteInsideNestedFStringLiteral.py
|
||||
PsiElement(Py:FSTRING_START)('f"')
|
||||
PsiErrorElement:" expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiErrorElement:""" expected
|
||||
<empty list>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ PyFile:FStringTerminatedByQuoteInsideNestedFStringLiteralInFormatPart.py
|
||||
PsiElement(Py:FSTRING_START)('f"')
|
||||
PsiErrorElement:" expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiErrorElement:""" expected
|
||||
<empty list>
|
||||
|
||||
@@ -17,7 +17,7 @@ PyFile:FStringTerminatedByQuoteInsideNestedStringLiteral.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('"')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiErrorElement:""" expected
|
||||
<empty list>
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ PyFile:FStringTerminatedByQuoteInsideNestedStringLiteralInFormatPart.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('"')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiErrorElement:""" expected
|
||||
<empty list>
|
||||
|
||||
@@ -13,7 +13,7 @@ PyFile:FStringTerminatedByQuoteInsideStringLiteral.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('"')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('"}baz'')
|
||||
@@ -18,7 +18,7 @@ PyFile:FStringTerminatedByQuoteInsideStringLiteralInFormatPart.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyStringLiteralExpression:
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('"')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiElement(Py:SINGLE_QUOTED_STRING)('"}}'')
|
||||
@@ -13,7 +13,7 @@ PyFile:FStringTerminatedByQuoteOfFStringLiteral.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyReferenceExpression: f
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiErrorElement:End of statement expected
|
||||
|
||||
@@ -18,7 +18,7 @@ PyFile:FStringTerminatedByQuoteOfFStringLiteralInFormatPart.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyReferenceExpression: f
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiErrorElement:End of statement expected
|
||||
|
||||
@@ -17,7 +17,7 @@ PyFile:FStringTerminatedByQuoteOfNestedFStringLiteral.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyReferenceExpression: f
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiErrorElement:" expected
|
||||
<empty list>
|
||||
|
||||
@@ -23,7 +23,7 @@ PyFile:FStringTerminatedByQuoteOfNestedFStringLiteralInFormatPart.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyReferenceExpression: f
|
||||
PsiElement(Py:IDENTIFIER)('f')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiErrorElement:" expected
|
||||
<empty list>
|
||||
|
||||
@@ -17,7 +17,7 @@ PyFile:FStringTerminatedByQuoteOfNestedStringLiteral.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiErrorElement:" expected
|
||||
<empty list>
|
||||
|
||||
@@ -23,7 +23,7 @@ PyFile:FStringTerminatedByQuoteOfNestedStringLiteralInFormatPart.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiErrorElement:" expected
|
||||
<empty list>
|
||||
|
||||
@@ -13,7 +13,7 @@ PyFile:FStringTerminatedByQuoteOfStringLiteral.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiErrorElement:End of statement expected
|
||||
|
||||
@@ -18,7 +18,7 @@ PyFile:FStringTerminatedByQuoteOfStringLiteralInFormatPart.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
PsiErrorElement:End of statement expected
|
||||
|
||||
@@ -18,6 +18,6 @@ PyFile:FStringTrailingWhitespaceInIncompleteFragmentInFormatPart.py
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
PsiErrorElement:} expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
Reference in New Issue
Block a user