@Override
  public void invoke(@NotNull PsiElement element) {
    final PsiTryStatement tryStatement = PsiTreeUtil.getParentOfType(element, PsiTryStatement.class);
    if (tryStatement == null) return;
    CommentTracker commentTracker = new CommentTracker();
    final @NonNls StringBuilder newTryStatement = new StringBuilder("try");
    final Set<PsiClassType> exceptionsThrown = new HashSet<>();
    final PsiResourceList resourceList = tryStatement.getResourceList();
    if (resourceList != null) {
      newTryStatement.append(commentTracker.text(resourceList));
      ExceptionUtils.calculateExceptionsThrown(resourceList, exceptionsThrown);
    }
    final PsiCodeBlock tryBlock = tryStatement.getTryBlock();
    if (tryBlock == null) {
      return;
    }
    final String tryBlockText = commentTracker.text(tryBlock);
    newTryStatement.append(tryBlockText);
    ExceptionUtils.calculateExceptionsThrown(tryBlock, exceptionsThrown);
    final Comparator<PsiType> comparator = new HierarchicalTypeComparator();
    final PsiCatchSection[] catchSections = tryStatement.getCatchSections();
    for (PsiCatchSection catchSection : catchSections) {
      final PsiParameter parameter = catchSection.getParameter();
      final PsiCodeBlock block = catchSection.getCatchBlock();
      if (parameter != null && block != null) {
        final PsiType caughtType = parameter.getType();
        List<PsiClassType> exceptionsToExpand = new ArrayList<>(exceptionsThrown.size());
        for (PsiClassType aExceptionsThrown : exceptionsThrown) {
          if (caughtType.isAssignableFrom(aExceptionsThrown)) {
            exceptionsToExpand.add(aExceptionsThrown);
          }
        }
        for (PsiClassType type : exceptionsToExpand) {
          exceptionsThrown.remove(type);
        }

        PsiClassType commonSuperType = null;
        PsiClass commonSuper = ObscureThrownExceptionsIntention.findCommonSuperClass(exceptionsToExpand.toArray(PsiClassType.EMPTY_ARRAY));
        if (commonSuper != null) {
          commonSuperType = JavaPsiFacade.getElementFactory(commonSuper.getProject()).createType(commonSuper);
          if (commonSuperType.equals(caughtType)) {
            commonSuperType = null;
          }
        }

        if (commonSuperType != null) {
          exceptionsToExpand = Collections.singletonList(commonSuperType);
        } else {
          exceptionsToExpand.sort(comparator);
        }
        for (PsiClassType thrownType : exceptionsToExpand) {
          newTryStatement.append("catch(").append(thrownType.getCanonicalText()).append(' ').append(parameter.getName()).append(')');
          newTryStatement.append(commentTracker.text(block));
        }
      }
    }
    final PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock();
    if (finallyBlock != null) {
      newTryStatement.append("finally").append(commentTracker.text(finallyBlock));
    }
    final String newStatement = newTryStatement.toString();

    PsiReplacementUtil.replaceStatementAndShortenClassNames(tryStatement, newStatement, commentTracker);
  }
@Override
  public void invoke(@NotNull PsiElement element)