void (@NotNull PsiConditionalLoopStatement loop) { CommentTracker ct = new CommentTracker(); String loopText; if (ControlFlowUtils.isEndlessLoop(loop)) { String conditionForWhile = this.conditionInThen ? BoolUtils.getNegatedExpressionText(this.condition, ct) : ct.text( this.condition); LoopTransformationFix.pullDownStatements(this.statement, this.conditionInThen ? this.statement.getElseBranch() : this.statement.getThenBranch()); ct.delete(this.statement); loopText = this.conditionInTheBeginning ? "while(" + conditionForWhile + ")" + ct.text(this.loopBody) : "do" + ct.text(this.loopBody) + "while(" + conditionForWhile + ");"; } else { String conditionForWhile = this.conditionInThen ? BoolUtils.getNegatedExpressionText(this.condition, ParenthesesUtils.AND_PRECEDENCE, ct) : ct.text( this.condition, ParenthesesUtils.AND_PRECEDENCE); ct.delete(this.statement); PsiExpression loopCondition = loop.getCondition(); assert loopCondition != null; loopText = this.conditionInTheBeginning ? "while(" + ct.text(loopCondition, ParenthesesUtils.AND_PRECEDENCE) + " && " + conditionForWhile + ")" + ct.text( this.loopBody) : "do" + ct.text(this.loopBody) + "while(" + conditionForWhile + " && " + ct.text(loopCondition, ParenthesesUtils.AND_PRECEDENCE) + ");"; } ct.replaceAndRestoreComments(this.loopStatement, loopText); }