mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-992 Extract Method doesn't handle conditional returns correctly
This commit is contained in:
@@ -100,9 +100,12 @@ public class PyCodeFragmentUtil {
|
||||
for (Instruction outerInstruction : outerInstructions) {
|
||||
// Here we check control flow when for statement content is beeing extracted
|
||||
if (outerInstruction instanceof ReadWriteInstruction &&
|
||||
PyForStatementNavigator.getPyForStatementByIterable(outerInstruction.getElement())!=null){
|
||||
errorFound = false;
|
||||
break;
|
||||
PyForStatementNavigator.getPyForStatementByIterable(outerInstruction.getElement())!=null) {
|
||||
// In case when return instruction is inside
|
||||
if (!returnInstructionInside){
|
||||
errorFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (errorFound){
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Conference(object):
|
||||
def __init__(self):
|
||||
self.talks = []
|
||||
|
||||
def getTalkAt(self, hour):
|
||||
for start, end, name in self.talks:
|
||||
<selection>if hour >= start and hour < end: return name</selection>
|
||||
@@ -126,4 +126,9 @@ public class PyExtractMethodTest extends LightMarkedTestCase {
|
||||
public void testClass() throws Throwable {
|
||||
doTest("context/class.before.py", "bar", "context/class.after.py");
|
||||
}
|
||||
|
||||
public void testConditionalReturn() throws Throwable {
|
||||
doTest("conditionalreturn.before.py", "bar", "Cannot perform refactoring when execution flow is interrupted");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user