From 30c936a46d07bf75b6341b682025431cc9cc856c Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Mon, 14 Sep 2015 15:22:58 +0300 Subject: [PATCH] Fixed warnings for star unpacking in set literals --- .../python/psi/impl/PyStarExpressionImpl.java | 2 +- python/testData/highlighting/unpackingStar.py | 1 + python/testData/psi/UnpackingExpressions.py | 3 + python/testData/psi/UnpackingExpressions.txt | 81 +++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/psi/impl/PyStarExpressionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyStarExpressionImpl.java index 64fb8aa8c452..fe211692a878 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyStarExpressionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyStarExpressionImpl.java @@ -60,6 +60,6 @@ public class PyStarExpressionImpl extends PyElementImpl implements PyStarExpress while (parent instanceof PyParenthesizedExpression) { parent = parent.getParent(); } - return parent instanceof PyTupleExpression || parent instanceof PyListLiteralExpression; + return parent instanceof PyTupleExpression || parent instanceof PyListLiteralExpression || parent instanceof PySetLiteralExpression; } } diff --git a/python/testData/highlighting/unpackingStar.py b/python/testData/highlighting/unpackingStar.py index 04e59c5a5ddb..59d21937a8ff 100644 --- a/python/testData/highlighting/unpackingStar.py +++ b/python/testData/highlighting/unpackingStar.py @@ -1,6 +1,7 @@ 1, *x (1, *x) [1, *x] +{1, *x} if *x: pass diff --git a/python/testData/psi/UnpackingExpressions.py b/python/testData/psi/UnpackingExpressions.py index 73c9cb541051..50dc2d3de817 100644 --- a/python/testData/psi/UnpackingExpressions.py +++ b/python/testData/psi/UnpackingExpressions.py @@ -10,3 +10,6 @@ print({**f()}) print({**f(), 3: 4}) print({1: 2, **f()}) print({**f(), **f()}) +print({1, 2, *(3, 4)}) +print({*(1, 2), 3}) +print({*(1, 2)}) diff --git a/python/testData/psi/UnpackingExpressions.txt b/python/testData/psi/UnpackingExpressions.txt index c96cc6b71d0b..084195f10b3e 100644 --- a/python/testData/psi/UnpackingExpressions.txt +++ b/python/testData/psi/UnpackingExpressions.txt @@ -363,4 +363,85 @@ PyFile:UnpackingExpressions.py PsiElement(Py:LPAR)('(') PsiElement(Py:RPAR)(')') PsiElement(Py:RBRACE)('}') + PsiElement(Py:RPAR)(')') + PsiWhiteSpace('\n') + PyExpressionStatement + PyCallExpression: print + PyReferenceExpression: print + PsiElement(Py:IDENTIFIER)('print') + PyArgumentList + PsiElement(Py:LPAR)('(') + PySetLiteralExpression + PsiElement(Py:LBRACE)('{') + PyNumericLiteralExpression + PsiElement(Py:INTEGER_LITERAL)('1') + PsiElement(Py:COMMA)(',') + PsiWhiteSpace(' ') + PyNumericLiteralExpression + PsiElement(Py:INTEGER_LITERAL)('2') + PsiElement(Py:COMMA)(',') + PsiWhiteSpace(' ') + PyStarExpression + PsiElement(Py:MULT)('*') + PyParenthesizedExpression + PsiElement(Py:LPAR)('(') + PyTupleExpression + PyNumericLiteralExpression + PsiElement(Py:INTEGER_LITERAL)('3') + PsiElement(Py:COMMA)(',') + PsiWhiteSpace(' ') + PyNumericLiteralExpression + PsiElement(Py:INTEGER_LITERAL)('4') + PsiElement(Py:RPAR)(')') + PsiElement(Py:RBRACE)('}') + PsiElement(Py:RPAR)(')') + PsiWhiteSpace('\n') + PyExpressionStatement + PyCallExpression: print + PyReferenceExpression: print + PsiElement(Py:IDENTIFIER)('print') + PyArgumentList + PsiElement(Py:LPAR)('(') + PySetLiteralExpression + PsiElement(Py:LBRACE)('{') + PyStarExpression + PsiElement(Py:MULT)('*') + PyParenthesizedExpression + PsiElement(Py:LPAR)('(') + PyTupleExpression + PyNumericLiteralExpression + PsiElement(Py:INTEGER_LITERAL)('1') + PsiElement(Py:COMMA)(',') + PsiWhiteSpace(' ') + PyNumericLiteralExpression + PsiElement(Py:INTEGER_LITERAL)('2') + PsiElement(Py:RPAR)(')') + PsiElement(Py:COMMA)(',') + PsiWhiteSpace(' ') + PyNumericLiteralExpression + PsiElement(Py:INTEGER_LITERAL)('3') + PsiElement(Py:RBRACE)('}') + PsiElement(Py:RPAR)(')') + PsiWhiteSpace('\n') + PyExpressionStatement + PyCallExpression: print + PyReferenceExpression: print + PsiElement(Py:IDENTIFIER)('print') + PyArgumentList + PsiElement(Py:LPAR)('(') + PySetLiteralExpression + PsiElement(Py:LBRACE)('{') + PyStarExpression + PsiElement(Py:MULT)('*') + PyParenthesizedExpression + PsiElement(Py:LPAR)('(') + PyTupleExpression + PyNumericLiteralExpression + PsiElement(Py:INTEGER_LITERAL)('1') + PsiElement(Py:COMMA)(',') + PsiWhiteSpace(' ') + PyNumericLiteralExpression + PsiElement(Py:INTEGER_LITERAL)('2') + PsiElement(Py:RPAR)(')') + PsiElement(Py:RBRACE)('}') PsiElement(Py:RPAR)(')') \ No newline at end of file