mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-42772 Impl filtering positional only arguments
GitOrigin-RevId: 978dd1f4970d5b1aaa94e251cbf81dee51f2f36c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
23b93e58f8
commit
edbd512159
@@ -1841,6 +1841,21 @@ public abstract class PythonCommonCompletionTest extends PythonCommonTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
// PY-42772
|
||||
public void testNoPositionalOnlyArgumentsSuggestion() {
|
||||
runWithLanguageLevel(
|
||||
LanguageLevel.getLatest(),
|
||||
() -> {
|
||||
List<String> suggested = doTestByText("def foo(argument_1, /, argument_2):\n" +
|
||||
" pass\n" +
|
||||
"\n" +
|
||||
"foo(<caret>)");
|
||||
assertContainsElements(suggested, "argument_2=");
|
||||
assertDoesntContain(suggested, "argument_1=");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void doTestHasattrContributor(String[] inList, String[] notInList) {
|
||||
doTestHasattrContributor("hasattrCompletion/" + getTestName(true) + ".py", inList, notInList);
|
||||
}
|
||||
|
||||
+11
-2
@@ -59,7 +59,8 @@ public class KeywordArgumentCompletionUtil {
|
||||
if (type.isCallable()) {
|
||||
final List<PyCallableParameter> parameters = type.getParameters(context);
|
||||
if (parameters != null) {
|
||||
for (PyCallableParameter parameter : parameters) {
|
||||
int indexOfPySlashParameter = getIndexOfPySlashParameter(parameters);
|
||||
for (PyCallableParameter parameter : parameters.subList(indexOfPySlashParameter + 1, parameters.size())) {
|
||||
if (parameter.isKeywordContainer() || parameter.isPositionalContainer()) {
|
||||
continue;
|
||||
}
|
||||
@@ -86,6 +87,10 @@ public class KeywordArgumentCompletionUtil {
|
||||
return result.getElement();
|
||||
}
|
||||
|
||||
private static int getIndexOfPySlashParameter(@NotNull List<PyCallableParameter> parameters) {
|
||||
return ContainerUtil.indexOf(parameters, parameter -> parameter.getParameter() instanceof PySlashParameter);
|
||||
}
|
||||
|
||||
private static void addKeywordArgumentVariantsForFunction(@NotNull final PyCallExpression callExpr,
|
||||
@NotNull final PyFunction function,
|
||||
@NotNull final List<String> ret,
|
||||
@@ -98,8 +103,12 @@ public class KeywordArgumentCompletionUtil {
|
||||
boolean needSelf = function.getContainingClass() != null && function.getModifier() != PyFunction.Modifier.STATICMETHOD;
|
||||
final KwArgParameterCollector collector = new KwArgParameterCollector(needSelf, ret);
|
||||
|
||||
List<PyCallableParameter> parameters = function.getParameters(context);
|
||||
int indexOfPySlashParameter = getIndexOfPySlashParameter(parameters);
|
||||
|
||||
StreamEx
|
||||
.of(function.getParameters(context))
|
||||
.of(parameters)
|
||||
.skip(indexOfPySlashParameter + 1)
|
||||
.map(PyCallableParameter::getParameter)
|
||||
.nonNull()
|
||||
.forEach(parameter -> parameter.accept(collector));
|
||||
|
||||
Reference in New Issue
Block a user