mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-5192 Move Statement: breaks code in case moving down to nested try statement
This commit is contained in:
+2
-2
@@ -246,7 +246,7 @@ public class StatementMover extends LineMover {
|
||||
PsiElement commonParent = PsiTreeUtil.findCommonParent(statementPart1, statementPart2);
|
||||
if (PsiTreeUtil.isAncestor(statementPart2, statementPart1, false)) return false;
|
||||
if ((commonParent instanceof PyIfStatement) || (commonParent instanceof PyLoopStatement) ||
|
||||
(commonParent instanceof PyConditionalStatementPart))
|
||||
(commonParent instanceof PyStatementPart))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -261,7 +261,7 @@ public class StatementMover extends LineMover {
|
||||
if (statementPart2 == null) return true;
|
||||
if (statementPart1.getParent() != statementPart2.getParent()) {
|
||||
PsiElement commonParent = PsiTreeUtil.findCommonParent(statementPart1, statementPart2);
|
||||
if (!(commonParent instanceof PyIfStatement) && !(commonParent instanceof PyLoopStatement) && !(commonParent instanceof PyConditionalStatementPart))
|
||||
if (!(commonParent instanceof PyIfStatement) && !(commonParent instanceof PyLoopStatement) && !(commonParent instanceof PyStatementPart))
|
||||
return true;
|
||||
if (PsiTreeUtil.isAncestor(statementPart2, statementPart1, false)) return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
try:
|
||||
zo<caret>o(3)
|
||||
try:
|
||||
print(zoo(1).foo(2))
|
||||
except:
|
||||
print(zoo(0).foo(2))
|
||||
except:
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
try:
|
||||
try:
|
||||
zoo(3)
|
||||
print(zoo(1).foo(2))
|
||||
except:
|
||||
print(zoo(0).foo(2))
|
||||
except:
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
zoo(3)
|
||||
try:
|
||||
try:
|
||||
print(zoo(1).foo(2))
|
||||
except:
|
||||
print(zoo(0).foo(2))
|
||||
except:
|
||||
pass
|
||||
@@ -99,4 +99,8 @@ public class PyStatementMoverTest extends PyTestCase {
|
||||
public void testContinueBreak() { // PY-5193
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNestedTry() { // PY-5192
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user