mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-6678 Assignment can be replace with augmented assignment: does nothing if there is a function in the assignment
This commit is contained in:
@@ -63,9 +63,9 @@ public class AugmentedAssignmentQuickFix implements LocalQuickFix {
|
||||
|
||||
if ((leftExpression instanceof PyReferenceExpression || leftExpression instanceof PySubscriptionExpression)) {
|
||||
if (leftExpression.getText().equals(targetText)) {
|
||||
if (rightExpression instanceof PyNumericLiteralExpression || rightExpression instanceof PyStringLiteralExpression
|
||||
|| rightExpression instanceof PyReferenceExpression || isPercentage(rightExpression) || isCompound(rightExpression)
|
||||
|| isMathOperation(rightExpression, expression.getOperator())) {
|
||||
if (rightExpression instanceof PyNumericLiteralExpression || rightExpression instanceof PyStringLiteralExpression ||
|
||||
rightExpression instanceof PyCallExpression || rightExpression instanceof PyReferenceExpression
|
||||
|| isPercentage(rightExpression) || isCompound(rightExpression) || isMathOperation(rightExpression, expression.getOperator())) {
|
||||
|
||||
final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
def retStr():
|
||||
return ''
|
||||
|
||||
s1 = ''
|
||||
<weak_warning descr="Assignment can be replaced with augmented assignment">s1 = s1 <caret>+ retStr()</weak_warning>
|
||||
@@ -0,0 +1,5 @@
|
||||
def retStr():
|
||||
return ''
|
||||
|
||||
s1 = ''
|
||||
s1 += retStr()
|
||||
@@ -236,6 +236,11 @@ public class PyQuickFixTest extends PyTestCase {
|
||||
PyBundle.message("QFIX.augment.assignment"), true, true);
|
||||
}
|
||||
|
||||
public void testAugmentAssignmentFunction() { // PY-6678
|
||||
doInspectionTest("AugmentAssignmentFunction.py", PyAugmentAssignmentInspection.class,
|
||||
PyBundle.message("QFIX.augment.assignment"), true, true);
|
||||
}
|
||||
|
||||
public void testChainedComparisons() { // PY-1020
|
||||
doInspectionTest("ChainedComparisons.py", PyChainedComparisonsInspection.class,
|
||||
PyBundle.message("QFIX.chained.comparison"), true, true);
|
||||
|
||||
Reference in New Issue
Block a user