diff --git a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java index c3bef81d1274..be18dd4a1554 100644 --- a/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java +++ b/python/src/com/jetbrains/python/codeInsight/controlflow/PyControlFlowBuilder.java @@ -441,6 +441,11 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor { @Override public void visitPyListCompExpression(final PyListCompExpression node) { + visitPyGeneratorExpression(node); + } + + @Override + public void visitPyGeneratorExpression(final PyGeneratorExpression node) { myBuilder.startNode(node); PyExpression prevCondition = null; for (ComprhIfComponent component : node.getIfComponents()) { diff --git a/python/src/com/jetbrains/python/psi/PyListCompExpression.java b/python/src/com/jetbrains/python/psi/PyListCompExpression.java index 0410dbfd99e6..e1cb60c45c5a 100644 --- a/python/src/com/jetbrains/python/psi/PyListCompExpression.java +++ b/python/src/com/jetbrains/python/psi/PyListCompExpression.java @@ -23,8 +23,5 @@ import java.util.List; * User: yole * Date: 31.05.2005 */ -public interface PyListCompExpression extends PyExpression, NameDefiner { - PyExpression getResultExpression(); - List getForComponents(); - List getIfComponents(); +public interface PyListCompExpression extends PyGeneratorExpression { } diff --git a/python/testData/codeInsight/controlflow/returnfor.py b/python/testData/codeInsight/controlflow/returnfor.py new file mode 100644 index 000000000000..8cc82f26c9e5 --- /dev/null +++ b/python/testData/codeInsight/controlflow/returnfor.py @@ -0,0 +1 @@ +return dict((name, val) for name, val in {'a': 1}) \ No newline at end of file diff --git a/python/testData/codeInsight/controlflow/returnfor.txt b/python/testData/codeInsight/controlflow/returnfor.txt new file mode 100644 index 000000000000..1dfe5f1bdb70 --- /dev/null +++ b/python/testData/codeInsight/controlflow/returnfor.txt @@ -0,0 +1,9 @@ +0(1) element: null +1(2) element: PyReturnStatement +2(3) READ ACCESS: dict +3(4) element: PyGeneratorExpression +4(5) WRITE ACCESS: name +5(6) WRITE ACCESS: val +6(7) READ ACCESS: name +7(8) READ ACCESS: val +8() element: null \ No newline at end of file diff --git a/python/testData/codeInsight/controlflow/try.txt b/python/testData/codeInsight/controlflow/try.txt index a83ad9bc255d..cd10733013e0 100644 --- a/python/testData/codeInsight/controlflow/try.txt +++ b/python/testData/codeInsight/controlflow/try.txt @@ -14,7 +14,7 @@ 13(14) READ ACCESS: int 14(15) READ ACCESS: s 15(16) READ ACCESS: strip -16(17,25,28,33) WRITE ACCESS: i +16(17,25,28,34) WRITE ACCESS: i 17(18) element: PyExceptPart 18(19) READ ACCESS: IOError 19(20) WRITE ACCESS: errno @@ -22,13 +22,14 @@ 21(22) element: PyPrintStatement 22(23) READ ACCESS: format 23(24) READ ACCESS: errno -24(33) READ ACCESS: strerror +24(34) READ ACCESS: strerror 25(26) element: PyExceptPart 26(27) READ ACCESS: ValueError -27(33) element: PyPrintStatement +27(34) element: PyPrintStatement 28(29) element: PyExceptPart 29(30) element: PyPrintStatement -30(31) READ ACCESS: sys -31(32) READ ACCESS: exc_info -32(33) element: PyRaiseStatement -33() element: null \ No newline at end of file +30(31) element: PySubscriptionExpression +31(32) READ ACCESS: sys +32(33) READ ACCESS: exc_info +33(34) element: PyRaiseStatement +34() 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 4ce748bcbc7e..093cb6dae527 100644 --- a/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java +++ b/python/testSrc/com/jetbrains/python/PyControlFlowBuilderTest.java @@ -86,6 +86,10 @@ public class PyControlFlowBuilderTest extends LightMarkedTestCase { doTest(); } + public void testReturnFor() throws Exception { + doTest(); + } + public void testTryBreak() throws Exception { final String testName = getTestName(false).toLowerCase(); configureByFile(testName + ".py");