fixed PY-11561 "Add super class call" incorrectly inserts parameter annotations

This commit is contained in:
Ekaterina Tuzova
2014-01-24 13:05:47 +04:00
parent acf175234f
commit 37645b447a
4 changed files with 33 additions and 5 deletions
@@ -149,15 +149,15 @@ public class AddCallSuperQuickFix implements LocalQuickFix {
for (int i = 1; i != parameters.length; i++) {
PyParameter p = parameters[i];
if (p.getDefaultValue() != null) continue;
String param;
param = p.getText();
if (param.startsWith("**")) {
final String param = p.getName();
String paramText = p.getText();
if (paramText.startsWith("**")) {
addDouble = true;
if (doubleStarName == null)
doubleStarName = p.getText();
continue;
}
if (param.startsWith("*")) {
if (paramText.startsWith("*")) {
addStar = true;
if (starName == null)
starName = p.getText();
@@ -0,0 +1,8 @@
class Example1:
def __init__(self, field1: str):
self.field1 = field1
class Example2(Example1):
def <warning descr="Call to __init__ of super class is missed">__i<caret>nit__</warning>(self): ## Missed call to __init__ of super class
pass
@@ -0,0 +1,8 @@
class Example1:
def __init__(self, field1: str):
self.field1 = field1
class Example2(Example1):
def __init__(self, field1):
super().__init__(field1)
@@ -270,7 +270,8 @@ public class PyQuickFixTest extends PyTestCase {
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
myFixture.configureByFile("UnresolvedRefNoCreateFunction.py");
myFixture.checkHighlighting(true, false, false);
final IntentionAction intentionAction = myFixture.getAvailableIntention(PyBundle.message("QFIX.unresolved.reference.create.function.$0", "ref"));
final IntentionAction intentionAction = myFixture.getAvailableIntention(
PyBundle.message("QFIX.unresolved.reference.create.function.$0", "ref"));
assertNull(intentionAction);
}
@@ -314,6 +315,17 @@ public class PyQuickFixTest extends PyTestCase {
PyBundle.message("QFIX.add.super"), true, true);
}
public void testAddCallSuperAnnotations() {
runWithLanguageLevel(LanguageLevel.PYTHON33, new Runnable() {
@Override
public void run() {
doInspectionTest("AddCallSuperAnnotations.py",
PyMissingConstructorInspection.class,
PyBundle.message("QFIX.add.super"), true, true);
}
});
}
public void testAddCallSuperPass() { //PY-8654
doInspectionTest("AddCallSuperPass.py", PyMissingConstructorInspection.class,
PyBundle.message("QFIX.add.super"), true, true);