mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
Conflicts: python/testSrc/com/jetbrains/mako/MakoResolveTest.java
This commit is contained in:
@@ -3,14 +3,15 @@ package com.jetbrains.python.actions;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.psi.PyArgumentList;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyKeywordArgument;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -36,14 +37,23 @@ public class RemoveArgumentEqualDefaultQuickFix implements LocalQuickFix {
|
||||
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
PsiElement element = descriptor.getPsiElement();
|
||||
PyExpression[] arguments = PsiTreeUtil.getParentOfType(element, PyArgumentList.class).getArguments();
|
||||
boolean canDelete = true;
|
||||
for (int i = arguments.length-1; i != -1; --i) {
|
||||
if (myProblemElements.contains(arguments[i])) {
|
||||
if (canDelete)
|
||||
arguments[i].delete();
|
||||
|
||||
PyArgumentList argumentList = PsiTreeUtil.getParentOfType(element, PyArgumentList.class);
|
||||
if (argumentList == null) return;
|
||||
StringBuilder newArgumentList = new StringBuilder("foo(");
|
||||
|
||||
PyExpression[] arguments = argumentList.getArguments();
|
||||
List<String> newArgs = new ArrayList<String>();
|
||||
for (int i = 0; i != arguments.length; ++i) {
|
||||
if (!myProblemElements.contains(arguments[i])) {
|
||||
newArgs.add(arguments[i].getText());
|
||||
}
|
||||
else if (!(arguments[i] instanceof PyKeywordArgument)) canDelete = false;
|
||||
}
|
||||
|
||||
newArgumentList.append(StringUtil.join(newArgs, ", ")).append(")");
|
||||
PyExpression expression = PyElementGenerator.getInstance(project).createFromText(
|
||||
LanguageLevel.forElement(argumentList), PyExpressionStatement.class, newArgumentList.toString()).getExpression();
|
||||
if (expression instanceof PyCallExpression)
|
||||
argumentList.replace(((PyCallExpression)expression).getArgumentList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ public class PyRedundantParenthesesInspection extends PyInspection {
|
||||
registerProblem(node, "Remove redundant parentheses", new RedundantParenthesesQuickFix());
|
||||
}
|
||||
else if (expression instanceof PyBinaryExpression) {
|
||||
if (node.getParent() instanceof PyPrefixExpression)
|
||||
return;
|
||||
if (((PyBinaryExpression)expression).getOperator() == PyTokenTypes.AND_KEYWORD ||
|
||||
((PyBinaryExpression)expression).getOperator() == PyTokenTypes.OR_KEYWORD) {
|
||||
if (((PyBinaryExpression)expression).getLeftExpression() instanceof PyParenthesizedExpression &&
|
||||
|
||||
@@ -2,4 +2,5 @@ def foo(a, b = 345, c = 1):
|
||||
pass
|
||||
|
||||
#PY-3261
|
||||
foo(1, <warning descr="Argument equals to default parameter value">345<caret></warning>, c=22)
|
||||
foo(1,
|
||||
<warning descr="Argument equals to default parameter value">345<caret></warning>, c=22)
|
||||
@@ -58,3 +58,12 @@ def bar(a = "qwer"):
|
||||
bar(<warning descr="Argument equals to default parameter value">a = 'qwer'</warning>)
|
||||
|
||||
getattr(bar, "__doc__", None) # None is not highlighted
|
||||
|
||||
class a:
|
||||
def get(self, a, b = None):
|
||||
pass
|
||||
|
||||
kw = a()
|
||||
|
||||
kw['customerPaymentProfileId'] = kw.get("customerPaymentProfileId",
|
||||
<warning descr="Argument equals to default parameter value">None</warning>)
|
||||
|
||||
Reference in New Issue
Block a user