mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-2102 Extract method fails
This commit is contained in:
@@ -7,6 +7,7 @@ import com.intellij.codeInsight.codeFragment.Position;
|
||||
import com.intellij.codeInsight.controlflow.ConditionalInstruction;
|
||||
import com.intellij.codeInsight.controlflow.Instruction;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
@@ -83,6 +84,10 @@ public class PyCodeFragmentUtil {
|
||||
if (nextElement instanceof PyExceptPart){
|
||||
continue;
|
||||
}
|
||||
// We allow raise statements in code
|
||||
if (nextElement == null && PsiTreeUtil.getParentOfType(element, PyRaiseStatement.class) != null){
|
||||
continue;
|
||||
}
|
||||
if (!CodeFragmentUtil.elementFit(nextElement, start, end)){
|
||||
outerInstructions.add(next);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
foo()
|
||||
<begin>
|
||||
for i in range(l):
|
||||
if foo:
|
||||
if tag is None:
|
||||
if bar:
|
||||
do
|
||||
else:
|
||||
if baz:
|
||||
raise ValueError(i)
|
||||
else:
|
||||
bzzzz
|
||||
<end>
|
||||
bar()
|
||||
<result>
|
||||
In:
|
||||
Out:
|
||||
@@ -159,5 +159,10 @@ public class PyCodeFragmentTest extends LightMarkedTestCase {
|
||||
public void testForIfReturn() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRaise2102() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user