Beispiel #1
0
  public boolean isIfElseBreakingPossiblePatternOne(ASTIfElseNode node) {
    List<Object> ifBody = node.getIfBody();
    if (ifBody.size() != 1) {
      // we are only interested if size is one
      return false;
    }

    ASTNode onlyNode = (ASTNode) ifBody.get(0);
    boolean check = checkStmt(onlyNode, node);
    if (!check) {
      return false;
    }

    // breaking is possible
    // break and store
    newIfNode = new ASTIfNode(((ASTLabeledNode) node).get_Label(), node.get_Condition(), ifBody);
    remainingBody = node.getElseBody();

    return true;
  }
Beispiel #2
0
  public boolean isIfElseBreakingPossiblePatternTwo(ASTIfElseNode node) {
    List<Object> elseBody = node.getElseBody();
    if (elseBody.size() != 1) {
      // we are only interested if size is one
      return false;
    }

    ASTNode onlyNode = (ASTNode) elseBody.get(0);
    boolean check = checkStmt(onlyNode, node);
    if (!check) {
      return false;
    }
    // breaking is possible

    ASTCondition cond = node.get_Condition();
    // flip
    cond.flip();

    newIfNode = new ASTIfNode(((ASTLabeledNode) node).get_Label(), cond, elseBody);
    remainingBody = node.getIfBody();

    return true;
  }