void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { if (!(startElement instanceof PsiExpression expression)) return; final OrderedBinaryExpression<PsiMethodCallExpression, PsiExpression> orderedBinaryExpression = OrderedBinaryExpression.from(expression, PsiMethodCallExpression.class); if (orderedBinaryExpression == null) { return; } final PsiMethodCallExpression methodCallExpression = orderedBinaryExpression.getFirstOperand(); final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); final PsiExpression qualifierExpression = methodExpression.getQualifierExpression(); if (qualifierExpression == null) { return; } CommentTracker commentTracker = new CommentTracker(); @NonNls String newExpression = commentTracker.text(qualifierExpression); final Object object = ExpressionUtils.computeConstantExpression(orderedBinaryExpression.getSecondOperand()); if (!(object instanceof Integer) && !(object instanceof Long)) { return; } int comparedValue = ((Number)object).intValue(); if ((comparedValue == 0 && !JavaTokenType.EQEQ.equals(orderedBinaryExpression.getTokenType())) || (comparedValue == 1 && !JavaTokenType.LT.equals(orderedBinaryExpression.getTokenType()))) { newExpression = '!' + newExpression; } newExpression += ".isEmpty()"; PsiReplacementUtil.replaceExpression(expression, newExpression, commentTracker); }