@Override public void visitAssertStatement(PsiAssertStatement statement) { super.visitAssertStatement(statement); final PsiExpression assertCondition = statement.getAssertCondition(); final PsiExpression expression = ParenthesesUtils.stripParentheses(assertCondition); if (expression == null) { return; } if (BoolUtils.isFalse(expression)) { return; } if (!PsiUtil.isConstantExpression(expression)) { return; } registerError(expression); }
@Override public void processIntention(@NotNull PsiElement element) throws IncorrectOperationException { final PsiAssertStatement assertStatement = (PsiAssertStatement)element; final PsiExpression condition = assertStatement.getAssertCondition(); final PsiExpression description = assertStatement.getAssertDescription(); final String negatedConditionString = BoolUtils.getNegatedExpressionText(condition); @NonNls final String newStatement; if (description == null) { newStatement = "if(" + negatedConditionString + "){ throw new java.lang.AssertionError();}"; } else { newStatement = "if(" + negatedConditionString + "){ throw new java.lang.AssertionError(" + description.getText() + ");}"; } replaceStatement(newStatement, assertStatement); }
public boolean satisfiedBy(PsiElement element) { if (!(element instanceof PsiAssertStatement)) { return false; } final PsiAssertStatement assertStatement = (PsiAssertStatement)element; return assertStatement.getAssertCondition() != null; }
@Override public void processIntention(@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()); }
public boolean satisfiedBy(PsiElement element) { if (!(element instanceof PsiAssertStatement)) { return false; } final PsiAssertStatement assertStatement = (PsiAssertStatement)element; if (assertStatement.getAssertCondition() == null) { return false; } return !ErrorUtil.containsError(element); }
@Override public void visitAssertStatement(PsiAssertStatement statement) { mVisitor.report("PsiAssertStatement", statement.getText(), statement); super.visitStatement(statement); }
@Override public void visitAssertStatement(PsiAssertStatement statement) { super.visitAssertStatement(statement); registerStatementError(statement); }