mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Keep else part on unwrap for and while
fixed PY-8569 Unwrap for loop statement should not delete else part
This commit is contained in:
@@ -28,6 +28,7 @@ public class PyForUnwrapper extends PyUnwrapper {
|
||||
protected void doUnwrap(final PsiElement element, final Context context) throws IncorrectOperationException {
|
||||
final PyForStatement forStatement = (PyForStatement)element;
|
||||
context.extractPart(forStatement);
|
||||
context.extractPart(forStatement.getElsePart());
|
||||
context.delete(forStatement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class PyWhileUnwrapper extends PyUnwrapper {
|
||||
protected void doUnwrap(final PsiElement element, final Context context) throws IncorrectOperationException {
|
||||
final PyWhileStatement whileStatement = (PyWhileStatement)element;
|
||||
context.extractPart(whileStatement);
|
||||
context.extractPart(whileStatement.getElsePart());
|
||||
context.delete(whileStatement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
print 1
|
||||
print 2
|
||||
@@ -0,0 +1,4 @@
|
||||
for item in range(1):
|
||||
prin<caret>t 1
|
||||
else:
|
||||
print 2
|
||||
@@ -0,0 +1,2 @@
|
||||
x = 1
|
||||
print 2
|
||||
@@ -0,0 +1,4 @@
|
||||
while True:
|
||||
x =<caret> 1
|
||||
else:
|
||||
print 2
|
||||
@@ -21,6 +21,7 @@ public class PyUnwrapperTest extends PyTestCase {
|
||||
public void testWhileUnwrap() throws Throwable {doTest();}
|
||||
public void testWhileUnwrapEmpty() throws Throwable {doNegativeTest();}
|
||||
public void testWhileUnwrapMultipleStatements() throws Throwable {doTest();}
|
||||
public void testWhileElseUnwrap() throws Throwable {doTest();}
|
||||
|
||||
public void testIfWithElseUnwrap() throws Throwable {doTest();}
|
||||
public void testIfInWhileUnwrap() throws Throwable {doTest();}
|
||||
@@ -40,6 +41,7 @@ public class PyUnwrapperTest extends PyTestCase {
|
||||
public void testTryElseFinallyUnwrap() throws Throwable {doTest();}
|
||||
|
||||
public void testForUnwrap() throws Throwable {doTest();}
|
||||
public void testForElseUnwrap() throws Throwable {doTest();}
|
||||
|
||||
public void testWithUnwrap() throws Throwable {doTest(LanguageLevel.PYTHON32);}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user