use of com.intellij.psi.PsiAssertStatement in project intellij-community by JetBrains.
the class AssertionCanBeIfInspection method doFixImpl.
private static void doFixImpl(@NotNull PsiElement element) {
final PsiAssertStatement assertStatement = (PsiAssertStatement) element;
@NonNls final StringBuilder newStatement = new StringBuilder();
final PsiExpression condition = assertStatement.getAssertCondition();
newStatement.append("if(").append(BoolUtils.getNegatedExpressionText(condition)).append(") throw new java.lang.AssertionError(");
final PsiExpression description = assertStatement.getAssertDescription();
if (description != null) {
newStatement.append(description.getText());
}
newStatement.append(");");
PsiReplacementUtil.replaceStatement(assertStatement, newStatement.toString());
}
Aggregations