Пример #1
0
 @Override
 public void visit(TryCatchStatement statement) {
   List<Statement> statements = processSequence(statement.getProtectedBody());
   statement.getProtectedBody().clear();
   statement.getProtectedBody().addAll(statements);
   statements = processSequence(statement.getHandler());
   statement.getHandler().clear();
   statement.getHandler().addAll(statements);
   resultStmt = statement;
 }
Пример #2
0
 private void wieldTryCatch(List<Statement> statements) {
   for (int i = 0; i < statements.size() - 1; ++i) {
     if (statements.get(i) instanceof TryCatchStatement
         && statements.get(i + 1) instanceof TryCatchStatement) {
       TryCatchStatement first = (TryCatchStatement) statements.get(i);
       TryCatchStatement second = (TryCatchStatement) statements.get(i + 1);
       if (Objects.equals(first.getExceptionType(), second.getExceptionType())
           && Objects.equals(first.getExceptionVariable(), second.getExceptionVariable())
           && briefStatementComparison(first.getHandler(), second.getHandler())) {
         first.getProtectedBody().addAll(second.getProtectedBody());
         statements.remove(i + 1);
         wieldTryCatch(first.getProtectedBody());
         --i;
       }
     }
   }
 }