mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
complete keyword arguments taken from __init__ of superclass (PY-505)
This commit is contained in:
@@ -505,18 +505,13 @@ public class PyReferenceExpressionImpl extends PyElementImpl implements PyRefere
|
||||
if (callee instanceof PyReferenceExpression) {
|
||||
PsiElement def = ((PyReferenceExpression)callee).resolve();
|
||||
if (def instanceof PyFunction) {
|
||||
((PyFunction)def).getParameterList().acceptChildren(
|
||||
new PyElementVisitor() {
|
||||
@Override
|
||||
public void visitPyParameter(PyParameter par) {
|
||||
PyNamedParameter n_param = par.getAsNamed();
|
||||
assert n_param != null;
|
||||
if (! n_param.isKeywordContainer() && ! n_param.isPositionalContainer()) {
|
||||
ret.add(LookupElementBuilder.create(n_param.getName() + "=").setIcon(n_param.getIcon(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
addKeywordArgumentVariants((PyFunction) def, ret);
|
||||
}
|
||||
else if (def instanceof PyClass) {
|
||||
PyFunction init = ((PyClass) def).findMethodByName(PyNames.INIT, true); // search in superclasses
|
||||
if (init != null) {
|
||||
addKeywordArgumentVariants(init, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -552,6 +547,21 @@ public class PyReferenceExpressionImpl extends PyElementImpl implements PyRefere
|
||||
return ret.toArray();
|
||||
}
|
||||
|
||||
private static void addKeywordArgumentVariants(PyFunction def, final List<Object> ret) {
|
||||
def.getParameterList().acceptChildren(
|
||||
new PyElementVisitor() {
|
||||
@Override
|
||||
public void visitPyParameter(PyParameter par) {
|
||||
PyNamedParameter n_param = par.getAsNamed();
|
||||
assert n_param != null;
|
||||
if (! n_param.isKeywordContainer() && ! n_param.isPositionalContainer()) {
|
||||
ret.add(LookupElementBuilder.create(n_param.getName() + "=").setIcon(n_param.getIcon(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public boolean isSoft() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class C:
|
||||
def __init__(self, auno=True): pass
|
||||
|
||||
c = C(auno=)
|
||||
@@ -0,0 +1,4 @@
|
||||
class C:
|
||||
def __init__(self, auno=True): pass
|
||||
|
||||
c = C(au<caret>)
|
||||
@@ -0,0 +1,7 @@
|
||||
class B:
|
||||
def __init__(self, auno=True): pass
|
||||
|
||||
class C(B):
|
||||
pass
|
||||
|
||||
c = C(auno=)
|
||||
@@ -0,0 +1,7 @@
|
||||
class B:
|
||||
def __init__(self, auno=True): pass
|
||||
|
||||
class C(B):
|
||||
pass
|
||||
|
||||
c = C(au<caret>)
|
||||
@@ -35,6 +35,14 @@ public class PythonCompletionTest extends PyLightFixtureTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInitParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSuperInitParams() throws Exception { // PY-505
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPredefinedMethodName() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user