PY-31442 Handle f-strings terminated by other string literals in fragments

When the terminating quote is either at the beginning of a string literal or
inside it, either in the given f-string itself or inside a nested one and
either in normal fragment or in a fragment located inside a format part of
another fragment. Normal string literals and nested f-strings are also checked
separately.
This commit is contained in:
Mikhail Golubev
2018-10-01 12:46:42 +03:00
parent 50383b4768
commit 68f72f3dd9
22 changed files with 1303 additions and 662 deletions
@@ -0,0 +1,37 @@
PyFile:FStringTerminatedByQuoteInsideNestedFStringLiteral.py
PyAssignmentStatement
PyTargetExpression: s
PsiElement(Py:IDENTIFIER)('s')
PsiWhiteSpace(' ')
PsiElement(Py:EQ)('=')
PsiWhiteSpace(' ')
PyStringLiteralExpression: }
PyFormattedStringNode
PsiElement(Py:FSTRING_START)('f'')
PyFStringFragment
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
PyStringLiteralExpression:
PyFormattedStringNode
PsiElement(Py:FSTRING_START)('f"""')
PyFStringFragment
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
PyStringLiteralExpression:
PyFormattedStringNode
PsiElement(Py:FSTRING_START)('f"')
PsiErrorElement:Expected "
<empty list>
PsiErrorElement:type conversion, : or } expected
<empty list>
PsiErrorElement:Expected """
<empty list>
PsiElement(Py:FSTRING_END)(''')
PsiElement(Py:SINGLE_QUOTED_STRING)('"}"')
PsiElement(Py:SINGLE_QUOTED_STRING)('""')
PsiErrorElement:End of statement expected
<empty list>
PsiElement(Py:RBRACE)('}')
PsiErrorElement:Statement expected, found Py:RBRACE
<empty list>
PyExpressionStatement
PyStringLiteralExpression:
PsiElement(Py:SINGLE_QUOTED_STRING)(''')