mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-31442 Include comments and whitespaces inside fragments
It's beneficial for two reasons: it allows us to avoid occasional PsiWhitespaces at the end of incomplete fragments and also we can now better report illegal line comments this way, because even though they still terminate f-strings they are now under the corresponding AST nodes for expression fragments and can be processed by the annotator in the same fashion.
This commit is contained in:
@@ -15,7 +15,7 @@ PyFile:FStringBackslashAfterExpression.py
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiErrorElement:unexpected expression part
|
||||
PsiElement(Py:BACKSLASH)(' \')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_END)('}')
|
||||
PsiElement(Py:FSTRING_TEXT)('bar')
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
@@ -0,0 +1 @@
|
||||
s = f'{42:{ '
|
||||
@@ -0,0 +1,23 @@
|
||||
PyFile:FStringTrailingWhitespaceInIncompleteFragmentInFormatPart.py
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: s
|
||||
PsiElement(Py:IDENTIFIER)('s')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression: {42:{
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PyFStringFragmentFormatPart
|
||||
PsiElement(Py:FSTRING_FRAGMENT_FORMAT_START)(':')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
<empty list>
|
||||
PsiElement(Py:FSTRING_END)(''')
|
||||
@@ -13,9 +13,8 @@ PyFile:MultilineFStringContainsCommentInsteadOfExpression.py
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(Py:FSTRING_FRAGMENT_END)('}')
|
||||
PsiElement(Py:FSTRING_END)(''''')
|
||||
@@ -5,7 +5,7 @@ PyFile:SingleLineFStringContainsCommentInsideExpression.py
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression: {42
|
||||
PyStringLiteralExpression: {42 # comment}'
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PyFStringFragment
|
||||
@@ -14,7 +14,7 @@ PyFile:SingleLineFStringContainsCommentInsideExpression.py
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment}'')
|
||||
PsiErrorElement:' expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment}'')
|
||||
<empty list>
|
||||
@@ -5,15 +5,14 @@ PyFile:SingleLineFStringContainsCommentInsteadOfExpression.py
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PyStringLiteralExpression: {
|
||||
PyStringLiteralExpression: {# comment}'
|
||||
PyFormattedStringNode
|
||||
PsiElement(Py:FSTRING_START)('f'')
|
||||
PyFStringFragment
|
||||
PsiElement(Py:FSTRING_FRAGMENT_START)('{')
|
||||
PsiErrorElement:expression expected
|
||||
<empty list>
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment}'')
|
||||
PsiErrorElement:type conversion, : or } expected
|
||||
<empty list>
|
||||
PsiErrorElement:' expected
|
||||
<empty list>
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('# comment}'')
|
||||
<empty list>
|
||||
Reference in New Issue
Block a user