mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-12920 **kwargs in constructor parameters disappear after "Add super class call" quick fix
This commit is contained in:
@@ -24,6 +24,7 @@ import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -139,7 +140,7 @@ public class AddCallSuperQuickFix implements LocalQuickFix {
|
||||
private static void addParametersFromSuper(@NotNull final PyFunction superInit, @NotNull final StringBuilder superCall,
|
||||
@NotNull final StringBuilder newFunction, boolean addComma,
|
||||
@NotNull final List<String> problemParams, @NotNull final List<String> functionParams,
|
||||
String starName, String doubleStarName) {
|
||||
@Nullable String starName, @Nullable String doubleStarName) {
|
||||
final PyParameterList paramList = superInit.getParameterList();
|
||||
PyParameter[] parameters = paramList.getParameters();
|
||||
boolean addDouble = false;
|
||||
@@ -170,16 +171,20 @@ public class AddCallSuperQuickFix implements LocalQuickFix {
|
||||
}
|
||||
for(String p : problemParams)
|
||||
newFunction.append(",").append(p);
|
||||
if (addStar) {
|
||||
if (starName != null) {
|
||||
newFunction.append(",").append(starName);
|
||||
if (addComma) superCall.append(",");
|
||||
superCall.append(starName);
|
||||
addComma = true;
|
||||
if (addStar) {
|
||||
if (addComma) superCall.append(",");
|
||||
superCall.append(starName);
|
||||
addComma = true;
|
||||
}
|
||||
}
|
||||
if (addDouble) {
|
||||
if (addComma) superCall.append(",");
|
||||
superCall.append(doubleStarName);
|
||||
if (doubleStarName != null) {
|
||||
newFunction.append(",").append(doubleStarName);
|
||||
if (addDouble) {
|
||||
if (addComma) superCall.append(",");
|
||||
superCall.append(doubleStarName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class A(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
class B(A):
|
||||
def <warning descr="Call to __init__ of super class is missed">__in<caret>it__</warning>(self, **kwargs):
|
||||
pass
|
||||
@@ -0,0 +1,7 @@
|
||||
class A(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
class B(A):
|
||||
def __init__(self, **kwargs):
|
||||
super(B, self).__init__()
|
||||
@@ -30,4 +30,8 @@ public class AddCallSuperQuickFixTest extends PyQuickFixTestCase {
|
||||
public void testNewStyle() {
|
||||
doQuickFixTest(PyMissingConstructorInspection.class, PyBundle.message("QFIX.add.super"));
|
||||
}
|
||||
|
||||
public void testKwargs() {
|
||||
doQuickFixTest(PyMissingConstructorInspection.class, PyBundle.message("QFIX.add.super"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user