use of com.jetbrains.python.inspections.quickfix.PyRenameArgumentQuickFix in project intellij-community by JetBrains.
the class PyArgumentListInspection method highlightUnexpectedArguments.
private static void highlightUnexpectedArguments(@NotNull PyArgumentList node, @NotNull ProblemsHolder holder, @NotNull List<PyCallExpression.PyArgumentsMapping> mappings, @NotNull TypeEvalContext context) {
if (mappings.isEmpty() || mappings.stream().anyMatch(mapping -> mapping.getUnmappedArguments().isEmpty()))
return;
if (mappings.size() == 1) {
// if there is only one mapping, we could suggest quick fixes
final Set<String> duplicateKeywords = getDuplicateKeywordArguments(node);
for (PyExpression argument : mappings.get(0).getUnmappedArguments()) {
final List<LocalQuickFix> quickFixes = Lists.newArrayList(new PyRemoveArgumentQuickFix());
if (argument instanceof PyKeywordArgument) {
if (duplicateKeywords.contains(((PyKeywordArgument) argument).getKeyword())) {
continue;
}
quickFixes.add(new PyRenameArgumentQuickFix());
}
holder.registerProblem(argument, PyBundle.message("INSP.unexpected.arg"), quickFixes.toArray(new LocalQuickFix[quickFixes.size() - 1]));
}
} else {
// all mappings have unmapped arguments so we couldn't determine desired argument list and suggest appropriate quick fixes
holder.registerProblem(node, addPossibleCalleesRepresentationAndWrapInHtml(PyBundle.message("INSP.unexpected.arg(s)"), mappings, context));
}
}
Aggregations