mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
fixed PY-9406 Make function from method: when removing last method from class add pass statement
This commit is contained in:
@@ -36,11 +36,14 @@ public class PyMakeFunctionFromMethodQuickFix implements LocalQuickFix {
|
||||
final PyClass containingClass = problemFunction.getContainingClass();
|
||||
if (containingClass == null) return;
|
||||
|
||||
if (!PyUtil.deleteParameter(problemFunction, 0)) return;
|
||||
PyUtil.deleteParameter(problemFunction, 0);
|
||||
|
||||
final PsiElement copy = problemFunction.copy();
|
||||
final PyStatementList classStatementList = containingClass.getStatementList();
|
||||
classStatementList.deleteChildRange(problemFunction, problemFunction);
|
||||
if (classStatementList.getStatements().length < 1) {
|
||||
classStatementList.add(PyElementGenerator.getInstance(project).createPassStatement());
|
||||
}
|
||||
final PsiFile file = containingClass.getContainingFile();
|
||||
file.addAfter(copy, containingClass);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
__author__ = 'ktisha'
|
||||
|
||||
class Child(Base):
|
||||
def <caret>f(self):
|
||||
test = 1
|
||||
@@ -0,0 +1,8 @@
|
||||
__author__ = 'ktisha'
|
||||
|
||||
class Child(Base):
|
||||
pass
|
||||
|
||||
|
||||
def f():
|
||||
test = 1
|
||||
@@ -0,0 +1,5 @@
|
||||
__author__ = 'ktisha'
|
||||
|
||||
class Child(Base):
|
||||
def <caret>f():
|
||||
test = 1
|
||||
@@ -0,0 +1,8 @@
|
||||
__author__ = 'ktisha'
|
||||
|
||||
class Child(Base):
|
||||
pass
|
||||
|
||||
|
||||
def f():
|
||||
test = 1
|
||||
@@ -24,4 +24,12 @@ public class PyMakeFunctionFromMethodQuickFixTest extends PyQuickFixTestCase {
|
||||
doInspectionTest(PyMethodMayBeStaticInspection.class, PyBundle.message("QFIX.NAME.make.function"));
|
||||
}
|
||||
|
||||
public void testEmptyStatementList() {
|
||||
doInspectionTest(PyMethodMayBeStaticInspection.class, PyBundle.message("QFIX.NAME.make.function"));
|
||||
}
|
||||
|
||||
public void testNoSelf() {
|
||||
doInspectionTest(PyMethodMayBeStaticInspection.class, PyBundle.message("QFIX.NAME.make.function"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user