mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SizeReplaceableByIsEmpty: support parentheses
This commit is contained in:
+4
-4
@@ -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;
|
||||
|
||||
+4
@@ -17,6 +17,10 @@ public class SizeReplaceableByIsEmpty {
|
||||
return <warning descr="'c.size() == 0' can be replaced with 'c.isEmpty()'">c.size() == 0</warning>;
|
||||
}
|
||||
|
||||
boolean parens(Collection c) {
|
||||
return <warning descr="'(c.size()) == (0)' can be replaced with 'c.isEmpty()'">(c.size()) == (0)</warning>;
|
||||
}
|
||||
|
||||
class String {
|
||||
public int length() {
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user