mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
PY-20770 Fixed: Support Python 3.6 asynchronous generators and comprehensions
Add tests for parsing await inside comprehensions
This commit is contained in:
16
python/testData/psi/AwaitInComprehensions.py
Normal file
16
python/testData/psi/AwaitInComprehensions.py
Normal file
@@ -0,0 +1,16 @@
|
||||
async def async2():
|
||||
[await fun() for fun in funcs]
|
||||
{await fun() for fun in funcs}
|
||||
{fun: await fun() for fun in funcs}
|
||||
|
||||
[await fun() for fun in funcs if await smth]
|
||||
{await fun() for fun in funcs if await smth}
|
||||
{fun: await fun() for fun in funcs if await smth}
|
||||
|
||||
[await fun() async for fun in funcs]
|
||||
{await fun() async for fun in funcs}
|
||||
{fun: await fun() async for fun in funcs}
|
||||
|
||||
[await fun() async for fun in funcs if await smth]
|
||||
{await fun() async for fun in funcs if await smth}
|
||||
{fun: await fun() async for fun in funcs if await smth}
|
||||
380
python/testData/psi/AwaitInComprehensions.txt
Normal file
380
python/testData/psi/AwaitInComprehensions.txt
Normal file
@@ -0,0 +1,380 @@
|
||||
PyFile:AwaitInComprehensions.py
|
||||
PyFunction('async2')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:DEF_KEYWORD)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IDENTIFIER)('async2')
|
||||
PyParameterList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyExpressionStatement
|
||||
PyListCompExpression
|
||||
PsiElement(Py:LBRACKET)('[')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PySetCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PyDictCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyKeyValueExpression
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PyExpressionStatement
|
||||
PyListCompExpression
|
||||
PsiElement(Py:LBRACKET)('[')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: smth
|
||||
PsiElement(Py:IDENTIFIER)('smth')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PySetCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: smth
|
||||
PsiElement(Py:IDENTIFIER)('smth')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PyDictCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyKeyValueExpression
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: smth
|
||||
PsiElement(Py:IDENTIFIER)('smth')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PyExpressionStatement
|
||||
PyListCompExpression
|
||||
PsiElement(Py:LBRACKET)('[')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PySetCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PyDictCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyKeyValueExpression
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PyExpressionStatement
|
||||
PyListCompExpression
|
||||
PsiElement(Py:LBRACKET)('[')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: smth
|
||||
PsiElement(Py:IDENTIFIER)('smth')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PySetCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: smth
|
||||
PsiElement(Py:IDENTIFIER)('smth')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PyDictCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyKeyValueExpression
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: fun
|
||||
PyReferenceExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: fun
|
||||
PsiElement(Py:IDENTIFIER)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: funcs
|
||||
PsiElement(Py:IDENTIFIER)('funcs')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyPrefixExpression
|
||||
PsiElement(Py:AWAIT_KEYWORD)('await')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: smth
|
||||
PsiElement(Py:IDENTIFIER)('smth')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
@@ -529,6 +529,11 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
// PY-20770
|
||||
public void testAwaitInComprehensions() {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
public void doTest(LanguageLevel languageLevel) {
|
||||
LanguageLevel prev = myLanguageLevel;
|
||||
myLanguageLevel = languageLevel;
|
||||
|
||||
Reference in New Issue
Block a user