PY-4082: correctly map things like (*args, a=... b=...) in Py3k.

This commit is contained in:
Dmitry Cheryasov
2011-07-06 19:43:20 +03:00
parent 978ff217fc
commit fc7349602d
3 changed files with 16 additions and 2 deletions
@@ -455,8 +455,10 @@ public class PyCallExpressionHelper {
if (n_par.isPositionalContainer()) tuple_par = n_par;
else if (n_par.isKeywordContainer()) kwd_par = n_par;
else {
slots.put(n_par, null); // regular parameter that may serve as positional
positional_index += 1;
slots.put(n_par, null); // regular parameter that may serve as positional/named
if (tuple_par == null && kwd_par == null) {
positional_index += 1; // only if we're not past *param / **param
}
}
}
else {
@@ -0,0 +1,4 @@
def foo(*arg, a=1, b=2):
pass
foo(<arg1>1, <arg2>2, <arg3>b=10, <arg4>a=20)
@@ -356,6 +356,14 @@ public class PyParameterInfoTest extends LightMarkedTestCase {
feignCtrlP(marks.get("<arg2>").getTextOffset()).check("a, b, c=1, d=2, e=3", new String[]{}); // no logical next
}
public void testPy3kPastTupleArg() {
Map<String, PsiElement> marks = loadTest(4);
feignCtrlP(marks.get("<arg1>").getTextOffset()).check("*arg, a=1, b=2", new String[]{"*arg, "});
feignCtrlP(marks.get("<arg2>").getTextOffset()).check("*arg, a=1, b=2", new String[]{"*arg, "});
feignCtrlP(marks.get("<arg3>").getTextOffset()).check("*arg, a=1, b=2", new String[]{"b=2"});
feignCtrlP(marks.get("<arg4>").getTextOffset()).check("*arg, a=1, b=2", new String[]{"a=1, "});
}
/**
* Imitates pressing of Ctrl+P; fails if results are not as expected.
* @param offset offset of 'cursor' where ^P is pressed.