@Override
  protected void invoke(@NotNull PsiElement element) {
    final PsiTryStatement tryStatement1 = (PsiTryStatement)element.getParent();
    final StringBuilder newTryStatement = new StringBuilder("try ");
    final PsiResourceList list1 = tryStatement1.getResourceList();
    int resourceCount = 0;
    if (list1 != null) {
      resourceCount = appendResources(newTryStatement, resourceCount, list1);
    }
    final PsiCodeBlock tryBlock1 = tryStatement1.getTryBlock();
    if (tryBlock1 == null) {
      return;
    }
    final PsiStatement[] statements = tryBlock1.getStatements();
    if (statements.length != 1) {
      return;
    }
    final PsiTryStatement tryStatement2 = (PsiTryStatement)statements[0];
    final PsiResourceList list2 = tryStatement2.getResourceList();
    if (list2 != null) {
      resourceCount = appendResources(newTryStatement, resourceCount, list2);
    }
    if (resourceCount > 0) {
      newTryStatement.append(')');
    }
    final PsiCodeBlock tryBlock2 = tryStatement2.getTryBlock();
    if (tryBlock2 == null) {
      return;
    }
    newTryStatement.append(tryBlock2.getText());
    final PsiCatchSection[] catchSections2 = tryStatement2.getCatchSections();
    for (PsiCatchSection section : catchSections2) {
      newTryStatement.append(section.getText());
    }
    final PsiCatchSection[] catchSections1 = tryStatement1.getCatchSections();
    for (PsiCatchSection section : catchSections1) {
      newTryStatement.append(section.getText());
    }
    final PsiElementFactory factory = JavaPsiFacade.getElementFactory(element.getProject());
    final PsiStatement newStatement = factory.createStatementFromText(newTryStatement.toString(), element);
    tryStatement1.replace(newStatement);
  }
@Override
  protected void invoke(@NotNull PsiElement element)