mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-20770 Fixed: Support Python 3.6 asynchronous generators and comprehensions
Check for "for" or "async for" while parsing generators, list, dict and set literals Highlight "async" as keyword in generators, list, dict and set literals
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
async def async2():
|
||||
{i async for i in asyncgen()}
|
||||
[i async for i in asyncgen()]
|
||||
{i: i ** 2 async for i in asyncgen()}
|
||||
(i ** 2 async for i in asyncgen())
|
||||
list(i async for i in asyncgen())
|
||||
|
||||
dataset = {data for line in gen()
|
||||
async for data in line
|
||||
if check(data)}
|
||||
|
||||
dataset = {data async for line in asyncgen()
|
||||
async for data in line
|
||||
if check(data)}
|
||||
@@ -0,0 +1,248 @@
|
||||
PyFile:AsyncComprehensions.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
|
||||
PySetCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyReferenceExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: asyncgen
|
||||
PyReferenceExpression: asyncgen
|
||||
PsiElement(Py:IDENTIFIER)('asyncgen')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PyListCompExpression
|
||||
PsiElement(Py:LBRACKET)('[')
|
||||
PyReferenceExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: asyncgen
|
||||
PyReferenceExpression: asyncgen
|
||||
PsiElement(Py:IDENTIFIER)('asyncgen')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PyDictCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyKeyValueExpression
|
||||
PyReferenceExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyBinaryExpression
|
||||
PyReferenceExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EXP)('**')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('2')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: asyncgen
|
||||
PyReferenceExpression: asyncgen
|
||||
PsiElement(Py:IDENTIFIER)('asyncgen')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PyGeneratorExpression
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyBinaryExpression
|
||||
PyReferenceExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EXP)('**')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('2')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: asyncgen
|
||||
PyReferenceExpression: asyncgen
|
||||
PsiElement(Py:IDENTIFIER)('asyncgen')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyExpressionStatement
|
||||
PyCallExpression: list
|
||||
PyReferenceExpression: list
|
||||
PsiElement(Py:IDENTIFIER)('list')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyGeneratorExpression
|
||||
PyReferenceExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: i
|
||||
PsiElement(Py:IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: asyncgen
|
||||
PyReferenceExpression: asyncgen
|
||||
PsiElement(Py:IDENTIFIER)('asyncgen')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: dataset
|
||||
PsiElement(Py:IDENTIFIER)('dataset')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PySetCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyReferenceExpression: data
|
||||
PsiElement(Py:IDENTIFIER)('data')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: line
|
||||
PsiElement(Py:IDENTIFIER)('line')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: gen
|
||||
PyReferenceExpression: gen
|
||||
PsiElement(Py:IDENTIFIER)('gen')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: data
|
||||
PsiElement(Py:IDENTIFIER)('data')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: line
|
||||
PsiElement(Py:IDENTIFIER)('line')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: check
|
||||
PyReferenceExpression: check
|
||||
PsiElement(Py:IDENTIFIER)('check')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyReferenceExpression: data
|
||||
PsiElement(Py:IDENTIFIER)('data')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PyAssignmentStatement
|
||||
PyTargetExpression: dataset
|
||||
PsiElement(Py:IDENTIFIER)('dataset')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PySetCompExpression
|
||||
PsiElement(Py:LBRACE)('{')
|
||||
PyReferenceExpression: data
|
||||
PsiElement(Py:IDENTIFIER)('data')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: line
|
||||
PsiElement(Py:IDENTIFIER)('line')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: asyncgen
|
||||
PyReferenceExpression: asyncgen
|
||||
PsiElement(Py:IDENTIFIER)('asyncgen')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(Py:ASYNC_KEYWORD)('async')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:FOR_KEYWORD)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PyTargetExpression: data
|
||||
PsiElement(Py:IDENTIFIER)('data')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IN_KEYWORD)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
PyReferenceExpression: line
|
||||
PsiElement(Py:IDENTIFIER)('line')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(Py:IF_KEYWORD)('if')
|
||||
PsiWhiteSpace(' ')
|
||||
PyCallExpression: check
|
||||
PyReferenceExpression: check
|
||||
PsiElement(Py:IDENTIFIER)('check')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyReferenceExpression: data
|
||||
PsiElement(Py:IDENTIFIER)('data')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:RBRACE)('}')
|
||||
Reference in New Issue
Block a user