TrivialIfInspection: remove asserts (for some reason javac compiles this file incorrectly if asserts present)

This commit is contained in:
Tagir Valeev
2018-09-25 14:03:49 +07:00
parent e188078dfd
commit b828bc9312
@@ -142,11 +142,13 @@ public class TrivialIfInspection extends BaseInspection implements CleanupLocalI
if (condition == null) {
return;
}
CommentTracker tr = new CommentTracker();
PsiReturnStatement nextStatement = ControlFlowUtils.getNextReturnStatement(statement);
if (nextStatement == null) {
return;
}
CommentTracker tr = new CommentTracker();
@NonNls final String newStatement = "return " + tr.text(condition) + ';';
PsiReplacementUtil.replaceStatement(statement, newStatement, tr);
assert nextStatement != null;
if (!ControlFlowUtils.isReachable(nextStatement)) {
nextStatement.delete();
}
@@ -219,7 +221,7 @@ public class TrivialIfInspection extends BaseInspection implements CleanupLocalI
private static void replaceSimplifiableImplicitAssignmentNegated(PsiIfStatement statement) {
final PsiElement prevStatement = PsiTreeUtil.skipWhitespacesBackward(statement);
final PsiExpression condition = statement.getCondition();
if (condition == null) {
if (condition == null || prevStatement == null) {
return;
}
final String conditionText = BoolUtils.getNegatedExpressionText(condition);
@@ -234,7 +236,6 @@ public class TrivialIfInspection extends BaseInspection implements CleanupLocalI
final PsiExpression lhs = assignmentExpression.getLExpression();
final String lhsText = lhs.getText();
PsiReplacementUtil.replaceStatement(statement, lhsText + operand + conditionText + ';');
assert prevStatement != null;
prevStatement.delete();
}