Java 类com.intellij.psi.PsiAssertStatement 实例源码

项目:intellij-ce-playground    文件:ConstantAssertConditionInspection.java   
@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);
}
项目:tools-idea    文件:ConstantAssertConditionInspection.java   
@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);
}
项目:tools-idea    文件:AssertToIfIntention.java   
@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);
}
项目:consulo-java    文件:AssertToIfIntention.java   
@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);
}
项目:consulo-java    文件:ConstantAssertConditionInspection.java   
@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);
}
项目:intellij-ce-playground    文件:AssertStatementPredicate.java   
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiAssertStatement)) {
    return false;
  }
  final PsiAssertStatement assertStatement = (PsiAssertStatement)element;
  return assertStatement.getAssertCondition() != null;
}
项目:intellij-ce-playground    文件:AssertToIfIntention.java   
@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());
}
项目:tools-idea    文件:AssertStatementPredicate.java   
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);
}
项目:consulo-java    文件:AssertStatementPredicate.java   
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);
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitAssertStatement(PsiAssertStatement statement) {
    mVisitor.report("PsiAssertStatement", statement.getText(), statement);
    super.visitStatement(statement);
}
项目:intellij-ce-playground    文件:AssertStatementInspection.java   
@Override
public void visitAssertStatement(PsiAssertStatement statement) {
  super.visitAssertStatement(statement);
  registerStatementError(statement);
}
项目:tools-idea    文件:AssertStatementInspection.java   
@Override
public void visitAssertStatement(PsiAssertStatement statement) {
  super.visitAssertStatement(statement);
  registerStatementError(statement);
}
项目:consulo-java    文件:AssertStatementInspection.java   
@Override
public void visitAssertStatement(PsiAssertStatement statement) {
  super.visitAssertStatement(statement);
  registerStatementError(statement);
}