void (PsiIfStatement statement) { final PsiExpression condition = statement.getCondition(); if (condition == null) { return; } final String conditionText = BoolUtils.getNegatedExpressionText(condition); if (statement.getElseBranch() != null) { return; } final PsiStatement thenBranch = ControlFlowUtils.stripBraces(statement.getThenBranch()); if (!(thenBranch instanceof PsiAssertStatement assertStatement)) { return; } final PsiExpression assertCondition = assertStatement.getAssertCondition(); if (assertCondition == null) { return; } final PsiExpression replacementCondition = JavaPsiFacade.getElementFactory(statement.getProject()).createExpressionFromText( BoolUtils.isFalse(assertCondition) ? conditionText : conditionText + "||" + assertCondition.getText(), statement); assertCondition.replace(replacementCondition); statement.replace(assertStatement); }