Esempio n. 1
0
 @Override
 public void process(CtElement candidate) {
   if (((CtBinaryOperator) candidate).getKind() == BinaryOperatorKind.LE) {
     CtBinaryOperator op = (CtBinaryOperator) candidate;
     op.setKind(BinaryOperatorKind.GE);
   } else if (((CtBinaryOperator) candidate).getKind() == BinaryOperatorKind.GE) {
     CtBinaryOperator op = (CtBinaryOperator) candidate;
     op.setKind(BinaryOperatorKind.LE);
   }
 }
  @Override
  public void process(CtIf element) {
    // On récupère le body actuel :

    CtBlock fi;

    this.init();

    int addLoop = 1 + (int) (Math.random() * ((4 - 1)));

    CtBlock dummyIf = null;
    switch (addLoop) {
      case 1:
        dummyIf = getDummyIf();
        break;
      case 2:
        dummyIf = getDummyStringIf();
        break;
      case 3:
        dummyIf = getDummyAndIf();
        break;
      case 4:
        dummyIf = getDummyOrIf();
        break;
      default:
    }

    fi = (CtBlock) element.getThenStatement();

    fi = (CtBlock) element.getThenStatement();
    element.setThenStatement(dummyIf);
    ((CtIf) element.getThenStatement().getElements(new TypeFilter(CtIf.class)).get(0))
        .setThenStatement(fi);

    CtExpression cdt = element.getCondition();

    CtBinaryOperator condition = getFactory().Core().createBinaryOperator();

    condition.setKind(BinaryOperatorKind.AND);

    condition.setLeftHandOperand(cdt);
    condition.setRightHandOperand(
        ((CtIf) getDummyAndIf().getElements(new TypeFilter(CtIf.class)).get(0)).getCondition());

    element.setCondition(condition);
  }