void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { final PsiReferenceExpression expression = PsiTreeUtil.getParentOfType(startElement, PsiReferenceExpression.class); if (expression == null) return; final PsiMethodCallExpression call = (PsiMethodCallExpression)expression.getParent(); final PsiExpression[] arguments = call.getArgumentList().getExpressions(); if (arguments.length == 0) return; final PsiExpression qualifier = expression.getQualifierExpression(); if (qualifier == null) return; final PsiExpression argument = arguments[0]; final PsiExpression checkedExpression; if (ExpressionUtils.isEmptyStringLiteral(argument)) { checkedExpression = getCheckedExpression(myUseIsEmpty, qualifier); } else { checkedExpression = getCheckedExpression(myUseIsEmpty, argument); } final @NonNls StringBuilder newExpression; CommentTracker ct = new CommentTracker(); final PsiExpression parent = ObjectUtils.tryCast(call.getParent(), PsiExpression.class); final boolean isNegation = parent != null && BoolUtils.isNegation(parent); if (myAddNullCheck) { newExpression = new StringBuilder(ct.text(checkedExpression, ParenthesesUtils.EQUALITY_PRECEDENCE)); newExpression.append(isNegation ? "==null||" : "!=null&&"); } else { newExpression = new StringBuilder(); } final PsiExpression expressionToReplace; String expressionText = ct.text(checkedExpression, ParenthesesUtils.METHOD_CALL_PRECEDENCE); if (isNegation) { expressionToReplace = parent; if (myUseIsEmpty) { newExpression.append('!').append(expressionText).append(".isEmpty()"); } else { newExpression.append(expressionText).append(".length()!=0"); } } else { expressionToReplace = call; if (myUseIsEmpty) { newExpression.append(expressionText).append(".isEmpty()"); } else { newExpression.append(expressionText).append(".length()==0"); } } PsiReplacementUtil.replaceExpression(expressionToReplace, newExpression.toString(), ct); }