@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) {
      final CommentTracker ct = new CommentTracker();
      if (element instanceof PsiConditionalExpression) {
        ConditionalModel model = ConditionalModel.from((PsiConditionalExpression)element);
        if (model == null) return;
        String replacement = createReplacement(model.getCondition(), ct);
        if (replacement == null) return;
        PsiReplacementUtil.replaceExpression((PsiExpression)element, replacement, ct);
        return;
      }
      PsiIfStatement ifStatement = PsiTreeUtil.getParentOfType(element, PsiIfStatement.class);
      if (ifStatement == null) return;
      IfConditionalModel model = IfConditionalModel.from(ifStatement, false);
      if (model == null) return;
      String replacement = createReplacement(model.getCondition(), ct);
      if (replacement == null) return;
      PsiStatement elseBranch = model.getElseBranch();
      final PsiElement result;
      if (elseBranch instanceof PsiDeclarationStatement) {
        PsiReplacementUtil.replaceExpression(model.getElseExpression(), replacement, new CommentTracker());
        result = PsiReplacementUtil.replaceStatement(ifStatement, ct.text(elseBranch), ct);
        elseBranch.delete();
      }
      else {
        PsiReplacementUtil.replaceExpression(model.getThenExpression(), replacement, new CommentTracker());
        result = PsiReplacementUtil.replaceStatement(ifStatement, ct.text(model.getThenBranch()), ct);
        if (!PsiTreeUtil.isAncestor(ifStatement, elseBranch, true)) {
          new CommentTracker().deleteAndRestoreComments(elseBranch);
        }
      }
      SimplifiableIfStatementInspection.tryJoinDeclaration(result);
    }
@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater)