PsiStatement (PsiIfStatement ifStatement, String... operators) { IfConditionalModel model = IfConditionalModel.from(ifStatement, false); if (model == null) return null; ConditionalExpressionGenerator generator = ConditionalExpressionGenerator.from(model); if (generator == null) return null; String operator = generator.getTokenType(); if (!ArrayUtil.contains(operator, operators)) return null; CommentTracker commentTracker = new CommentTracker(); String conditional = generator.generate(commentTracker); commentTracker.replace(model.getThenExpression(), conditional); PsiStatement branch = model.getElseBranch(); if (!PsiTreeUtil.isAncestor(ifStatement, branch, true)) { commentTracker.delete(branch); } return (PsiStatement)commentTracker.replaceAndRestoreComments(ifStatement, model.getThenBranch()); }