mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-1086 False positive for "Cannot perform refactoring when execution flow is interrupted"
This commit is contained in:
@@ -92,9 +92,23 @@ public class PyCodeFragmentUtil {
|
||||
}
|
||||
|
||||
// If we see more than 1 outer instruction, controlflow is interrupted
|
||||
if (outerInstructions.size() > 1){
|
||||
if (outerInstructions.size() > 2){
|
||||
throw new CannotCreateCodeFragmentException(PyBundle.message("refactoring.extract.method.error.cannot.perform.refactoring.when.execution.flow.is.interrupted"));
|
||||
}
|
||||
if (outerInstructions.size() == 2){
|
||||
boolean errorFound = true;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (errorFound){
|
||||
throw new CannotCreateCodeFragmentException(PyBundle.message("refactoring.extract.method.error.cannot.perform.refactoring.when.execution.flow.is.interrupted"));
|
||||
}
|
||||
}
|
||||
|
||||
// Building code fragment
|
||||
final PyCodeFragmentBuilder builder = new PyCodeFragmentBuilder(owner, start, end);
|
||||
|
||||
Reference in New Issue
Block a user