void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiIfStatement ifStatement = tryCast(element.getParent(), PsiIfStatement.class); if (ifStatement == null) return; ElseIf elseIf = ElseIf.from(ifStatement, unwrap(ifStatement.getThenBranch())); if (elseIf == null) return; PsiExpression condition = ifStatement.getCondition(); if (condition == null) return; CommentTracker ct = new CommentTracker(); ct.markUnchanged(elseIf.myElseIfBranchToRemove); ct.markUnchanged(condition); ct.replace(elseIf.myElseBranch, elseIf.myElseIfBranchToKeep); String firstCondition = ParenthesesUtils.getText(condition, ParenthesesUtils.OR_PRECEDENCE); String secondCondition = elseIf.myInvert ? BoolUtils.getNegatedExpressionText(elseIf.myElseIfCondition, ParenthesesUtils.OR_PRECEDENCE, ct) : ParenthesesUtils.getText(ct.markUnchanged(elseIf.myElseIfCondition), ParenthesesUtils.OR_PRECEDENCE); String newCondition = firstCondition + "||" + secondCondition; ct.replaceAndRestoreComments(condition, newCondition); }