void (PsiJavaToken token) { final PsiIfStatement parentStatement = (PsiIfStatement)token.getParent(); assert parentStatement != null; final PsiIfStatement childStatement = (PsiIfStatement)parentStatement.getElseBranch(); if (childStatement == null) { return; } final PsiExpression childCondition = childStatement.getCondition(); if (childCondition == null) { return; } CommentTracker tracker = new CommentTracker(); final String childConditionText = tracker.text(childCondition, ParenthesesUtils.OR_PRECEDENCE); final PsiExpression condition = parentStatement.getCondition(); if (condition == null) { return; } final String parentConditionText = tracker.text(condition, ParenthesesUtils.OR_PRECEDENCE); final PsiStatement parentThenBranch = parentStatement.getThenBranch(); if (parentThenBranch == null) { return; } final String parentThenBranchText = tracker.text(parentThenBranch); @NonNls final StringBuilder statement = new StringBuilder(); statement.append("if("); statement.append(parentConditionText); statement.append("||"); statement.append(childConditionText); statement.append(')'); statement.append(parentThenBranchText); final PsiStatement childElseBranch = childStatement.getElseBranch(); if (childElseBranch != null) { statement.append("\nelse "); statement.append(tracker.text(childElseBranch)); } PsiReplacementUtil.replaceStatement(parentStatement, statement.toString(), tracker); }