void (@NotNull PsiBinaryExpression expression) { super.visitBinaryExpression(expression); if (!ComparisonUtils.isComparison(expression)) { return; } final OrderedBinaryExpression<PsiMethodCallExpression, PsiExpression> orderedBinaryExpression = OrderedBinaryExpression.from(expression, PsiMethodCallExpression.class); if (orderedBinaryExpression == null) { return; } final PsiMethodCallExpression callExpression = orderedBinaryExpression.getFirstOperand(); @NonNls String isEmptyCall = null; final PsiReferenceExpression methodExpression = callExpression.getMethodExpression(); final String referenceName = methodExpression.getReferenceName(); if (!HardcodedMethodConstants.SIZE.equals(referenceName) && !HardcodedMethodConstants.LENGTH.equals(referenceName)) { return; } if (!callExpression.getArgumentList().isEmpty()) { return; } final PsiExpression qualifierExpression = methodExpression.getQualifierExpression(); if (qualifierExpression == null) { return; } final PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(qualifierExpression.getType()); if (aClass == null || PsiTreeUtil.isAncestor(aClass, callExpression, true)) { return; } for (String ignoredType : ignoredTypes) { if (InheritanceUtil.isInheritor(aClass, ignoredType)) { return; } } for (PsiMethod method : aClass.findMethodsByName("isEmpty", true)) { final PsiParameterList parameterList = method.getParameterList(); if (parameterList.isEmpty() && isLanguageLevelCompatible(expression, method)) { isEmptyCall = qualifierExpression.getText() + ".isEmpty()"; break; } } if (isEmptyCall == null) { return; } final Object object = ExpressionUtils.computeConstantExpression(orderedBinaryExpression.getSecondOperand()); if (!(object instanceof Integer) && !(object instanceof Long)) { return; } int comparedValue = ((Number)object).intValue(); if (comparedValue == 0) { final IElementType tokenType = orderedBinaryExpression.getTokenType(); if (JavaTokenType.EQEQ.equals(tokenType)) { registerError(expression, isEmptyCall, qualifierExpression, referenceName); } if (ignoreNegations) { return; } if (JavaTokenType.NE.equals(tokenType) || JavaTokenType.GT.equals(tokenType)) { registerError(expression, '!' + isEmptyCall, qualifierExpression, referenceName); } } else if (comparedValue == 1) { final IElementType tokenType = orderedBinaryExpression.getTokenType(); if (JavaTokenType.LT.equals(tokenType)) { registerError(expression, isEmptyCall, qualifierExpression, referenceName); } if (ignoreNegations) { return; } if (JavaTokenType.GE.equals(tokenType)) { registerError(expression, '!' + isEmptyCall, qualifierExpression, referenceName); } } }