From e57db6494990ba60d43edcdb1c03e337c9c6619a Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 16 Jan 2012 18:39:20 +0100 Subject: [PATCH] to make sure CFG for bad code is built correctly, visit raw targets of assignment --- .../codeInsight/controlflow/PyControlFlowBuilder.java | 2 +- .../testData/codeInsight/controlflow/setcomprehension.py | 1 + .../codeInsight/controlflow/setcomprehension.txt | 9 +++++++++ .../com/jetbrains/python/PyControlFlowBuilderTest.java | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 python/testData/codeInsight/controlflow/setcomprehension.py create mode 100644 python/testData/codeInsight/controlflow/setcomprehension.txt diff --git a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java index ad2fe31e993c..9dcd79a98bad 100644 --- a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java +++ b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java @@ -144,7 +144,7 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor { if (value != null) { value.accept(this); } - for (PyExpression expression : node.getTargets()) { + for (PyExpression expression : node.getRawTargets()) { expression.accept(this); } } diff --git a/python/testData/codeInsight/controlflow/setcomprehension.py b/python/testData/codeInsight/controlflow/setcomprehension.py new file mode 100644 index 000000000000..78f501e5c79d --- /dev/null +++ b/python/testData/codeInsight/controlflow/setcomprehension.py @@ -0,0 +1 @@ +{ x for x in (1, 2) } = 5 \ No newline at end of file diff --git a/python/testData/codeInsight/controlflow/setcomprehension.txt b/python/testData/codeInsight/controlflow/setcomprehension.txt new file mode 100644 index 000000000000..44d9578c60c6 --- /dev/null +++ b/python/testData/codeInsight/controlflow/setcomprehension.txt @@ -0,0 +1,9 @@ +0(1) element: null +1(2) element: PyAssignmentStatement +2(3) element: PySetCompExpression +3(4,8) element: PyParenthesizedExpression +4(5) element: PyTargetExpression: x +5(6) WRITE ACCESS: x +6(7) element: PyReferenceExpression: x +7(4,8) READ ACCESS: x +8() element: null \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java b/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java index 23ed486402be..055a51c44fb4 100644 --- a/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java +++ b/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java @@ -170,6 +170,10 @@ public class PyControlFlowBuilderTest extends LightMarkedTestCase { doTestFirstStatement(); } + public void testSetComprehension() { + doTest(); + } + public void testQualifiedSelfReference() { final String testName = getTestName(false).toLowerCase(); configureByFile(testName + ".py");