void (PsiIfStatement ifStatement, PsiStatement[] thenStatements, PsiStatement[] elseStatements) { ImplicitElse implicitElse = ImplicitElse.from(thenStatements, elseStatements, ifStatement); if (implicitElse == null) return; PsiIfStatement ifToDelete = implicitElse.myIfToDelete; CommentTracker ct = new CommentTracker(); PsiElement parent = ifToDelete.getParent(); if(ifToDelete == ifStatement) { // Only in this case condition may contains side effect PsiExpression condition = ifToDelete.getCondition(); if(condition == null) return; ct.markUnchanged(condition); List<PsiExpression> sideEffectExpressions = SideEffectChecker.extractSideEffectExpressions(condition); PsiStatement[] sideEffectStatements = StatementExtractor.generateStatements(sideEffectExpressions, condition); for (int statementIndex = sideEffectStatements.length - 1; statementIndex >= 0; statementIndex--) { PsiStatement statement = sideEffectStatements[statementIndex]; parent.addAfter(statement, ifToDelete); } } ct.deleteAndRestoreComments(ifToDelete); }