parameter info works for inherited class constructors (PY-256)

This commit is contained in:
Dmitry Jemerov
2010-03-16 20:24:49 +03:00
parent c9bb113e46
commit 08b5f44df2
3 changed files with 17 additions and 1 deletions
@@ -88,7 +88,7 @@ public class PyCallExpressionHelper {
if (callee instanceof PyReferenceExpression) {
PyReferenceExpression ref = (PyReferenceExpression)callee;
PsiElement resolved = ref.followAssignmentsChain();
if (resolved instanceof PyClass) resolved = ((PyClass)resolved).findMethodByName(PyNames.INIT, false); // class to constructor call
if (resolved instanceof PyClass) resolved = ((PyClass)resolved).findMethodByName(PyNames.INIT, true); // class to constructor call
else if (resolved instanceof PyCallExpression) {
// is it a case of "foo = classmethod(foo)"?
PyCallExpression redefining_call = (PyCallExpression)resolved;
@@ -0,0 +1,8 @@
class Bar:
def __init__(self, a, b):
pass
class Bambr(Bar):
pass
Bambr(<arg1>1, <arg2>2)
@@ -239,6 +239,14 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
feignCtrlP(marks.get("<arg2>").getTextOffset()).check("self,a,b", new String[]{"b"}, new String[]{"self,"});
}
public void testInheritedClassInit() throws Exception {
Map<String, PsiElement> marks = loadTest();
assertEquals("Test data sanity", marks.size(), 2);
feignCtrlP(marks.get("<arg1>").getTextOffset()).check("self,a,b", new String[]{"a,"}, new String[]{"self,"});
feignCtrlP(marks.get("<arg2>").getTextOffset()).check("self,a,b", new String[]{"b"}, new String[]{"self,"});
}
// TODO: add method tests with decorators when a mock SDK is available
/**