mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-16348 Preserve line comments inside the body of updated constructor
This commit is contained in:
@@ -116,12 +116,16 @@ public class AddCallSuperQuickFix implements LocalQuickFix {
|
||||
}
|
||||
newFunction.append(superCall).append("\n\t");
|
||||
boolean first = true;
|
||||
for (PyStatement statement : statementList.getStatements()) {
|
||||
if (first && docstring != null || statement instanceof PyPassStatement) {
|
||||
first = false;
|
||||
continue;
|
||||
for (PsiElement child = statementList.getFirstChild(); child != null; child = child.getNextSibling()) {
|
||||
if (child instanceof PyStatement) {
|
||||
if (first && docstring != null || child instanceof PyPassStatement) {
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (child instanceof PyStatement || child instanceof PsiComment) {
|
||||
newFunction.append(child.getText()).append("\n\t");
|
||||
}
|
||||
newFunction.append(statement.getText()).append("\n\t");
|
||||
}
|
||||
|
||||
final PyElementGenerator generator = PyElementGenerator.getInstance(project);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class A:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
class B(A):
|
||||
def <warning descr="Call to __init__ of super class is missed">__in<caret>it__</warning>(self):
|
||||
# comment #1
|
||||
pass
|
||||
# comment #2
|
||||
print 42
|
||||
@@ -0,0 +1,11 @@
|
||||
class A:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
class B(A):
|
||||
def __init__(self):
|
||||
A.__init__(self)
|
||||
# comment #1
|
||||
# comment #2
|
||||
print 42
|
||||
@@ -379,6 +379,11 @@ public class PyQuickFixTest extends PyTestCase {
|
||||
doInspectionTest(PyMissingConstructorInspection.class, PyBundle.message("QFIX.add.super"), true, true);
|
||||
}
|
||||
|
||||
// PY-16348
|
||||
public void testAddCallSuperCommentsInFunctionBodyPreserved() {
|
||||
doInspectionTest(PyMissingConstructorInspection.class, PyBundle.message("QFIX.add.super"), true, true);
|
||||
}
|
||||
|
||||
// PY-491, PY-13297
|
||||
public void testAddEncoding() {
|
||||
doInspectionTest(PyMandatoryEncodingInspection.class, PyBundle.message("QFIX.add.encoding"), true, true);
|
||||
|
||||
Reference in New Issue
Block a user