void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { if (myIsIfStatement) { final PsiElement parent = startElement.getParent(); if (!(parent instanceof PsiIfStatement ifStatement)) return; final PsiExpression condition = PsiUtil.skipParenthesizedExprDown(ifStatement.getCondition()); if (!(condition instanceof PsiBinaryExpression)) return; PsiExpression nullComparedExpression = ExpressionUtils.getValueComparedWithNull((PsiBinaryExpression)condition); if (nullComparedExpression == null) return; PsiNewExpression exception = getThrownNewException(ifStatement.getThenBranch()); if (exception == null) return; PsiExpressionList args = exception.getArgumentList(); PsiExpression message = null; if (args != null) { PsiExpression arg = ArrayUtil.getFirstElement(args.getExpressions()); if (arg != null && TypeUtils.isJavaLangString(arg.getType())) { message = arg; } } CommentTracker tracker = new CommentTracker(); final String text = buildNewExpressionText(tracker.markUnchanged(nullComparedExpression), message); PsiReplacementUtil.replaceStatementAndShortenClassNames(ifStatement, text + ";", tracker); } else { PsiReferenceExpression ref = ObjectUtils.tryCast(startElement.getParent(), PsiReferenceExpression.class); if (ref == null) return; PsiMethodCallExpression methodCall = ObjectUtils.tryCast(ref.getParent(), PsiMethodCallExpression.class); if (!MATCHER.test(methodCall)) { return; } PsiExpression[] args = methodCall.getArgumentList().getExpressions(); if (args.length > 2) return; CommentTracker tracker = new CommentTracker(); final String text = buildNewExpressionText(tracker.markUnchanged(args[0]), (args.length == 2) ? tracker.markUnchanged(args[1]) : null); PsiReplacementUtil.replaceExpressionAndShorten(methodCall, text, tracker); } }