diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/SizeReplaceableByIsEmptyInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/SizeReplaceableByIsEmptyInspection.java index 7d35fe68211d..2fde98ff746a 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/style/SizeReplaceableByIsEmptyInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/SizeReplaceableByIsEmptyInspection.java @@ -93,9 +93,9 @@ public class SizeReplaceableByIsEmptyInspection extends BaseInspection { @Override protected void doFix(Project project, ProblemDescriptor descriptor) { final PsiBinaryExpression binaryExpression = (PsiBinaryExpression)descriptor.getPsiElement(); - PsiExpression operand = binaryExpression.getLOperand(); + PsiExpression operand = PsiUtil.skipParenthesizedExprDown(binaryExpression.getLOperand()); if (!(operand instanceof PsiMethodCallExpression)) { - operand = binaryExpression.getROperand(); + operand = PsiUtil.skipParenthesizedExprDown(binaryExpression.getROperand()); } if (!(operand instanceof PsiMethodCallExpression)) { return; @@ -131,8 +131,8 @@ public class SizeReplaceableByIsEmptyInspection extends BaseInspection { if (!ComparisonUtils.isComparison(expression)) { return; } - final PsiExpression rhs = expression.getROperand(); - final PsiExpression lhs = expression.getLOperand(); + final PsiExpression rhs = PsiUtil.skipParenthesizedExprDown(expression.getROperand()); + final PsiExpression lhs = PsiUtil.skipParenthesizedExprDown(expression.getLOperand()); final boolean flipped; if (lhs instanceof PsiMethodCallExpression) { flipped = false; diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/size_replaceable_by_is_empty/SizeReplaceableByIsEmpty.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/size_replaceable_by_is_empty/SizeReplaceableByIsEmpty.java index 5ff6da093c62..144b1e010237 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/size_replaceable_by_is_empty/SizeReplaceableByIsEmpty.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/size_replaceable_by_is_empty/SizeReplaceableByIsEmpty.java @@ -17,6 +17,10 @@ public class SizeReplaceableByIsEmpty { return c.size() == 0; } + boolean parens(Collection c) { + return (c.size()) == (0); + } + class String { public int length() { return 1;